From 92202fd51ad6b6c35c2858cf6e283da539130f28 Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Fri, 1 Oct 2021 22:22:37 +0200 Subject: [PATCH] Allow greedy property evaluation This can be used, to redefine a property from its previous value, e.g. for normalization: ```xml ``` Without this option, due to lazy evaluation, it would be an attempt to recursively evaluate the property. --- src/xacro/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/xacro/__init__.py b/src/xacro/__init__.py index 3b9373a..7ea294a 100644 --- a/src/xacro/__init__.py +++ b/src/xacro/__init__.py @@ -557,7 +557,7 @@ def grab_property(elt, table): assert(elt.tagName == 'xacro:property') remove_previous_comments(elt) - name, value, default, scope = check_attrs(elt, ['name'], ['value', 'default', 'scope']) + name, value, default, scope, greedy = check_attrs(elt, ['name'], ['value', 'default', 'scope', 'greedy']) if not is_valid_name(name): raise XacroException('Property names must be valid python identifiers: ' + name) if value is not None and default is not None: @@ -590,7 +590,7 @@ def grab_property(elt, table): return # cannot store the value, no reason to evaluate it else: target_table = table - unevaluated = True + unevaluated = not get_boolean_value(eval_text(greedy or 'false', table), greedy) if not unevaluated and isinstance(value, _basestr): value = eval_text(value, table)