summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Ulrich Niedermann <hun@n-dimensional.de>2008-06-25 14:05:22 +0200
committerHans Ulrich Niedermann <hun@n-dimensional.de>2008-07-15 12:28:53 +0200
commit7c8e2cdacaee25c97266911be609dd3c3299eb95 (patch)
tree0124673e9701a1aaaed6291d8ba70eff0c132395
parent50329926dae11a934a526315d09eb1e7f897a06e (diff)
downloadnbb-7c8e2cdacaee25c97266911be609dd3c3299eb95.tar.gz
nbb-7c8e2cdacaee25c97266911be609dd3c3299eb95.tar.xz
nbb-7c8e2cdacaee25c97266911be609dd3c3299eb95.zip
Iterate over dict.iteritems() instead of .items()
-rw-r--r--src/nbblib/bs.py2
-rw-r--r--src/nbblib/plugins.py8
-rw-r--r--src/nbblib/vcs.py2
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: