Skip to content

Commit

Permalink
Moved conditional import of ament_index_python
Browse files Browse the repository at this point in the history
  • Loading branch information
c-rizz committed Mar 20, 2024
1 parent 53f71c2 commit 8c11134
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions xacro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion xacro/substitution_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import os
import yaml

from ament_index_python.packages import get_package_share_directory, PackageNotFoundError
from io import StringIO


Expand Down Expand Up @@ -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)


Expand Down

0 comments on commit 8c11134

Please sign in to comment.