launch icon indicating copy to clipboard operation
launch copied to clipboard

Pass modules to PythonExpression

Open RobertBlakeAnderson opened this issue 2 years ago • 1 comments

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 avatar Sep 26 '22 19:09 RobertBlakeAnderson

Any feedback on this?

RobertBlakeAnderson avatar Nov 18 '22 16:11 RobertBlakeAnderson

Could you add tests? @RobertBlakeAnderson

methylDragon avatar Dec 13 '22 08:12 methylDragon

Sure thing! I'll get to it shortly.

RobertBlakeAnderson avatar Dec 13 '22 16:12 RobertBlakeAnderson

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

RobertBlakeAnderson avatar Dec 14 '22 22:12 RobertBlakeAnderson

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

methylDragon avatar Dec 14 '22 23:12 methylDragon

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 avatar Dec 16 '22 16:12 RobertBlakeAnderson

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.

RobertBlakeAnderson avatar Dec 20 '22 20:12 RobertBlakeAnderson

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

:fire:

methylDragon avatar Dec 20 '22 21:12 methylDragon

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

methylDragon avatar Dec 20 '22 22:12 methylDragon

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 avatar Dec 21 '22 00:12 methylDragon

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

methylDragon avatar Dec 21 '22 19:12 methylDragon