[Erp5-report] r16900 - /erp5/trunk/products/HBTreeFolder2/HBTreeFolder2.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Oct 9 11:17:34 CEST 2007


Author: vincent
Date: Tue Oct  9 11:17:34 2007
New Revision: 16900

URL: http://svn.erp5.org?rev=16900&view=rev
Log:
Avoid overcomplexification.
Use python-ish code.
Factorise calls to isinstance.
Split comment to match code with better granularity.

Modified:
    erp5/trunk/products/HBTreeFolder2/HBTreeFolder2.py

Modified: erp5/trunk/products/HBTreeFolder2/HBTreeFolder2.py
URL: http://svn.erp5.org/erp5/trunk/products/HBTreeFolder2/HBTreeFolder2.py?rev=16900&r1=16899&r2=16900&view=diff
==============================================================================
--- erp5/trunk/products/HBTreeFolder2/HBTreeFolder2.py (original)
+++ erp5/trunk/products/HBTreeFolder2/HBTreeFolder2.py Tue Oct  9 11:17:34 2007
@@ -242,17 +242,18 @@
         """
         htree = self._htree
         id_list = self.hashId(id)
-        for idx in xrange(len(id_list[0:-1])):
+        for idx in xrange(len(id_list) - 1):
           sub_id = id_list[idx]
-          if not htree.has_key(sub_id):
-            # Create a new index and index it
+          if sub_id not in htree:
+            # Create a new level
             htree[sub_id] = OOBTree()
-            if isinstance(sub_id, int) or isinstance(sub_id, long):
+            if isinstance(sub_id, (int, long)):
               tree_id = 0
               for id in id_list[:idx+1]:
                   tree_id = tree_id + id * MAX_OBJECT_PER_LEVEL
             else:
               tree_id = H_SEPARATOR.join(id_list[:idx+1])
+            # Index newly created level
             self._tree_list[tree_id] = None
             
           htree = htree[sub_id]




More information about the Erp5-report mailing list