diff --git a/rust2rpm/cfg.py b/rust2rpm/cfg.py index efccf87..9385b20 100644 --- a/rust2rpm/cfg.py +++ b/rust2rpm/cfg.py @@ -111,3 +111,7 @@ def evaluate(expr, nested=False): return x case _: raise ValueError + +def parse_and_evaluate(expr): + parsed = cfg_grammar().parse_string(expr) + return evaluate(parsed[0]) diff --git a/rust2rpm/tests/test_cfg.py b/rust2rpm/tests/test_cfg.py index ea89b6b..4a86abb 100644 --- a/rust2rpm/tests/test_cfg.py +++ b/rust2rpm/tests/test_cfg.py @@ -55,6 +55,5 @@ def test_pyparsing_run_tests(): ]) def test_expressions(expr, expected): - parsed = cfg.cfg_grammar().parse_string(expr) - value = cfg.evaluate(parsed[0]) + value = cfg.parse_and_evaluate(expr) assert value == expected