API#
This is the internal API reference for ibek
ibek
#
- ibek.__version__: str#
Version number as calculated by pypa/setuptools_scm
ibek.globals
#
A few global definitions
ibek.support
#
Support Class to represent a deserialized <MODULE_NAME>.ibek.support.yaml file.
ibek.ioc
#
Classes for generating an IocInstance derived class from a set of support module YAML files
- class ibek.ioc.Entity(*, type: str, entity_enabled: bool = True)[source]#
A baseclass for all generated Entity classes.
- add_ibek_attributes()[source]#
Whole Entity model validation
Do jinja rendering of pre_defines/ parameters / post_defines in the correct order.
Also adds pre_defines and post_defines to the model instance, making them available for the phase 2 (final) jinja rendering performed in ibek.runtime_cmds.generate().
ibek.render
#
Functions for rendering lines in the boot script using Jinja2
- class ibek.render.Render[source]#
A class for generating snippets of startup script / EPICS DB by using Jinja to combine snippet templates from support module yaml with substitution values supplied in ioc entity yaml
- render_text(instance: Entity, text: str, when=When.every, suffix='') str [source]#
Add in the next line of text, honouring the once flag which will only add the line once per IOC.
Jinja rendering of values/args has already been done in Entity.__post_init__ but we pass all strings though jinja again to render any other jinja in the IOC (e.g. database and function entries)
once uses the name of the model + suffix to track which lines have been rendered already. The suffix can be used where a given Entity has more than one element to render once (e.g. functions)
- render_pre_ioc_init(instance: Entity) str | None [source]#
render the startup script by combining the jinja template from an entity with the arguments from an Entity
- render_post_ioc_init(instance: Entity) str | None [source]#
render the post-iocInit entries by combining the jinja template from an entity with the arguments from an Entity
- render_environment_variables(instance: Entity) str | None [source]#
render the environment variable elements by combining the jinja template from an entity with the arguments from an Entity
- render_elements(entities: Sequence[Entity], render_element: Callable[[Entity], str | None]) str [source]#
Render elements of a given IOC instance based on calling the correct method
- render_pre_ioc_init_elements(entities: Sequence[Entity]) str [source]#
Render all of the startup script entries for a given IOC instance
ibek.utils
#
A class containing utility functions for passing into the Jinja context.
This allows us to provide simple functions that can be called inside Jinja templates with {{ _global.function_name() }}. It also allows us to maintain state between calls to the Jinja templates because we pass a single instance of this class into all Jinja contexts.
- class ibek.utils.Utils[source]#
A Utility class for adding functions to the Jinja context
- set_file_name(file: Path)[source]#
Set the ioc name based on the file name of the instance definition
- incrementor(name: str, start: int = 0, increment: int = 1, stop: int | None = None) int [source]#
get a named counter that increments by inc each time it is called
creates a new counter if it does not yet exist
- render(context: Any, template_text: Any) str [source]#
Render a Jinja template with the global _global object in the context
- render_map(context: Any, map: Mapping[str, str | None]) dict[str, str] [source]#
Render a map of jinja templates with values from the given context.
If given a key with a value of
None
, the key itself will be used as a template value, so{"P": None}
is equivalent to{"P": "{{ P }}"}
.- Parameters:
context – Context to extract template variables from
map – Map of macro to jinja template to render
- class apischema.types.UndefinedType#
A sentinel value that allows detection that a value has not been passed at init