diff --git a/tools/roslaunch/src/roslaunch/arg_dump.py b/tools/roslaunch/src/roslaunch/arg_dump.py index df5a462d64..c886eef577 100644 --- a/tools/roslaunch/src/roslaunch/arg_dump.py +++ b/tools/roslaunch/src/roslaunch/arg_dump.py @@ -45,7 +45,7 @@ from roslaunch.config import load_config_default def get_args(roslaunch_files): - loader = roslaunch.xmlloader.XmlLoader(resolve_anon=False) + loader = roslaunch.xmlloader.XmlLoader(resolve_anon=False, args_only=True) config = load_config_default(roslaunch_files, None, loader=loader, verbose=False, assign_machines=False) return loader.root_context.resolve_dict.get('arg_doc', {}) diff --git a/tools/roslaunch/src/roslaunch/xmlloader.py b/tools/roslaunch/src/roslaunch/xmlloader.py index 226d2bdf08..3e9d0f6825 100644 --- a/tools/roslaunch/src/roslaunch/xmlloader.py +++ b/tools/roslaunch/src/roslaunch/xmlloader.py @@ -166,15 +166,18 @@ class XmlLoader(loader.Loader): Parser for roslaunch XML format. Loads parsed representation into ROSConfig model. """ - def __init__(self, resolve_anon=True): + def __init__(self, resolve_anon=True, args_only=False): """ @param resolve_anon: If True (default), will resolve $(anon foo). If false, will leave these args as-is. @type resolve_anon: bool + @param args_only: if True, will only load arg tags (e.g. autocompletion purposes) + @type args_only: bool """ # store the root XmlContext so that outside code can access it self.root_context = None self.resolve_anon = resolve_anon + self.args_only = args_only def resolve_args(self, args, context): """ @@ -673,7 +676,12 @@ def _recurse_load(self, ros_config, tags, context, default_machine, is_core, ver """ for tag in [t for t in tags if t.nodeType == DomNode.ELEMENT_NODE]: name = tag.tagName - if name == 'group': + if name == 'arg': + self._arg_tag(tag, context, ros_config, verbose=verbose) + elif self.args_only: + # do not load other tags + pass + elif name == 'group': if ifunless_test(self, tag, context): self._check_attrs(tag, context, ros_config, XmlLoader.GROUP_ATTRS) child_ns = self._ns_clear_params_attr(name, tag, context, ros_config) @@ -715,8 +723,6 @@ def _recurse_load(self, ros_config, tags, context, default_machine, is_core, ver default_machine = val elif name == 'env': self._env_tag(tag, context, ros_config) - elif name == 'arg': - self._arg_tag(tag, context, ros_config, verbose=verbose) else: ros_config.add_config_error("unrecognized tag "+tag.tagName) return default_machine