weaver.base

Module Contents

weaver.base.PropertyDataTypeT[source]
class weaver.base._Const[source]
abstract get(key)[source]
class weaver.base.Constants[source]

Constants container that provides similar functionalities to ExtendedEnum without explicit Enum membership.

classmethod get(key_or_value: Union[weaver.typedefs.AnyKey, EnumType, PropertyDataTypeT], default: Optional[Any] = None) PropertyDataTypeT[source]
classmethod docs() Dict[str, Optional[str]][source]

Retrieves the documentation string applied on the attribute.

Employ classproperty to define the attributes.

classmethod names() List[str][source]

Returns the member names assigned to corresponding enum elements.

classmethod values() List[weaver.typedefs.AnyKey][source]

Returns the literal values assigned to corresponding enum elements.

class weaver.base.classproperty(fget: Ellipsis = None, fset: Optional[Callable[[object, PropertyDataTypeT], None]] = None, fdel: Optional[Callable[[object], None]] = None, doc: str = '')[source]

Mimics property decorator, but applied onto classmethod in backward compatible way.

Note

This decorator purposely only supports getter attribute to define unmodifiable class properties.

Initialize self. See help(type(self)) for accurate signature.

class weaver.base._EnumMeta[source]

Metaclass for Enum

abstract get(key)[source]
class weaver.base.ExtendedEnum[source]

Utility enum.Enum methods.

Create an extended enum with these utilities as follows.

class CustomEnum(ExtendedEnum):
    ItemA = "A"
    ItemB = "B"

Warning

Must not define any enum value here to allow inheritance by subclasses.

property title: str[source]

Returns the title representation of the enum element.

Title use the original enum element name with capitalization considering underscores for separate words.

classmethod names() List[str][source]

Returns the member names assigned to corresponding enum elements.

classmethod values() List[weaver.typedefs.AnyKey][source]

Returns the literal values assigned to corresponding enum elements.

classmethod get(key_or_value: Union[weaver.typedefs.AnyKey, EnumType], default: Optional[Any] = None) Optional[EnumType][source]

Finds an enum entry by defined name or its value.

Returns the entry directly if it is already a valid enum.

classmethod titles() List[str][source]

Returns the title representation of all enum elements.

weaver.base.EnumType[source]