Skip to content
Snippets Groups Projects

WIP: [ParameterTreeParser] add ParameterTreeParser for python scripts

This MR adds two static methods to ParameterTreeParser that can be used to read a python dictionary into a ParameterTree.

readPythonDict:

  • Traverses all key-value pairs in the python dictionary
    • if the value is an instance of pybind11::dict readPythonDict is called for the sub-ParameterTree of the corresponding key
    • else the string representation is added to the ParameterTree for the corresponding key

readPythonFile:

  • The python script is interpret using pybind11 eval_file method
  • The variable with the specified name (default: __dict__, which is the global scope) is casted to a pybind11:dict and passed to readPythonDict

For readPythonDict the include files and libraries of python must be available. I added a CMake variable HAVE_PYTHON3_DEV and an entry in the config.h for that. Futhermore I added AddPythonFlags.cmake for the management of the linking and includes.

For readPythonFile the embed functionality of python must be available this is checked with the CMake variable Python3_Development.Embed_FOUND and passed to the c++ side with HAVE_PYTHON3_EMBED.

Furthermore a type_caster is added for conversion of a python dict into a ParameterTree. That makes python bindings that take a ParameterTree as a function argument callable from the python-side with a dict.

Edited by Nils-Arne Dreier

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading