Notification rework v0.5

This commit is contained in:
Jokob-sk
2023-10-08 11:15:10 +11:00
parent d4b590a9fc
commit 79c47015f4
7 changed files with 111 additions and 81 deletions

View File

@@ -71,30 +71,42 @@ def get_plugin_string(props, el):
#-------------------------------------------------------------------------------
def flatten_array(arr):
# generates a comma separated list of values from a list (or a string representing a list)
def list_to_csv(arr):
tmp = ''
arrayItemStr = ''
mylog('debug', '[Plugins] Flattening the below array')
mylog('debug', '[Plugins] Flattening the below array')
mylog('debug', arr)
for arrayItem in arr:
# only one column flattening is supported
if isinstance(arrayItem, list):
arrayItemStr = str(arrayItem[0]).replace("'", '') # removing single quotes - not allowed
else:
# is string already
arrayItemStr = arrayItem
mylog('debug', f'[Plugins] isinstance(arr, list) : {isinstance(arr, list)}')
mylog('debug', f'[Plugins] isinstance(arr, str) : {isinstance(arr, str)}')
if isinstance(arr, str):
return arr.replace('[','').replace(']','').replace("'", '') # removing brackets and single quotes (not allowed)
elif isinstance(arr, list):
for arrayItem in arr:
# only one column flattening is supported
if isinstance(arrayItem, list):
arrayItemStr = str(arrayItem[0]).replace("'", '') # removing single quotes - not allowed
else:
# is string already
arrayItemStr = arrayItem
tmp += f'{arrayItemStr},'
tmp += f'{arrayItemStr},'
tmp = tmp[:-1] # Remove last comma ','
tmp = tmp[:-1] # Remove last comma ','
mylog('debug', f'[Plugins] Flattened array: {tmp}')
mylog('debug', f'[Plugins] Flattened array: {tmp}')
return tmp
else:
mylog('none', f'[Plugins] ERROR Could not convert array: {arr}')
return tmp