-#!/usr/bin/python3 -tt
-#
-# Copyright (c) 2011 Intel, Inc.
-#
-# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; version 2 of the License
#
from mic import msger
from mic.utils import errors
-class _Plugin(object):
- class __metaclass__(type):
- def __init__(cls, name, bases, attrs):
- if not hasattr(cls, 'plugins'):
- cls.plugins = {}
+class pluginMetaClass(type):
+ def __new__(cls, name, bases, attrs):
+
+ return type.__new__(cls,name, bases, attrs)
+
+ def __init__(cls, name, bases, attrs):
+ if not hasattr(cls, 'plugins'):
+ cls.plugins = {}
+ elif 'mic_plugin_type' in attrs:
+ if attrs['mic_plugin_type'] not in cls.plugins:
+ cls.plugins[attrs['mic_plugin_type']] = {}
+
+ elif hasattr(cls, 'mic_plugin_type') and 'name' in attrs:
+ cls.plugins[cls.mic_plugin_type][attrs['name']] = cls
- elif 'mic_plugin_type' in attrs:
- if attrs['mic_plugin_type'] not in cls.plugins:
- cls.plugins[attrs['mic_plugin_type']] = {}
+ def show_plugins(cls):
+ for cls in cls.plugins[cls.mic_plugin_type]:
+ print (cls)
- elif hasattr(cls, 'mic_plugin_type') and 'name' in attrs:
- cls.plugins[cls.mic_plugin_type][attrs['name']] = cls
+ def get_plugins(cls):
+ return cls.plugins
- def show_plugins(cls):
- for cls in cls.plugins[cls.mic_plugin_type]:
- print (cls)
- def get_plugins(cls):
- return cls.plugins
+class _Plugin(object, metaclass=pluginMetaClass):
+ pass
class ImagerPlugin(_Plugin):
mic_plugin_type = "imager"