[pp:python] add '"mode": "eval"'

This commit is contained in:
Mike Fährmann
2025-09-22 16:54:50 +02:00
parent b49745d351
commit 2480ba2a55
3 changed files with 56 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2023 Mike Fährmann
# Copyright 2023-2025 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@@ -17,10 +17,14 @@ class PythonPP(PostProcessor):
def __init__(self, job, options):
PostProcessor.__init__(self, job)
spec = options["function"]
module_name, _, function_name = spec.rpartition(":")
module = util.import_file(module_name)
self.function = getattr(module, function_name)
mode = options.get("mode")
if mode == "eval" or not mode and options.get("expression"):
self.function = util.compile_expression(options["expression"])
else:
spec = options["function"]
module_name, _, function_name = spec.rpartition(":")
module = util.import_file(module_name)
self.function = getattr(module, function_name)
events = options.get("event")
if events is None: