mirror of https://github.com/fmartingr/iosfu.git
Moved base plugin and plugin library to separate modules outside __init__
This commit is contained in:
parent
d5cc94e396
commit
c962e5dc51
|
@ -1,37 +0,0 @@
|
|||
from iosfu.utils import slugify
|
||||
|
||||
|
||||
class Library(object):
|
||||
_instance = None
|
||||
plugins = {} # Plugin dictonary
|
||||
|
||||
def register(self, plugin):
|
||||
"""
|
||||
Decorator to register plugins
|
||||
"""
|
||||
ins = plugin()
|
||||
plugin_slug = ins.__slug__
|
||||
if ins not in self.plugins:
|
||||
self.plugins[plugin_slug] = plugin
|
||||
else:
|
||||
raise RuntimeError(
|
||||
'Plugin {0} already registered.'.format(plugin_slug))
|
||||
|
||||
|
||||
class BasePlugin(object):
|
||||
"""
|
||||
Base plugin object
|
||||
"""
|
||||
category = 'Base'
|
||||
name = 'Base Plugin'
|
||||
description = ''
|
||||
|
||||
@property
|
||||
def __slug__(self):
|
||||
"""
|
||||
Returns slugified name for identification
|
||||
"""
|
||||
return u"{0}.{1}".format(
|
||||
slugify(self.category),
|
||||
slugify(self.name)
|
||||
)
|
|
@ -0,0 +1,22 @@
|
|||
from iosfu.utils import slugify
|
||||
|
||||
|
||||
class BasePlugin(object):
|
||||
"""
|
||||
Base plugin object
|
||||
"""
|
||||
category = 'Base' # Category of the plugin
|
||||
name = 'Base Plugin' # Name of the plugin
|
||||
description = '' # Description
|
||||
|
||||
_backup = None # BackupManager instance
|
||||
|
||||
@property
|
||||
def __slug__(self):
|
||||
"""
|
||||
Returns slugified name for identification
|
||||
"""
|
||||
return u"{0}.{1}".format(
|
||||
slugify(self.category),
|
||||
slugify(self.name)
|
||||
)
|
|
@ -1,4 +1,5 @@
|
|||
from iosfu.plugin import BasePlugin, Library
|
||||
from iosfu.plugin.base import BasePlugin
|
||||
from iosfu.plugin.library import Library
|
||||
|
||||
|
||||
plugin_library = Library()
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
class Library(object):
|
||||
_instance = None
|
||||
plugins = {} # Plugin dictonary
|
||||
|
||||
def register(self, plugin):
|
||||
"""
|
||||
Decorator to register plugins
|
||||
"""
|
||||
ins = plugin()
|
||||
plugin_slug = ins.__slug__
|
||||
if ins not in self.plugins:
|
||||
self.plugins[plugin_slug] = plugin
|
||||
else:
|
||||
raise RuntimeError(
|
||||
'Plugin {0} already registered.'.format(plugin_slug))
|
|
@ -1,4 +1,5 @@
|
|||
from iosfu.plugin import BasePlugin, Library
|
||||
from iosfu.plugin.base import BasePlugin
|
||||
from iosfu.plugin.library import Library
|
||||
|
||||
|
||||
plugin_library = Library()
|
||||
|
|
Loading…
Reference in New Issue