secop_ophyd.GenNodeCode#
Code generation for annotated ophyd device classes using Jinja2 templates.
Module Contents#
Classes#
Represents an enum member with name and value. |
|
Represents an enum class definition. |
|
Represents a module attribute with name, type, and optional description. |
|
Represents a module property attribute with name, type |
|
Represents a module parameter attribute with name, type, and optional description. |
|
Represents a class method with signature and description. |
|
Represents a module class to be generated. |
|
Represents a node class to be generated. |
|
Generates annotated Python classes for SECoP ophyd devices. |
Functions#
how to create internal names |
|
API#
- class secop_ophyd.GenNodeCode.EnumClass[source]#
Represents an enum class definition.
- members: list[secop_ophyd.GenNodeCode.EnumMember] = None#
- class secop_ophyd.GenNodeCode.ModuleAttribute[source]#
Represents a module attribute with name, type, and optional description.
- class secop_ophyd.GenNodeCode.PropertyAttribute[source]#
Represents a module property attribute with name, type
- class secop_ophyd.GenNodeCode.ParameterAttribute[source]#
Represents a module parameter attribute with name, type, and optional description.
- class secop_ophyd.GenNodeCode.Method(cmd_name: str, description: str, cmd_sign: inspect.Signature)[source]#
Represents a class method with signature and description.
This class supports both old-style initialization (for backward compatibility) and new-style dataclass initialization.
Initialization
Initialize Method (backward compatibility constructor).
- Args:
cmd_name: Name of the command description: Description of the command cmd_sign: Signature of the command
- class secop_ophyd.GenNodeCode.ModuleClass[source]#
Represents a module class to be generated.
- parameters: list[secop_ophyd.GenNodeCode.ParameterAttribute] = 'field(...)'#
- properties: list[secop_ophyd.GenNodeCode.PropertyAttribute] = 'field(...)'#
- methods: list[secop_ophyd.GenNodeCode.Method] = 'field(...)'#
- enums: list[secop_ophyd.GenNodeCode.EnumClass] = 'field(...)'#
- class secop_ophyd.GenNodeCode.NodeClass[source]#
Represents a node class to be generated.
- properties: list[secop_ophyd.GenNodeCode.PropertyAttribute] = 'field(...)'#
- modules: list[secop_ophyd.GenNodeCode.ModuleAttribute] = 'field(...)'#
- class secop_ophyd.GenNodeCode.GenNodeCode(path: str | None = None, log=None)[source]#
Generates annotated Python classes for SECoP ophyd devices.
This class can generate Python code in two ways: 1. By introspecting a fully instantiated SECoP ophyd device 2. From a SECoP JSON describe message (future feature)
The generated code uses Jinja2 templates and is formatted with Black.
Initialization
Initialize the code generator.
- Args:
path: Optional path to the module folder log: Optional logger instance
- add_import(module: str, class_str: str | None = None)[source]#
Add an import to the import dictionary.
- Args:
module: Python module to import from class_str: Class/symbol to import. If None or empty, imports the module directly.
- add_mod_class(module_cls: str, bases: list[str], parameters: list[secop_ophyd.GenNodeCode.ParameterAttribute], properties: list[secop_ophyd.GenNodeCode.PropertyAttribute], cmd_plans: list[secop_ophyd.GenNodeCode.Method], description: str = '', enum_classes: list[secop_ophyd.GenNodeCode.EnumClass] | None = None)[source]#
Add a module class to be generated.
- Args:
module_cls: Name of the module class bases: Base classes parameters: List of parameter attributes properties: List of property attributes cmd_plans: List of method definitions description: Optional class description
- add_node_class(node_cls: str, bases: list[str], properties: list[secop_ophyd.GenNodeCode.PropertyAttribute], modules: list[secop_ophyd.GenNodeCode.ModuleAttribute], description: str = '')[source]#
Add a node class to be generated.
- Args:
node_cls: Name of the node class bases: Base classes attrs: List of attribute tuples. Supported formats:
(name, type)
(name, type, type_param)
(name, type, type_param, description, category)
- from_json_describe(json_data: str | dict)[source]#
Generate classes from a SECoP JSON describe message.
- Args:
json_data: JSON string or dict containing SECoP describe data