enb.plugins package

Subpackages

Submodules

enb.plugins.installable module

Installable interface used for plugins and templates.

class enb.plugins.installable.Installable

Bases: object

Common interface to all Installable types, e.g., Plugins and Templates.

authors = ['Miguel Hernández-Cabronero']
classmethod build(installation_dir)

Method called after the main installation body, that allows further building customization by Installable subclasses. By default, nothing is done.

Note that the installation dir is created before calling build.

contrib_authors = []
contrib_download_url_name = []
contrib_reference_urls = []
extra_requirements_message = None
classmethod get_help()

Return help about this Installable. By default, the docstring of the selected class is returned.

classmethod install(installation_dir, overwrite_destination=False)

Install this Installable into installation_dir. By default, copy all contents of the Installable source dir and install the declared pip requirements.

Parameters:
  • installation_dir – path where the installable is to be copied and, when necessary, built.

  • overwrite_destination – if True, if the destination exists prior to this call, it is removed before installation.

label = None
name = None
classmethod print_info()

Print information about this installable.

classmethod report_successful_installation(installation_dir)
classmethod repr()

Get a terse representation of this Installable.

required_pip_modules = []
tags = {}
tested_on = {}
classmethod warn_extra_requirements()
class enb.plugins.installable.InstallableMeta(*args, **kwargs)

Bases: type

Installable classes are not meant to be instantiated, just to be defined to declare the presence of Installables. This metaclass is used to perform basic checks on the declared Installable subclasses.

__init__(*args, **kwargs)
installable_file_name = '__plugin__.py'
name_to_installable = {}
tag_to_installable = {}
valid_tested_on_strings = {'linux', 'macos', 'windows'}
enb.plugins.installable.get_installable_by_name(name)

Search among all defined installables for one with exactly the name provided. :param name: name of the installable :raises KeyError: if name cannot be found

enb.plugins.installable.import_all_installables()

Import all public enb Installables.

These are recognized by containing a __plugin__.py file in them and an installable definition.

enb.plugins.installable.install(name, target_dir=None, overwrite=False, automatic_import=True)

Install an Installable by name into target_dir.

Parameters:
  • name – name of the installable (e.g., plugin) to be installed. Run enb plugin list in the CLI to get a list of all available installables.

  • target_dir – If target_dir is None, it is set to plugins/<plugin_name> by default.

  • overwrite – If overwrite is False and target_dir already exists, no action is taken.

  • automatic_import – If True, the installable is imported as a module.

enb.plugins.installable.list_all_installables(base_class=<class 'enb.plugins.installable.Installable'>, ignored_classes=[])

Get a list of all known enb installables, sorted by name.

Parameters:
  • base_class – base class used for search, e.g. Installable to search for all defined installables.

  • ignored_classes – classes to be excluded from the returned list. In addition to these, any installable with name set to None is also excluded

enb.plugins.plugin module

Tools define plugin installables.

class enb.plugins.plugin.Plugin

Bases: Installable

Plugins are self-contained, python modules that may assume enb is installed.

  • They can be installed into your projects via the enb CLI (e.g., with enb plugin install <name> <clone_dir>), and then imported like any other module.

  • The list of plugins available off-the-box can be obtained using the enb CLI (e.g., with enb plugin list).

  • Plugins may declare pip dependencies, which are attempted to be satisfied automatically when the plugins are installed. In addition, plugins may define their extra_requirements_message member to be not None, in which case it describes manual intervention required from the user either as a pre-installation or post-installation step. That message is shown when attempting to install the plugin with not-None extra_requirements_message.

  • The __init__.py file is preserved if present. If not present, one is created automatically, which imports all symbols from all .py modules in the plugin.

authors = ['Miguel Hernández-Cabronero']
classmethod build(installation_dir)

Perform any additional retrieval, compilation and setup necessary for this plugin to be importable and usable. By default:

  • The existence of installation_dir as a directory is performed.

  • Install any required apt modules

  • Any needed python modules are installed via pip

  • Cleanup any generic files that might not be needed at this point

  • The __init__.py file is preserved or generated automatically

