pyanimeinfo.utils.enum

load_from_enum

pyanimeinfo.utils.enum.load_from_enum(obj, enum_class: Type[_Enum]) _Enum[source]

Load an enum value from its text representation.

This function allows you to load an enum value from either a matching enum instance, its text representation, or its integer representation.

Parameters:
  • obj (Union[_Enum, str, int]) – The value to load from the enum.

  • enum_class (Type[_Enum]) – The enum class to load the value from.

Returns:

The enum value corresponding to the input.

Return type:

_Enum

Raises:
  • ValueError – If the input value does not match any enum values.

  • TypeError – If the input value is of an unknown type.

load_text_from_enum

pyanimeinfo.utils.enum.load_text_from_enum(obj, enum_class: Type[_Enum]) str[source]

Load the text representation of an enum value.

This function allows you to load the text representation of an enum value from its corresponding enum instance, text representation, or integer representation.

Parameters:
  • obj (Union[_Enum, str, int]) – The value to load from the enum.

  • enum_class (Type[_Enum]) – The enum class to load the text from.

Returns:

The text representation of the enum value.

Return type:

str

Raises:
  • ValueError – If the input value does not match any enum values.

  • TypeError – If the input value is of an unknown type.