medcat.utils.registry
Attributes
Exceptions
Common base class for all non-exit exceptions. |
Classes
Abstract base class for generic types. |
Module Contents
- medcat.utils.registry.logger
- medcat.utils.registry.P
- class medcat.utils.registry.Registry(type, lazy_defaults=None)
Bases:
Generic[P]Abstract base class for generic types.
A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:
class Mapping(Generic[KT, VT]): def __getitem__(self, key: KT) -> VT: ... # Etc.
This class can then be used as follows:
def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
- Parameters:
type (Type[P])
lazy_defaults (Optional[dict[str, tuple[str, str]]])
- __init__(type, lazy_defaults=None)
- Parameters:
type (Type[P])
lazy_defaults (Optional[dict[str, tuple[str, str]]])
- Return type:
None
- _components: dict[str, Callable[Ellipsis, P]]
- _type
- _lazy_defaults
- register(component_name, creator)
- Parameters:
component_name (str)
creator (Callable[Ellipsis, P])
- get_component(component_name)
Get the component that’s registered.
The component generally refers to the class, but may be another method that creates the object needed.
- Parameters:
component_name (str) – The name of the component.
- Raises:
MedCATRegistryException – If no component by requested name is registered.
- Returns:
Callable[…, P] – The creator for the registered component.
- Return type:
Callable[Ellipsis, P]
- _ensure_lazy_default(component_name)
- Parameters:
component_name (str)
- Return type:
None
- register_all_defaults()
Register all default (lazily-added) components.
- Return type:
None
- list_components()
List all available component names and class names.
- Returns:
list[tuple[str, str]] – The list of the names and class names for each registered componetn.
- Return type:
list[tuple[str, str]]
- unregister_component(component_name)
Unregister a component.
- Parameters:
component_name (str) – The component name.
- Raises:
MedCATRegistryException – If no component by the name specified had been registered.
- Returns:
Callable[…, P] – The creator of the component.
- Return type:
Callable[Ellipsis, P]
- unregister_all_components()
Unregister all components.
- Return type:
None
- __contains__(component_name)
- Parameters:
component_name (str)
- Return type:
bool
- __getitem__(component_name)
- Parameters:
component_name (str)
- Return type:
Callable[Ellipsis, P]
- __slots__ = ()
- _is_protocol = False
- classmethod __class_getitem__(params)
- classmethod __init_subclass__(*args, **kwargs)
- exception medcat.utils.registry.MedCATRegistryException(*args)
Bases:
ExceptionCommon base class for all non-exit exceptions.
- Parameters:
args (object)
- __init__(*args)
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
args (object)
- Return type:
None
- class __cause__
exception cause
- class __context__
exception context
- __delattr__()
Implement delattr(self, name).
- __dir__()
Default dir() implementation.
- __eq__()
Return self==value.
- __format__()
Default object formatter.
- __ge__()
Return self>=value.
- __getattribute__()
Return getattr(self, name).
- __gt__()
Return self>value.
- __hash__()
Return hash(self).
- __le__()
Return self<=value.
- __lt__()
Return self<value.
- __ne__()
Return self!=value.
- __new__()
Create and return a new object. See help(type) for accurate signature.
- __reduce__()
- __reduce_ex__()
Helper for pickle.
- __repr__()
Return repr(self).
- __setattr__()
Implement setattr(self, name, value).
- __setstate__()
- __sizeof__()
Size of object in memory, in bytes.
- __str__()
Return str(self).
- __subclasshook__()
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- class __suppress_context__
- class __traceback__
- class args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.