Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
build
bazel-*
MODULE.bazel.lock
*.egg-info
5 changes: 3 additions & 2 deletions xacro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,12 +1040,13 @@ def parse(inp, filename=None):
f.close()


def process_doc(doc, mappings=None, **kwargs):
def process_doc(doc, mappings=None, extra_find_pkgs={}, **kwargs):
global verbosity
verbosity = kwargs.get('verbosity', verbosity)

# set substitution args
substitution_args_context['arg'] = {} if mappings is None else mappings
substitution_args_context['find'] = extra_find_pkgs

# if not yet defined: initialize filestack
if not filestack:
Expand All @@ -1064,7 +1065,7 @@ def process_doc(doc, mappings=None, **kwargs):

# reset substitution args
substitution_args_context['arg'] = {}

substitution_args_context['find'] = {}

def open_output(output_filename):
if output_filename is None:
Expand Down
8 changes: 6 additions & 2 deletions xacro/substitution_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class ArgException(SubstitutionException):
"""Exception for missing $(arg) values."""
pass


def _eval_env(name):
"""
Returns the environment variable value or throws exception.
Expand Down Expand Up @@ -152,7 +151,12 @@ def _find(resolved, a, args, context):
if len(args) != 1:
raise SubstitutionException(
'$(find pkg) accepts exactly one argument [%s]' % a)
return resolved.replace('$(%s)' % a, _eval_find(args[0]))
pkg_name_str = args[0]
if "find" in context and pkg_name_str in context["find"]:
pkg_path_str = context["find"][pkg_name_str]
else:
pkg_path_str = _eval_find(args[0])
return resolved.replace('$(%s)' % a, pkg_path_str)


def _eval_arg(name, args):
Expand Down