[docs]classExtendedEnum(Enum):"""Base Enum type with compatible string functionalities. Methods ------- names() Returns a list of Enum names as string values() Returns a list of Enum values as string to_dict() Returns a dictionary of all Enum name-value pairs Examples -------- >>> from slickml.utils import ExtendedEnum >>> class FooBar(ExtendedEnum): ... FOO = "foo" ... BAR = "bar" >>> FooBar.FOO >>> FooBar.names() >>> FooBar.values() >>> FooBar.to_dict() """
[docs]@classmethoddefnames(cls)->List[str]:"""Returns a list of Enum names as string. Returns ------- List[str] """return[c.nameforcincls]
[docs]@classmethoddefvalues(cls)->List[str]:"""Returns a list of Enum values as string. Returns ------- List[str] """return[c.valueforcincls]
[docs]@classmethoddefto_dict(cls)->Dict[str,str]:"""Returns a dictionary of all Enum name-value pairs as string. Returns ------- Dict[str, str] """return{name:str(value)for(name,value)incls.__members__.items()}
[docs]def__str__(self)->str:"""Returns the Enum ``str`` value. Returns ------- str """returnself.value
[docs]def__repr__(self)->str:"""Returns the Enum ``str`` representation value. Returns ------- str """returnf"'{self.value}'"