diff roundup/backends/indexer_common.py @ 4357:13b3155869e0

Beginnings of a big code cleanup / modernisation to make 2to3 happy
author Richard Jones <richard@users.sourceforge.net>
date Mon, 22 Feb 2010 05:26:57 +0000
parents 864746c0cf8d
children b9abbdd15259
line wrap: on
line diff
--- a/roundup/backends/indexer_common.py	Fri Feb 19 05:09:38 2010 +0000
+++ b/roundup/backends/indexer_common.py	Mon Feb 22 05:26:57 2010 +0000
@@ -43,7 +43,7 @@
             return {}
 
         designator_propname = {}
-        for nm, propclass in klass.getprops().items():
+        for nm, propclass in klass.getprops().iteritems():
             if _isLink(propclass):
                 designator_propname.setdefault(propclass.classname,
                     []).append(nm)
@@ -52,7 +52,7 @@
         # and files
         nodeids = {}      # this is the answer
         propspec = {}     # used to do the klass.find
-        for l in designator_propname.values():
+        for l in designator_propname.itervalues():
             for propname in l:
                 propspec[propname] = {}  # used as a set (value doesn't matter)
 
@@ -61,7 +61,7 @@
             # skip this result if we don't care about this class/property
             classname = entry[0]
             property = entry[2]
-            if ignore.has_key((classname, property)):
+            if (classname, property) in ignore:
                 continue
 
             # if it's a property on klass, it's easy
@@ -69,12 +69,12 @@
             # backends as that can cause problems down the track)
             nodeid = str(entry[1])
             if classname == klass.classname:
-                if not nodeids.has_key(nodeid):
+                if nodeid not in nodeids:
                     nodeids[nodeid] = {}
                 continue
 
             # make sure the class is a linked one, otherwise ignore
-            if not designator_propname.has_key(classname):
+            if classname not in designator_propname:
                 continue
 
             # it's a linked class - set up to do the klass.find
@@ -82,7 +82,7 @@
                 propspec[linkprop][nodeid] = 1
 
         # retain only the meaningful entries
-        for propname, idset in propspec.items():
+        for propname, idset in propspec.iteritems():
             if not idset:
                 del propspec[propname]
 
@@ -95,16 +95,16 @@
             nodeids[resid] = {}
             node_dict = nodeids[resid]
             # now figure out where it came from
-            for linkprop in propspec.keys():
+            for linkprop in propspec:
                 v = klass.get(resid, linkprop)
                 # the link might be a Link so deal with a single result or None
                 if isinstance(propdefs[linkprop], hyperdb.Link):
                     if v is None: continue
                     v = [v]
                 for nodeid in v:
-                    if propspec[linkprop].has_key(nodeid):
+                    if nodeid in propspec[linkprop]:
                         # OK, this node[propname] has a winner
-                        if not node_dict.has_key(linkprop):
+                        if linkprop not in node_dict:
                             node_dict[linkprop] = [nodeid]
                         else:
                             node_dict[linkprop].append(nodeid)

Roundup Issue Tracker: http://roundup-tracker.org/