From c04106492dbb239a85042df58198fedad213b3be Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Tue, 8 Jul 2008 21:21:15 -0400 Subject: [PATCH] Only allow one plugin to override a given command --- yap/yap.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/yap/yap.py b/yap/yap.py index 3e25095..756789b 100644 --- a/yap/yap.py +++ b/yap/yap.py @@ -26,6 +26,7 @@ class YapError(Exception): class Yap(object): def __init__(self): self.plugins = set() + self.overrides = [] plugindir = os.path.expanduser("~/.yap/plugins") for p in glob.glob(os.path.join(plugindir, "*.py")): glbls = {} @@ -38,9 +39,16 @@ class Yap(object): if cls is YapPlugin: continue x = cls(self) - # XXX: check for override overlap self.plugins.add(x) + for func in dir(x): + if not func.startswith('cmd_'): + continue + if func in self.overrides: + print >>sys.stderr, "Plugin %s overrides already overridden function %s. Disabling" % (p, func) + self.plugins.remove(x) + break + def _add_new_file(self, file): repo = get_output('git rev-parse --git-dir')[0] dir = os.path.join(repo, 'yap') -- 2.11.4.GIT