weaver.base =========== .. py:module:: weaver.base .. autoapi-nested-parse:: Definitions of base classes employed across multiple modules to avoid circular import errors. Module Contents --------------- .. py:data:: PropertyDataTypeT .. py:class:: _Const .. py:method:: get(key) :abstractmethod: .. py:class:: Constants Constants container that provides similar functionalities to :class:`ExtendedEnum` without explicit Enum membership. .. py:method:: get(key_or_value: Union[weaver.typedefs.AnyKey, EnumType, PropertyDataTypeT], default: Optional[Any] = None) -> PropertyDataTypeT :classmethod: .. py:method:: docs() -> Dict[str, Optional[str]] :classmethod: Retrieves the documentation string applied on the attribute. Employ :class:`classproperty` to define the attributes. .. py:method:: names() -> List[str] :classmethod: Returns the member names assigned to corresponding enum elements. .. py:method:: values() -> List[weaver.typedefs.AnyKey] :classmethod: Returns the literal values assigned to corresponding enum elements. .. py:class:: classproperty(fget: Optional[Callable[[object], PropertyDataTypeT]] = None, fset: Optional[Callable[[object, PropertyDataTypeT], None]] = None, fdel: Optional[Callable[[object], None]] = None, doc: str = '') Mimics :class:`property` decorator, but applied onto ``classmethod`` in backward compatible way. .. note:: This decorator purposely only supports getter attribute to define unmodifiable class properties. .. seealso:: https://stackoverflow.com/a/5191224 Initialize self. See help(type(self)) for accurate signature. .. py:class:: _EnumMeta Metaclass for Enum .. py:method:: get(key) :abstractmethod: .. py:class:: ExtendedEnum Utility :class:`enum.Enum` methods. Create an extended enum with these utilities as follows. .. code-block:: python class CustomEnum(ExtendedEnum): ItemA = "A" ItemB = "B" .. warning:: Must not define any enum value here to allow inheritance by subclasses. .. py:method:: names() -> List[str] :classmethod: Returns the member names assigned to corresponding enum elements. .. py:method:: values() -> List[weaver.typedefs.AnyKey] :classmethod: Returns the literal values assigned to corresponding enum elements. .. py:method:: get(key_or_value: Union[weaver.typedefs.AnyKey, EnumType], default: Optional[Any] = None) -> Optional[EnumType] :classmethod: Finds an enum entry by defined name or its value. Returns the entry directly if it is already a valid enum. .. py:method:: titles() -> List[str] :classmethod: Returns the title representation of all enum elements. .. py:property:: title :type: str Returns the title representation of the enum element. Title use the original enum element name with capitalization considering underscores for separate words. .. py:data:: EnumType