dataset/seed/journald_remote/funcs/journald_remote.py

21 lines
713 B
Python
Raw Normal View History

2023-06-23 08:12:05 +02:00
from itertools import chain as _chain
def calc_vector_conditions(messages, services, functions):
mes = _chain(*messages)
ser = list(_chain(*services))
fun = list(_chain(*functions))
conditions = []
for idx, message in enumerate(mes):
service = ser[idx]
function = fun[idx]
condition = '(.SYSLOG_IDENTIFIER == "' + service + '" && '
if not function:
condition += '.message == "' + message + '"'
else:
condition += function + '(to_string(.message) ?? "", "' + message + '")'
condition += ')'
if condition not in conditions:
conditions.append(condition)
return '!(' + ' || '.join(conditions) + ')'