cookiecutter_python package

Subpackages

Submodules

cookiecutter_python.cli module

Main cookiecutter_python CLI.

cookiecutter_python.cli.version_msg()[source]

Message about Python Generator version, location and Python version.

cookiecutter_python.cli_handlers module

cookiecutter_python.cli_handlers.handle_error(error)[source]

cookiecutter_python.exceptions module

cookiecutter_python.exceptions.error_2_str(error)[source]

cookiecutter_python.utils module

cookiecutter_python.utils.load(interface: Type[T], module: str | None = None) List[Type[T]][source]

Dynamically import all class objects that implement the given interface.

The classes (class objects) are discovered and imported in the namespace, by searching within each module found inside the input ‘dire’ (path) directory.

Each class object is an attribute found in a module’s namespace. We classify an attribute as a (correct) “class to import”, if the following python boolean expression evaluates to True:

isclass(attribute) and issubclass(attribute, interface)

If ‘dire’ is not given then we consider the modules that are inside the same directory as the one where the module of the invoking code resides.

Parameters:
  • interface (Type[T]) – the type (ie class) that the imported classes should ‘inherit’ (subclass) from

  • module (str) – module containing the modules to inspect. Defaults to the same module (directory) as the one where the module of the invoking code resides.

Module contents