weaver.base

Definitions of base classes employed across multiple modules to avoid circular import errors.

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: weaver.typedefs.AnyKey | EnumType | PropertyDataTypeT, default: Any | None = None) PropertyDataTypeT[source]
classmethod docs() Dict[str, str | None][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: Callable[[object], PropertyDataTypeT] | None = None, fset: Callable[[object, PropertyDataTypeT], None] | None = None, fdel: Callable[[object], None] | 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.

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: weaver.typedefs.AnyKey | EnumType, default: Any | None = None) EnumType | None[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.

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.

weaver.base.EnumType[source]