From d915a18a4095b3137396553d1196cb66879131e6 Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Thu, 1 Apr 2021 07:18:51 +0000 Subject: [PATCH] Pass through datetime, math, re, and time to --pyfilter --- archivebot-jobs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archivebot-jobs b/archivebot-jobs index 86eaa0c..ef3842d 100755 --- a/archivebot-jobs +++ b/archivebot-jobs @@ -62,7 +62,7 @@ class FilterAction(argparse.Action): func = compile(values[0], '', 'eval') except Exception as e: parser.error(f'Could not compile filter expression: {type(e).__module__}.{type(e).__name__}: {e!s}') - setattr(namespace, self.dest, lambda job: eval(func, {}, {'job': job})) + setattr(namespace, self.dest, lambda job: eval(func, {k: v for k, v in globals().items() if k in ('datetime', 'math', 're', 'time')}, {'job': job})) return global columns match = re.match(r'^(?P[A-Za-z ]+)(?P[=<>^*$~])(?P.*)$', values[0])