mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Notification rework v0.5
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user