patroni.dynamic_loader module

Helper functions to search for implementations of specific abstract interface in a package.

patroni.dynamic_loader.find_class_in_module(module: module, cls_type: Type[ClassType]) → Type[ClassType] | None View on GitHub

Try to find the implementation of cls_type class interface in module matching the module name. +

Parameters:
Returns:

class with a name matching the name of module that implements cls_type or None if not found.

patroni.dynamic_loader.iter_classes(package: str, cls_type: Type[ClassType], config: Config | Dict[ str, Any] | None = None) → Iterator[ Tuple[ str, Type[ClassType]]] View on GitHub

Attempt to import modules and find implementations of cls_type that are present in the given configuration. + Note

If a module successfully imports we can assume that all its requirements are installed.
+
Parameters:;;
Yields:;;
  a tuple containing the module `+name+` and the imported class object.
patroni.dynamic_loader.iter_modules(package: str) → List[ str] View on GitHub

Get names of modules from package, depending on execution environment. + Note

If being packaged with PyInstaller, modules aren’t discoverable dynamically by scanning source directory because  https://docs.python.org/3/library/importlib.html#importlib.machinery.FrozenImporter[`+importlib.machinery.FrozenImporter+`] doesn’t implement link:#patroni.dynamic_loader.iter_modules[`+iter_modules()+`]. But it is still possible to find all potential modules by iterating through `+toc+`, which contains list of all “frozen” resources.
+
Parameters:;;
  *package* – a package name to search modules in, e.g. `+patroni.dcs+`.
Returns:;;
  list of known module names with absolute python module path namespace, e.g. `+patroni.dcs.etcd+`.

© Copyright 2015 Compose, Zalando SE. Revision 9d231aee.

Built with Sphinx using a theme provided by Read the Docs.

Read the Docs v: latest

+ Builds