medcat.utils.import_utils ========================= .. py:module:: medcat.utils.import_utils Attributes ---------- .. autoapisummary:: medcat.utils.import_utils._DEP_PATTERN medcat.utils.import_utils._DEP_NAME_MAPPER Exceptions ---------- .. autoapisummary:: medcat.utils.import_utils.IncorrectExtraComponent medcat.utils.import_utils.MissingDependenciesError Classes ------- .. autoapisummary:: medcat.utils.import_utils.KeyDefaultDict Functions --------- .. autoapisummary:: medcat.utils.import_utils.get_all_extra_deps_raw medcat.utils.import_utils.get_required_extra_deps medcat.utils.import_utils.get_installed_extra_dependencies medcat.utils.import_utils.ensure_optional_extras_installed Module Contents --------------- .. py:data:: _DEP_PATTERN .. py:class:: KeyDefaultDict Bases: :py:obj:`dict` dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) .. py:method:: __missing__(key) .. py:method:: __contains__() True if the dictionary has the specified key, else False. .. py:method:: __delattr__() Implement delattr(self, name). .. py:method:: __delitem__() Delete self[key]. .. py:method:: __dir__() Default dir() implementation. .. py:method:: __eq__() Return self==value. .. py:method:: __format__() Default object formatter. .. py:method:: __ge__() Return self>=value. .. py:method:: __getattribute__() Return getattr(self, name). .. py:method:: __getitem__() x.__getitem__(y) <==> x[y] .. py:method:: __gt__() Return self>value. .. py:method:: __init__() Initialize self. See help(type(self)) for accurate signature. .. py:method:: __ior__() Return self|=value. .. py:method:: __iter__() Implement iter(self). .. py:method:: __le__() Return self<=value. .. py:method:: __len__() Return len(self). .. py:method:: __lt__() Return self size of D in memory, in bytes .. py:method:: __str__() Return str(self). .. py:method:: __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). .. py:method:: clear() D.clear() -> None. Remove all items from D. .. py:method:: copy() D.copy() -> a shallow copy of D .. py:method:: get() Return the value for key if key is in the dictionary, else default. .. py:method:: items() D.items() -> a set-like object providing a view on D's items .. py:method:: keys() D.keys() -> a set-like object providing a view on D's keys .. py:method:: pop() D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If the key is not found, return the default if given; otherwise, raise a KeyError. .. py:method:: popitem() Remove and return a (key, value) pair as a 2-tuple. Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty. .. py:method:: setdefault() Insert key with a value of default if key is not in the dictionary. Return the value for key if key is in the dictionary, else default. .. py:method:: update() D.update([E, ]**F) -> None. Update D from dict/iterable E and F. If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k] .. py:method:: values() D.values() -> an object providing a view on D's values .. py:data:: _DEP_NAME_MAPPER .. py:function:: get_all_extra_deps_raw(package_name) Get all the dependencies for a pcakge that are for an extra component. The output will include extra information such as the extra it's tied to. :param package_name: The package name. :type package_name: str :raises ValueError: If the package isn't installed. :Returns: **list[str]** -- The list of extra dependencies, including extra information. .. py:function:: get_required_extra_deps(package_name, extra_name) Get the extra dependencies required for this extra part. :param package_name: The package name. :type package_name: str :param extra_name: The extra name. :type extra_name: str :Returns: **list[str]** -- All the required extra dependencies for this part. .. py:function:: get_installed_extra_dependencies(package_name, extra_name) Get installed dependencies for a given package's extra parts. :param package_name: The package name. :type package_name: str :Returns: **list[str]** -- The list of extra packages installed. .. py:function:: ensure_optional_extras_installed(package_name, extra_name) Ensure that an optional dependency set is installed. :param package_name: The base package name. :type package_name: str :param extra_name: The name of the extra dependency. :type extra_name: str :raises MissingDependenciesError: If the extra dependency isn't provided. .. py:exception:: IncorrectExtraComponent(package_name, extra_name) Bases: :py:obj:`Exception` Common base class for all non-exit exceptions. .. py:method:: __init__(package_name, extra_name) Initialize self. See help(type(self)) for accurate signature. .. py:attribute:: package_name .. py:attribute:: extra_name .. py:class:: __cause__ exception cause .. py:class:: __context__ exception context .. py:method:: __delattr__() Implement delattr(self, name). .. py:method:: __dir__() Default dir() implementation. .. py:method:: __eq__() Return self==value. .. py:method:: __format__() Default object formatter. .. py:method:: __ge__() Return self>=value. .. py:method:: __getattribute__() Return getattr(self, name). .. py:method:: __gt__() Return self>value. .. py:method:: __hash__() Return hash(self). .. py:method:: __le__() Return self<=value. .. py:method:: __lt__() Return self=value. .. py:method:: __getattribute__() Return getattr(self, name). .. py:method:: __gt__() Return self>value. .. py:method:: __hash__() Return hash(self). .. py:method:: __le__() Return self<=value. .. py:method:: __lt__() Return self