mangadap.util.pkg module

General package utilities.

mangadap.util.pkg.all_subclasses(cls)[source]

Collect all the subclasses of the provided class.

The search follows the inheritance to the highest-level class. Intermediate base classes are included in the returned set, but not the base class itself.

Thanks to: https://stackoverflow.com/questions/3862310/how-to-find-all-the-subclasses-of-a-class-given-its-name

Parameters:

cls (object) – The base class

Returns:

The unique set of derived classes, including any intermediate base classes in the inheritance thread.

Return type:

set

mangadap.util.pkg.load_object(module, obj=None)[source]

Load an abstracted module and object.

Thanks to: https://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path?rq=1

Parameters:
  • module (str) – The name of a global python module, the root name of a local file with the object to import, or the full module + object type. If obj is None, this must be the latter.

  • obj (str, optional) – The name of the object to import. If None, module must be the full module + object type name.

Returns:

The imported object.

Return type:

type

Raises:

ImportError – Raised if unable to import module.