From c639f3c0e2bf3a7a78c8b030158a51ccb8a77f62 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 27 Jun 2008 00:26:01 +0200 Subject: Remove old plugin code --- src/Makefile-files | 1 - src/nbblib/__init__.py | 1 - src/nbblib/plugins.py | 70 -------------------------------------------------- 3 files changed, 72 deletions(-) delete mode 100644 src/nbblib/plugins.py (limited to 'src') diff --git a/src/Makefile-files b/src/Makefile-files index 0a93287..bd6ea23 100644 --- a/src/Makefile-files +++ b/src/Makefile-files @@ -9,7 +9,6 @@ nbblib_PYTHON += src/nbblib/__init__.py nbblib_PYTHON += src/nbblib/bs.py nbblib_PYTHON += src/nbblib/commands.py nbblib_PYTHON += src/nbblib/main.py -nbblib_PYTHON += src/nbblib/plugins.py nbblib_PYTHON += src/nbblib/newplugins.py nbblib_PYTHON += src/nbblib/progutils.py nbblib_PYTHON += src/nbblib/vcs.py diff --git a/src/nbblib/__init__.py b/src/nbblib/__init__.py index 0004cfc..0c1a2c2 100644 --- a/src/nbblib/__init__.py +++ b/src/nbblib/__init__.py @@ -2,7 +2,6 @@ import nbblib.bs as bs import nbblib.commands as commands import nbblib.newplugins as newplugins import nbblib.package as package -import nbblib.plugins as plugins import nbblib.vcs as plugins from package import PACKAGE_VERSION diff --git a/src/nbblib/plugins.py b/src/nbblib/plugins.py deleted file mode 100644 index 132a03e..0000000 --- a/src/nbblib/plugins.py +++ /dev/null @@ -1,70 +0,0 @@ -import sys - - -class DuplicatePluginName(Exception): - pass - - -class PluginDict(object): - """Helper for GenericPluginMeta class - - Behaves basically like a standard dict, but will raise an exception - when asked to update an existing value. - """ - def __init__(self): - self.dict = {} - - # This is the important difference between PluginDict and dict. - def __setitem__(self, key, value): - if self.dict.has_key(key): - raise DuplicatePluginName() - else: - self.dict[key] = value - - # Forward all other dict methods. - def __getitem__(self, *args): return self.dict.__getitem__(*args) - def items(self): return self.dict.items() - def iteritems(self): return self.dict.iteritems() - def keys(self): return self.dict.keys() - def values(self): return self.dict.values() - def __iter__(self): return self.dict.__iter__() - def __str__(self): return self.dict.__str__() - def __repr__(self): return self.dict.__repr__() - def __len__(self): return self.dict.__len__() - def has_key(self, key): return self.dict.has_key(key) - - -######################################################################## -# Generic plugin system -######################################################################## -# Plugin architecture (metaclass tricks) by Marty Alchin from -# http://gulopine.gamemusic.org/2008/jan/10/simple-plugin-framework/ -# Slightly modified go store plugins as dict. -######################################################################## - - -class NoPluginsRegistered(Exception): - def __init__(self, cls): - super(NoPluginsRegistered, self).__init__() - self.cls = cls - def __str__(self): - return "No %s plugins registered" % (self.cls.__name__) - - -class GenericPluginMeta(type): - def __init__(cls, name, bases, attrs): - if not hasattr(cls, 'plugins'): - # This branch only executes when processing the mount point itself. - # So, since this is a new plugin type, not an implementation, this - # class shouldn't be registered as a plugin. Instead, it sets up a - # list where plugins can be registered later. - cls.plugins = PluginDict() - elif hasattr(cls, 'name'): - # This must be a plugin implementation, which should be registered. - # Simply appending it to the list is all that's needed to keep - # track of it later. - cls.plugins[cls.name] = cls - else: - # This must be an abstract subclass of plugins. - pass - -- cgit