diff options
author | Hans Ulrich Niedermann <hun@n-dimensional.de> | 2008-06-25 16:42:38 +0200 |
---|---|---|
committer | Hans Ulrich Niedermann <hun@n-dimensional.de> | 2008-07-15 12:28:53 +0200 |
commit | 4f6b2987ed33db74824b4cb2f91032f03ec7d26a (patch) | |
tree | 41c87406781524525095ffa6642d6fc1253e8af5 | |
parent | ae52fdbda31a37b161189bcb8272a22ca8de33d3 (diff) | |
download | nbb-4f6b2987ed33db74824b4cb2f91032f03ec7d26a.tar.gz nbb-4f6b2987ed33db74824b4cb2f91032f03ec7d26a.tar.xz nbb-4f6b2987ed33db74824b4cb2f91032f03ec7d26a.zip |
Converging plugin detect() methods
-rw-r--r-- | src/nbblib/bs.py | 8 | ||||
-rw-r--r-- | src/nbblib/vcs.py | 10 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/nbblib/bs.py b/src/nbblib/bs.py index b325355..aff1834 100644 --- a/src/nbblib/bs.py +++ b/src/nbblib/bs.py @@ -42,19 +42,21 @@ class BSSourceTree(object): @classmethod def detect(cls, vcs_tree, context): """Find BS tree type and return it""" - if len(BSSourceTree.plugins) < 1: + if len(cls.plugins) < 1: raise NoPluginsRegistered(cls) + # print "CLASS", cls matches = PluginDict() - for key, klass in BSSourceTree.plugins.iteritems(): + for key, klass in cls.plugins.iteritems(): try: t = klass(vcs_tree, context) if t.tree_root() == vcs_tree.tree_root(): + # print "KLASS", klass matches[key] = t except NotABSSourceTree, e: pass if len(matches) > 1: raise ("More than one source tree BS type detected for '%s': %s" - % (vcs_tree, ", ".join(map(lambda x:str(x), matches)))) + % (vcs_tree, ", ".join([str(x) for x in matches]))) elif len(matches) < 1: raise NotABSSourceTree(vcs_tree) return matches[matches.keys()[0]] diff --git a/src/nbblib/vcs.py b/src/nbblib/vcs.py index a5df8c9..38d04b5 100644 --- a/src/nbblib/vcs.py +++ b/src/nbblib/vcs.py @@ -45,8 +45,8 @@ class AmbigousVCSource(Exception): fmt = " %-9s %-15s %s" def strmatch(m): return fmt % (m.name, m.branch_name(), m.tree_root()) - alist = ([fmt % ('VCS Type', 'Branch Name', 'Source tree root')] - + map(strmatch, self.matches)) + alist = ([fmt % ('VCS Type', 'Branch Name', 'Source tree root')] + + [fmt % (m.name, m.branch_name(), m.tree_root()) for m in self.matches]) return ("More than one source tree VCS type detected for '%s':\n#%s" % (self.srcdir, '\n '.join(alist))) @@ -72,13 +72,15 @@ class VCSourceTree(object): @classmethod def detect(cls, srcdir, context): """Detect VCS tree type and return object representing it""" - if len(VCSourceTree.plugins) < 1: + if len(cls.plugins) < 1: raise NoPluginsRegistered(cls) + # print "CLASS", cls matches = PluginDict() - for key, klass in VCSourceTree.plugins.iteritems(): + for key, klass in cls.plugins.iteritems(): try: t = klass(srcdir, context) if t.tree_root() == srcdir: + # print "KLASS", klass matches[key] = t except NotAVCSourceTree, e: pass |