3 # Copyright (c) 2011 Intel, Inc.
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the Free
7 # Software Foundation; version 2 of the License
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 # You should have received a copy of the GNU General Public License along
15 # with this program; if not, write to the Free Software Foundation, Inc., 59
16 # Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 class _Plugin(object):
21 class __metaclass__(type):
22 def __init__(cls, name, bases, attrs):
23 if not hasattr(cls, 'plugins'):
26 elif 'mic_plugin_type' in attrs:
27 if attrs['mic_plugin_type'] not in cls.plugins:
28 cls.plugins[attrs['mic_plugin_type']] = {}
30 elif hasattr(cls, 'mic_plugin_type') and 'name' in attrs:
31 cls.plugins[cls.mic_plugin_type][attrs['name']] = cls
33 def show_plugins(cls):
34 for cls in cls.plugins[cls.mic_plugin_type]:
40 class ImagerPlugin(_Plugin):
41 mic_plugin_type = "imager"
55 class BackendPlugin(_Plugin):
56 mic_plugin_type="backend"
58 # suppress the verbose rpm warnings
59 if msger.get_loglevel() != 'debug':
61 rpm.setVerbosity(rpm.RPMLOG_ERR)
63 def addRepository(self):
66 def get_plugins(typen):
67 ps = ImagerPlugin.get_plugins()
73 __all__ = ['ImagerPlugin', 'BackendPlugin', 'get_plugins']