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
#
The Support Class represents a deserialized <MODULE_NAME>.ibek.support.yaml file.
- class ibek.support.Arg(*, type: str, name: str, description: str)[source]#
Base class for all Argument Types
- class ibek.support.FloatArg(*, type: Literal['float'] = 'float', name: str, description: str, default: float | None = None)[source]#
An argument with a float value
- class ibek.support.StrArg(*, type: Literal['str'] = 'str', name: str, description: str, default: str | None = None)[source]#
An argument with a str value
- class ibek.support.IntArg(*, type: Literal['int'] = 'int', name: str, description: str, default: int | None = None)[source]#
An argument with an int value
- class ibek.support.BoolArg(*, type: Literal['bool'] = 'bool', name: str, description: str, default: bool | None = None)[source]#
An argument with an bool value
- class ibek.support.ObjectArg(*, type: Literal['object'] = 'object', name: str, description: str, default: str | None = None)[source]#
A reference to another entity defined in this IOC
- class ibek.support.IdArg(*, type: Literal['id'] = 'id', name: str, description: str, default: str | None = None)[source]#
Explicit ID argument that an object can refer to
- class ibek.support.EnumArg(*, type: Literal['enum'] = 'enum', name: str, description: str, default: Any | None = None, values: Dict[str, Any])[source]#
An argument with an enum value
- class ibek.support.Database(*, file: str, args: Mapping[str, str | None])[source]#
A database file that should be loaded by the startup script and its args
- class ibek.support.EnvironmentVariable(*, name: str, value: str)[source]#
An environment variable that should be set in the startup script
- class ibek.support.Comment(*, type: Literal['comment'] = 'comment', when: When = 'every', value: str = '')[source]#
A script snippet that will have ‘# ‘ prepended to every line for insertion into the startup script
- class ibek.support.Text(*, type: Literal['text'] = 'text', when: str = 'every', value: str = '')[source]#
A script snippet to insert into the startup script
- class ibek.support.Value(*, name: str, description: str, value: str)[source]#
A calculated string value for a definition
- class ibek.support.EntityPVI(*, yaml_path: str, index: bool = True, prefix: str, pva_template: bool = False)[source]#
Entity PVI definition
- class ibek.support.Definition(*, name: str, description: str, args: Sequence[FloatArg | StrArg | IntArg | BoolArg | ObjectArg | IdArg | EnumArg] = (), values: Sequence[Value] = (), databases: Sequence[Database] = [], pre_init: Sequence[Text | Comment] = (), post_init: Sequence[Text | Comment] = (), env_vars: Sequence[EnvironmentVariable] = (), pvi: EntityPVI = None)[source]#
A single definition of a class of Entity that an IOC instance may instantiate
- class ibek.support.Support(*, module: str, defs: Sequence[Definition])[source]#
Lists the definitions for a support module, this defines what Entities it supports
Provides the deserialize entry point.
ibek.ioc
#
Functions for generating an IocInstance derived class from a support module definition YAML file
- class ibek.ioc.Entity(*, type: str, entity_enabled: bool = True)[source]#
A baseclass for all generated Entity classes.
- ibek.ioc.make_entity_model(definition: Definition, support: Support) Type[Entity] [source]#
Create an Entity Model from a Definition instance and a Support instance.
- ibek.ioc.make_entity_models(support: Support)[source]#
Create Entity subclasses for all Definition instances in the given Support instance. Returns a list of the Entity subclasses Models.
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 definition 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 definition + 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(ioc: IOC, method: Callable[[Entity], str | None]) str [source]#
Render elements of a given IOC instance based on calling the correct method
- render_pre_ioc_init_elements(ioc: IOC) 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 {{ __utils__.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.Counter(start: int, current: int, stop: int)[source]#
Provides the ability to supply unique numbers to Jinja templates
- 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
- class apischema.types.UndefinedType#
A sentinel value that allows detection that a value has not been passed at init