spine.constants.factory
Helpers for parsing SPINE enum-like configuration values.
This module is intentionally separate from spine.constants.enums.
The enum module should define canonical enumerated types; this module contains
parsing helpers that translate user/config strings into those enum values.
Functions
|
Parse canonical SPINE enum values from config strings. |
- spine.constants.factory.enum_factory(enum: str, value: str) int[source]
- spine.constants.factory.enum_factory(enum: str, value: list[str] | tuple[str, ...]) list[int]
Parse canonical SPINE enum values from config strings.
This is a small compatibility/helper layer used by config-driven code that still refers to groups like
"shape"or"pid"rather than importing enum classes directly.- Parameters:
enum (str) – Name of the supported enum group to parse. Supported groups are
"cluster","shape","pid", and"interaction_scheme".value (Union[str, Sequence[str]]) – One enum-member name or a sequence of enum-member names. Member names are matched case-insensitively through their uppercase representation.
- Returns:
Integer value of the parsed enum member, or a list of integer values if a sequence of names is provided.
- Return type:
Union[int, List[int]]
- Raises:
ValueError – If the requested enum group is not supported.
ValueError – If one of the provided member names does not exist on the target enum.