![]() |
launch_xml package from launch repolaunch launch_testing launch_testing_ament_cmake launch_xml launch_yaml test_launch_testing |
Package Summary
Tags | No category tags. |
Version | 0.10.4 |
License | Apache License 2.0 |
Build type | AMENT_PYTHON |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/ros2/launch.git |
VCS Type | git |
VCS Version | foxy |
Last Updated | 2021-04-05 |
Dev Status | DEVELOPED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Ivan Paunovic
Authors
launch_xml
This package provides an abstraction of the XML tree.
XML front-end mapping rules
Accessing xml attributes
When having an xml tag like:
<tag value="2"/>
If the entity e
is wrapping it, the following statements will be true:
e.get_attr('value') == '2'
e.get_attr('value', data_type=int) == 2
e.get_attr('value', data_type=float) == 2.0
By default, the value of the attribute is returned as a string.
Allowed types are:
- scalar types: str, int, float, bool
- lists: Can be uniform like List[int]
, or non-uniform like List[Union[str, int]]
, List
(same as list
).
In any case, the members should be of one of the scalar types.
- An union of both any of the above. e.g.: Union[List[int], int]
.
- The list of entities type: List[Entity]
(see below).
List
is the usual object from the typing
package.
data_type
can also be set to None
, which works in the same way as passing:
Union[int, float, bool, list, str]
For handling lists, the *-sep
attribute is used. e.g.:
<tag value="2,3,4" value-sep=","/>
<tag2 value="2 3 4" value-sep=" "/>
<tag3 value="2, 3, 4" value-sep=", "/>
tag.get_attr('value', data_type=List[int]) == [2, 3, 4]
tag2.get_attr('value', data_type=List[float]) == [2.0, 3.0, 4.0]
tag3.get_attr('value', data_type=List[str]) == ['2', '3', '4']
For checking if an attribute exists, use an optional argument:
value = e.get_attr('value', optional=True)
if value is not None:
do_something(value)
With optional=False
(default), AttributeError
is raised if it is not found.
Accessing XML children as attributes:
In this xml:
<executable cmd="ls">
<env name="a" value="100"/>
<env name="b" value="stuff"/>
</node>
The env
children could be accessed like:
env = e.get_attr('env', data_type=List[Entity])
len(env) == 2
env[0].get_attr('name') == 'a'
env[0].get_attr('value') == '100'
env[1].get_attr('name') == 'b'
env[1].get_attr('value') == 'stuff'
In these cases, e.env
is a list of entities, that can be accessed in the same abstract way.
Accessing all the XML children:
All the children can be directly accessed:
e.children
It returns a list of launch_xml.Entity
wrapping each of the XML children.
Built-in substitutions
See this document.
Changelog for package launch_xml
0.10.4 (2020-12-08)
0.10.3 (2020-08-27)
- Add pytest.ini so local tests don\'t display warning (#428)
- Contributors: Chris Lalancette
0.10.2 (2020-05-26)
0.10.1 (2020-05-08)
0.10.0 (2020-04-24)
- more verbose test_flake8 error messages (same as ros2/launch_ros#135)
- Use imperative mood in docstrings. (#362)
- Contributors: Dirk Thomas, Steven! Ragnar
Wiki Tutorials
Source Tutorials
Package Dependencies
Deps | Name | |
---|---|---|
1 | ament_copyright | |
1 | ament_flake8 | |
1 | ament_pep257 | |
1 | launch |
System Dependencies
Name |
---|
python3-pytest |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged launch_xml at answers.ros.org
![]() |
launch_xml package from launch repolaunch launch_testing launch_testing_ament_cmake launch_xml launch_yaml test_launch_testing |
Package Summary
Tags | No category tags. |
Version | 0.9.7 |
License | Apache License 2.0 |
Build type | AMENT_PYTHON |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/ros2/launch.git |
VCS Type | git |
VCS Version | eloquent |
Last Updated | 2020-12-04 |
Dev Status | DEVELOPED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Ivan Paunovic
Authors
launch_xml
This package provides an abstraction of the XML tree.
XML front-end mapping rules
Accessing xml attributes
When having an xml tag like:
<tag value="2"/>
If the entity e
is wrapping it, the following statements will be true:
e.get_attr('value') == '2'
e.get_attr('value', data_type=int) == 2
e.get_attr('value', data_type=float) == 2.0
By default, the value of the attribute is returned as a string.
Allowed types are:
- scalar types: str, int, float, bool
- lists: Can be uniform like List[int]
, or non-uniform like List[Union[str, int]]
, List
(same as list
).
In any case, the members should be of one of the scalar types.
- An union of both any of the above. e.g.: Union[List[int], int]
.
- The list of entities type: List[Entity]
(see below).
List
is the usual object from the typing
package.
data_type
can also be set to None
, which works in the same way as passing:
Union[int, float, bool, list, str]
For handling lists, the *-sep
attribute is used. e.g.:
<tag value="2,3,4" value-sep=","/>
<tag2 value="2 3 4" value-sep=" "/>
<tag3 value="2, 3, 4" value-sep=", "/>
tag.get_attr('value', data_type=List[int]) == [2, 3, 4]
tag2.get_attr('value', data_type=List[float]) == [2.0, 3.0, 4.0]
tag3.get_attr('value', data_type=List[str]) == ['2', '3', '4']
For checking if an attribute exists, use an optional argument:
value = e.get_attr('value', optional=True)
if value is not None:
do_something(value)
With optional=False
(default), AttributeError
is raised if it is not found.
Accessing XML children as attributes:
In this xml:
<executable cmd="ls">
<env name="a" value="100"/>
<env name="b" value="stuff"/>
</node>
The env
children could be accessed like:
env = e.get_attr('env', data_type=List[Entity])
len(env) == 2
env[0].get_attr('name') == 'a'
env[0].get_attr('value') == '100'
env[1].get_attr('name') == 'b'
env[1].get_attr('value') == 'stuff'
In these cases, e.env
is a list of entities, that can be accessed in the same abstract way.
Accessing all the XML children:
All the children can be directly accessed:
e.children
It returns a list of launch_xml.Entity
wrapping each of the XML children.
Built-in substitutions
See this document.
Changelog for package launch_xml
0.9.7 (2020-12-04)
0.9.6 (2020-01-21)
0.9.5 (2019-11-13)
0.9.4 (2019-11-08)
0.9.3 (2019-10-23)
0.9.2 (2019-10-23)
- install resource marker file for packages (#341)
- Contributors: Dirk Thomas
0.9.1 (2019-09-25)
0.9.0 (2019-09-18)
- install package manifest (#330)
- Add deprecated argument to LaunchDescriptionn (#291)
- Add support for not optional environment variable substitution (#288)
- Add parsing methods for SetEnviromentVariable and UnsetEnviromentVariable (#272)
- Add parsing method for DeclareLaunchArgument (#270)
- Add frontend module in launch, launch_xml and launch_yaml packages (#226)
- Contributors: Dirk Thomas, ivanpauno
Wiki Tutorials
Source Tutorials
Package Dependencies
Deps | Name | |
---|---|---|
1 | ament_copyright | |
1 | ament_flake8 | |
1 | ament_pep257 | |
1 | launch |
System Dependencies
Name |
---|
python3-pytest |