runtimepy.enum package#
Submodules#
runtimepy.enum.registry module#
A module implementing and enumeration registry.
- class runtimepy.enum.registry.EnumRegistry(data: dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]] = None, schemas: SchemaMap = None, dest_attr: str = 'data', verify: bool = True)[source]#
Bases:
Registry
[RuntimeEnum
]A runtime enumeration registry.
- enum(name: str, kind: str | EnumType, items: MutableMapping[str | int, str | int] | MutableMapping[str | bool, str | bool] | MutableMapping[str, bool] | MutableMapping[str, int] = None, primitive: str = 'uint8') RuntimeEnum | None [source]#
Create a new runtime enumeration.
- property kind: type[RuntimeEnum]#
Determine what kind of registry this is.
- class runtimepy.enum.registry.RuntimeIntEnum(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
IntEnum
An integer enumeration extension.
- classmethod normalize(data: int | str | T) T [source]#
Normalize a value at runtime that is either integer, string or an enum instance.
- classmethod register_enum(registry: EnumRegistry, name: str = None) RuntimeEnum [source]#
Register an enumeration to a registry.
- classmethod runtime_enum(identifier: int) RuntimeEnum [source]#
Obtain a runtime enumeration from this class.
runtimepy.enum.types module#
A module implementing a type system for runtime enumerations.
Module contents#
A module implementing a runtime enumeration interface.
- class runtimepy.enum.RuntimeEnum(data: dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]] = None, schemas: SchemaMap = None, dest_attr: str = 'data', verify: bool = True)[source]#
Bases:
RegistryItem
A class implementing a runtime enumeration.
- asdict() dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]] [source]#
Obtain a dictionary representing this instance.
- property bools: BooleanRegistry#
Get the underlying boolean enumeration.
- static data_from_enum(enum: type[IntEnum]) dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]] [source]#
Get JSON data from an enumeration class.
- static from_enum(enum: type[IntEnum], identifier: int) RuntimeEnum [source]#
Create a runtime enumeration from an enum class.
- init(data: dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]]) None [source]#
Perform implementation-specific initialization.
- property ints: NameRegistry#
Get the underlying integer enumeration.
- property is_boolean: bool#
Determine if this is a boolean enumeration.
- property is_integer: bool#
Determine if this is an integer enumeration.