in next_steps/operations/filter_rotator/src/filter_rotator_function/template_evaluation.py [0:0]
def eval_expression(s: str, names: Dict = None) -> str:
"""
Customizes the functions and names available in
expression and evaluates an expression.
"""
functions = DEFAULT_FUNCTIONS.copy()
functions.update(
unixtime=_unixtime,
datetime_format=_datetime_format,
starts_with=_starts_with,
ends_with=_ends_with,
start=_start,
end=_end,
timedelta_days=_timedelta_days,
timedelta_hours=_timedelta_hours,
timedelta_minutes=_timedelta_minutes,
timedelta_seconds=_timedelta_seconds
)
names_combined = DEFAULT_NAMES.copy()
names_combined.update(
now=datetime.datetime.now()
)
if names:
names_combined.update(names)
return simple_eval(s, functions=functions, names=names_combined)