Util Entrypoint¶
Loader subclasses know how to load classes under their entry point which conform to their subclasses.
- class dffml.util.entrypoint.Entrypoint[source]¶
Uses the pkg_resources.iter_entry_points on the ENTRYPOINT of the class
- classmethod load(loading=None)[source]¶
Loads all installed loading and returns them as a list. Sources to be loaded should be registered to ENTRYPOINT via setuptools.
- dffml.util.entrypoint.base_entry_point(entrypoint, *args)[source]¶
Any class which subclasses from Entrypoint needs this decorator applied to it. The decorator sets the ENTRYPOINT and ENTRY_POINT_NAME properties on the class.
This allows the load() classmethod to be called to load subclasses of the class being decorated. This is how the subclasses get loaded via the entry point system by calling BaseClass.load().
ENTRY_POINT_NAME corresponds to the command line argument and config file reference to the class. It comes from all arguments after the entrypoint argument (first argument) is a list which would turn into an command line argument if it were joined with hyphens.
Examples
>>> from dffml import base_entry_point, Entrypoint >>> >>> @base_entry_point('dffml.entrypoint', 'entrypoint') ... class BaseEntrypointSubclassClass(Entrypoint): pass
entry_points={ # dffml.entrypoint = ENTRYPOINT 'dffml.entrypoint': [ 'mylabel = module.path.to:EntrypointSubclassClass', ] }
- dffml.util.entrypoint.entrypoint(label)[source]¶
If a class if going to be registered with setuptools as an entrypoint it must have the label it will be registered under associated with it via this decorator.
This decorator sets the ENTRY_POINT_ORIG_LABEL and ENTRY_POINT_LABEL class proprieties to the same value, label.
Examples
>>> from dffml import entrypoint, Entrypoint >>> >>> @entrypoint('mylabel') ... class EntrypointSubclassClass(Entrypoint): pass
In setup.py, EntrypointSubclassClass needs to have this decorator applied to it with label set to mylabel.
entry_points={ 'dffml.entrypoint': [ 'mylabel = module.path.to:EntrypointSubclassClass', ] }