Plugins can now also supply information regarding the plugin author and website, metadata also tracks from where they were loaded
This commit is contained in:
parent
4b60475a02
commit
922ee39109
2 changed files with 19 additions and 0 deletions
|
|
@ -27,6 +27,10 @@ a couple of properties describing the module:
|
|||
Version of your plugin
|
||||
``__plugin_description__``
|
||||
Description of your plugin
|
||||
``__plugin_author__``
|
||||
Author of your plugin
|
||||
``__plugin_url__``
|
||||
URL of the webpage of your plugin, e.g. the Github repository
|
||||
``__plugin_implementations__``
|
||||
Instances of one or more of the various :ref:`plugin mixins <sec-plugins-developing-mixins>`
|
||||
``__plugin_hooks__``
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@ class PluginInfo(object):
|
|||
|
||||
attr_version = '__plugin_version__'
|
||||
|
||||
attr_author = '__plugin_author__'
|
||||
|
||||
attr_url = '__plugin_url__'
|
||||
|
||||
attr_hooks = '__plugin_hooks__'
|
||||
|
||||
attr_implementations = '__plugin_implementations__'
|
||||
|
|
@ -34,6 +38,7 @@ class PluginInfo(object):
|
|||
self.key = key
|
||||
self.location = location
|
||||
self.instance = instance
|
||||
self.origin = None
|
||||
|
||||
self._version = version
|
||||
|
||||
|
|
@ -71,6 +76,14 @@ class PluginInfo(object):
|
|||
def version(self):
|
||||
return self._version if self._version is not None else self._get_instance_attribute(self.__class__.attr_version, default=None)
|
||||
|
||||
@property
|
||||
def author(self):
|
||||
return self._get_instance_attribute(self.__class__.attr_author, default=None)
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
return self._get_instance_attribute(self.__class__.attr_url, default=None)
|
||||
|
||||
@property
|
||||
def hooks(self):
|
||||
return self._get_instance_attribute(self.__class__.attr_hooks, default={})
|
||||
|
|
@ -153,6 +166,7 @@ class PluginManager(object):
|
|||
|
||||
plugin = self._load_plugin_from_module(key, folder=folder)
|
||||
if plugin:
|
||||
plugin.origin = ("folder", folder)
|
||||
plugins[key] = plugin
|
||||
|
||||
return plugins
|
||||
|
|
@ -179,6 +193,7 @@ class PluginManager(object):
|
|||
|
||||
plugin = self._load_plugin_from_module(key, module_name=module_name, version=version)
|
||||
if plugin:
|
||||
plugin.origin = ("entry_point", group)
|
||||
plugins[key] = plugin
|
||||
|
||||
return plugins
|
||||
|
|
|
|||
Loading…
Reference in a new issue