ros2 / launch

Tools for launching multiple processes and for writing tests involving multiple processes.
Apache License 2.0
124 stars 139 forks source link

Pass modules to PythonExpression #655

Closed RobertBlakeAnderson closed 1 year ago

RobertBlakeAnderson commented 1 year ago

Added ability to pass Python modules to the PythonExpression substitution. Allows eval of more expressions.

For example, my motivating use case was: robot_desc = PythonExpression(["process_file('", filepath, "').toprettyxml(indent=' ')"], xacro.__dict__)

RobertBlakeAnderson commented 1 year ago

Any feedback on this?

methylDragon commented 1 year ago

Could you add tests? @RobertBlakeAnderson

RobertBlakeAnderson commented 1 year ago

Sure thing! I'll get to it shortly.

RobertBlakeAnderson commented 1 year ago

Done. I also fixed a couple tiny issues that I found while creating and running the tests.

methylDragon commented 1 year ago
RobertBlakeAnderson commented 1 year ago

Got it working with Substitutions in the constructor. Updated tests and added new ones for the XML. I'll now look into the matter of keying the definitions to their modules, with backwards compatibility. As for naming, maybe python_modules or python_deps would be less ambiguous.

RobertBlakeAnderson commented 1 year ago

Done. The expressions will now require the module names before the definitions you use. For backwards compatibility, math definitions will work with or without the module name, and the tests include cases for both. If you wish, the implicit references could be considered deprecated for removal at a future date.

I think this PR is ready to go now.

methylDragon commented 1 year ago

:fire:

methylDragon commented 1 year ago
methylDragon commented 1 year ago

Flake 8 issues :o

https://ci.ros2.org/job/ci_linux-aarch64/12418/testReport/launch.test/test_flake8/test_flake8/

I think just change the name locals

methylDragon commented 1 year ago