classmethod install(installation_dir, overwrite_destination=False)

Make a copy of this plugin into installation_dir, ready to be imported. By default, a verbatim copy of the source plugin’s dir is made. Any previous contents in installation_dir are overwritten. Then any explicit requirements are met (external software may be downloaded and pip packages installed).

Parameters:
  • installation_dir – destination dir where the plugin is to be copied to and, when necessary, built.

  • overwrite_destination – if True, the destination path is deleted before installation. If False and installation_dir already exists, an error is raised (plugins are intended to be self-contained, isolated python modules).

label = None
name = None
tags = {}
class enb.plugins.plugin.PluginJava

Bases: Plugin

authors = ['Miguel Hernández-Cabronero']
classmethod build(installation_dir)

Perform any additional retrieval, compilation and setup necessary for this plugin to be importable and usable. By default:

  • The existence of installation_dir as a directory is performed.

  • Install any required apt modules

  • Any needed python modules are installed via pip

  • Cleanup any generic files that might not be needed at this point

  • The __init__.py file is preserved or generated automatically

label = None
name = None
tags = {}
class enb.plugins.plugin.PluginMake

Bases: Plugin

Plugin that assumes the existence of a valid Makefile in the installation folder, and uses it for building the plugin.

authors = ['Miguel Hernández-Cabronero']
classmethod build(installation_dir)

Perform any additional retrieval, compilation and setup necessary for this plugin to be importable and usable. By default:

  • The existence of installation_dir as a directory is performed.

  • Install any required apt modules

  • Any needed python modules are installed via pip

  • Cleanup any generic files that might not be needed at this point

  • The __init__.py file is preserved or generated automatically

label = None
name = None
tags = {}

enb.plugins.template module

Tools to define Templates.

Templates are very similar to plugins, but use jinja to transform .enbt template files upon installation.

class enb.plugins.template.MetaTemplate(*args, **kwargs)

Bases: InstallableMeta

__init__(*args, **kwargs)
class enb.plugins.template.Template

Bases: Installable

Base class to define templates. Subclasses must be defined in the __plugin__.py file of the template’s source dir.

  • Templates copy the source dir’s contents (except for __plugin__.py) and then transforms any *.enbt file applying jinja and removing that extension.

  • Templates may require so-called fields in order to produce output. These fields can be automatically taken from enb.config.ini (e.g., file-based configuration), passed as arguments to the template installation CLI, and programmatically.

  • One or more templates can be installed into an existing directory, the __plugin__.py file is not written by default to the installation dir.

authors = ['Miguel Hernández-Cabronero']
classmethod get_field_parser()
classmethod get_fields(original_fields=None)
classmethod install(installation_dir, overwrite_destination=False, fields=None)

Install a template into the given dir. See super().install for more information.

Parameters:
  • installation_dir – directory where the contents of the template are placed. It will be created if not existing.

  • overwrite_destination – if False, a SyntaxError is raised if any of the destination contents existed prior to this call. Note that installation_dir can already exist, it is the files and directories moved into it that can trigger this SyntaxError.

  • fields – if not None, it must be a dict-like object containing a field to field value mapping. If None, it is interpreted as an empty dictionary. Required template fields not present in fields will be then read from the CLI arguments. If those are not provided, then the default values read from *.ini configuration files. If any required field cannot not satisfied after this, a SyntaxError is raised.

label = None
name = None
required_fields_to_help = {}
tags = {}
templatable_extension = '.enbt'

Module contents

The core functionality of enb is extended by means of plugins and templates. These derive from Installable, a class that by default copies the Installable’s source contents and runs the subclass’ build() method. Python libraries available via pip can be defined for Installables, which are attempted to be satisfied before invoking the build method.

Plugins are conceived self-contained, python modules that can assume the enb library is installed.

Templates are very similar to plugins, but use jinja to transform .enbt template files upon installation.

Please refer to each submodule for further information.