pynyaasi.utils.enum¶
load_text_from_enum¶
-
pynyaasi.utils.enum.load_text_from_enum(text, enum_class: Type[enum.Enum])[source]¶ Load text from an Enum member or a text value.
- Parameters:
text (Union[str, Enum]) – The text or Enum member
enum_class (Type[Enum]) – The Enum class to search in
- Returns:
The text value corresponding to the input
- Return type:
Any
- Raises:
TypeError – If the input value is not a string or Enum member
load_from_enum¶
-
pynyaasi.utils.enum.load_from_enum(text, enum_class: Type[enum.Enum])[source]¶ Load an Enum member from a given text.
- Parameters:
text (str) – The text to match with Enum values
enum_class (Type[Enum]) – The Enum class to search in
- Returns:
The Enum member corresponding to the text
- Return type:
Enum
- Raises:
ValueError – If the text does not match any Enum values
TypeError – If the input value is not a string