"""Utilities for enumerations."""fromenumimportEnum
[docs]classValueEnum(Enum):"""Enum that serializes to string as the value and can be compared against a str."""def__str__(self):"""Get a string representation of the enum."""returnstr(self.value)def__eq__(self,other):"""Compare to another enum for equality."""iftype(self)istype(other)andself.value==other.value:returnTruereturnstr(self.value)==str(other)def__hash__(self):"""Get a hash of the enum."""returnhash(str(self))
[docs]defas_dict(self):"""Create a serializable representation of the enum."""returnstr(self.value)