model.py.jinja 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/python3
  2. # This file was automatically generated from drawio2CBD from
  3. # {{ file }}
  4. from pyCBD.Core import *
  5. from pyCBD.lib.std import *
  6. {% for file, klss in imports.items() %}
  7. from {{ file }} import {{ klss|join(', ') }}
  8. {% endfor %}
  9. {% for block in classes %}
  10. class {{block.class_name}}(CBD):
  11. {% if block.docs != "" %}
  12. """
  13. {{ block.docs }}
  14. """
  15. {% endif %}
  16. def __init__(self, block_name{% if block.properties|length > 0 %}, {{block.get_properties()}}{% endif %}):
  17. super().__init__(block_name, input_ports={{block.get_inputs()}}, output_ports={{ block.get_outputs() }})
  18. # Create the Blocks
  19. {% for child in block.blocks %}
  20. self.addBlock({{child.class_name}}("{{child.block_name}}"{% if child.args|length > 0 %}, {{child.get_properties()}}{% endif %}))
  21. {% endfor %}
  22. # Create the Connections
  23. {% for source, target in block.connections %}
  24. {% set send = "" %}
  25. {% if source[1] is not none %}
  26. {% set send = ", output_port_name=\"" + source[1] + '"' %}
  27. {% endif %}
  28. {% set tend = "" %}
  29. {% if target[1] is not none %}
  30. {% set tend = ", input_port_name=\"" + target[1] + '"' %}
  31. {% endif %}
  32. self.addConnection("{{source[0]}}", "{{target[0]}}"{{ send }}{{ tend }})
  33. {% endfor %}
  34. {% endfor %}