def __new__(cls, name, bases, attrs): super_new = super(IonPluginMeta, cls).__new__ parents = [b for b in bases if isinstance(b, IonPluginMeta)] if not parents: # If this isn't a subclass of Modules/Plugins, don't do anything special. return super_new(cls, name, bases, attrs) # Nothing special for these abstract base classes if name == 'IonPlugin' or name == 'IonLaunchPlugin': return super_new(cls, name, bases, attrs) # Create the class. module = attrs.pop('__module__', None) new_class = super_new(cls, name, bases, {'__module__': module}) # Bail out early if we have already created this class. add_to_store = attrs.get('add_to_store', True) m = cache.get_module(name, seed_cache=False, only_installed=False) if add_to_store else None if m is not None: return m # Enhance the class attrs attr = attrs.pop('', None) # These are class level attributes. (so we can inspect without instantiating) attrs.setdefault('name', name) # Add all attributes to the class. for obj_name, obj in attrs.items(): setattr(new_class, obj_name, obj) # module_label = sys.modules[new_class.__module__].__name__ new_class._prepare() cache.register_plugin(name, new_class) # return cache.get_instance(name) return new_class