diff options
-rw-r--r-- | src/nbblib/bs.py | 2 | ||||
-rw-r--r-- | src/nbblib/plugins.py | 8 | ||||
-rw-r--r-- | src/nbblib/vcs.py | 2 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/nbblib/bs.py b/src/nbblib/bs.py index e78cd19..b325355 100644 --- a/src/nbblib/bs.py +++ b/src/nbblib/bs.py @@ -45,7 +45,7 @@ class BSSourceTree(object): if len(BSSourceTree.plugins) < 1: raise NoPluginsRegistered(cls) matches = PluginDict() - for key, klass in BSSourceTree.plugins.items(): + for key, klass in BSSourceTree.plugins.iteritems(): try: t = klass(vcs_tree, context) if t.tree_root() == vcs_tree.tree_root(): diff --git a/src/nbblib/plugins.py b/src/nbblib/plugins.py index 1b7a653..132a03e 100644 --- a/src/nbblib/plugins.py +++ b/src/nbblib/plugins.py @@ -13,14 +13,18 @@ class PluginDict(object): """ def __init__(self): self.dict = {} - def __getitem__(self, *args): - return self.dict.__getitem__(*args) + + # 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__() diff --git a/src/nbblib/vcs.py b/src/nbblib/vcs.py index a3e4867..a5df8c9 100644 --- a/src/nbblib/vcs.py +++ b/src/nbblib/vcs.py @@ -75,7 +75,7 @@ class VCSourceTree(object): if len(VCSourceTree.plugins) < 1: raise NoPluginsRegistered(cls) matches = PluginDict() - for key, klass in VCSourceTree.plugins.items(): + for key, klass in VCSourceTree.plugins.iteritems(): try: t = klass(srcdir, context) if t.tree_root() == srcdir: |