From 8c11134296fd65572233312f6455a864d97c0d24 Mon Sep 17 00:00:00 2001 From: Carlo Rizzardo Date: Wed, 20 Mar 2024 17:59:36 +0100 Subject: [PATCH] Moved conditional import of ament_index_python --- xacro/__init__.py | 6 +++--- xacro/substitution_args.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xacro/__init__.py b/xacro/__init__.py index a16dc90..32e2076 100644 --- a/xacro/__init__.py +++ b/xacro/__init__.py @@ -285,14 +285,14 @@ def eval_extension(s): if s == '$(cwd)': return os.getcwd() try: - from .substitution_args import resolve_args, ArgException, PackageNotFoundError + from .substitution_args import resolve_args, ArgException return resolve_args(s, context=substitution_args_context) except ImportError as e: raise XacroException("substitution args not supported: ", exc=e) except ArgException as e: raise XacroException("Undefined substitution argument", exc=e) - except PackageNotFoundError as e: - raise XacroException("package not found:", exc=e) + except Exception as e: + raise XacroException(f"Argument resolution failed: exception={type(e)}: {e}", exc=e) class Table(dict): diff --git a/xacro/substitution_args.py b/xacro/substitution_args.py index 3773ea0..9f136b7 100644 --- a/xacro/substitution_args.py +++ b/xacro/substitution_args.py @@ -41,7 +41,6 @@ import os import yaml -from ament_index_python.packages import get_package_share_directory, PackageNotFoundError from io import StringIO @@ -138,6 +137,7 @@ def _dirname(resolved, a, args, context): def _eval_find(pkg): + from ament_index_python.packages import get_package_share_directory, PackageNotFoundError return get_package_share_directory(pkg)