[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/PathIndex - PathIndex.py:1.25

Martijn Pieters mj@zope.com
Wed, 14 Aug 2002 18:20:02 -0400


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/PathIndex
In directory cvs.zope.org:/tmp/cvs-serv24540/PathIndex

Modified Files:
	PathIndex.py 
Log Message:
Clean up indentation and trailing whitespace.


=== Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 1.24 => 1.25 ===
--- Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py:1.24	Thu Jun 20 16:07:20 2002
+++ Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py	Wed Aug 14 18:19:31 2002
@@ -1,19 +1,19 @@
 ##############################################################################
 #
 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE
-# 
+#
 ##############################################################################
 
 __version__ = '$Id$'
 
-from Products.PluginIndexes import PluggableIndex 
+from Products.PluginIndexes import PluggableIndex
 from Products.PluginIndexes.common.util import parseIndexRequest
 
 from Globals import Persistent, DTMLFile
@@ -29,26 +29,26 @@
 _marker = []
 
 class PathIndex(Persistent, Implicit, SimpleItem):
-    """ A path index stores all path components of the physical 
-    path of an object: 
+    """ A path index stores all path components of the physical
+    path of an object:
 
     Internal datastructure:
 
     - a physical path of an object is split into its components
-  
+
     - every component is kept as a  key of a OOBTree in self._indexes
 
     - the value is a mapping 'level of the path component' to
       'all documentIds with this path component on this level'
-  
+
     """
 
     __implements__ = (PluggableIndex.PluggableIndexInterface,)
 
     meta_type="PathIndex"
-    
+
     manage_options= (
-        {'label': 'Settings',     
+        {'label': 'Settings',
          'action': 'manage_main',
          'help': ('PathIndex','PathIndex_Settings.stx')},
     )
@@ -60,24 +60,24 @@
         self.id = id
 
         # experimental code for specifing the operator
-        self.operators = ['or','and'] 
+        self.operators = ['or','and']
         self.useOperator = 'or'
 
         self.clear()
 
-    
+
     def getId(self): return self.id
-        
+
     def clear(self):
         """ clear everything """
 
-        self._depth   = 0 
+        self._depth   = 0
         self._index   = OOBTree()
         self._unindex = IOBTree()
 
 
     def insertEntry(self,comp,id,level):
-        """ 
+        """
         k is a path component (generated by splitPath() )
         v is the documentId
         level is the level of the component inside the path
@@ -90,10 +90,10 @@
             self._index[comp][level] = IISet()
 
         self._index[comp][level].insert(id)
-        
+
         if level > self._depth: self._depth = level
 
-            
+
 
     def index_object(self, documentId, obj ,threshold=100):
         """ hook for (Z)Catalog """
@@ -110,11 +110,11 @@
             except:
                 return 0
 
-            if not (isinstance(path,StringType) or 
+            if not (isinstance(path,StringType) or
                     isinstance(path,TupleType)):
                 raise TypeError, "attribute/method must be/return string or tuple"
 
-        else:             
+        else:
 
             try:
                 path = obj.getPhysicalPath()
@@ -148,7 +148,7 @@
 
         for level in range(len(comps[1:])-1):
             comp = comps[level+1]
-    
+
             self._index[comp][level].remove(documentId)
 
             if len(self._index[comp][level])==0:
@@ -167,8 +167,8 @@
             for k1,v1 in v.items():
                 print k1,v1,
 
-            print 
-            
+            print
+
 
     def splitPath(self,path,obj=None):
         """ split physical path of object. If the object has
@@ -192,7 +192,7 @@
 
         level>=0  starts searching at the given level
         level<0   not implemented yet
-        """       
+        """
 
         if isinstance(path,StringType):
             level = default_level
@@ -201,13 +201,13 @@
             path  = path[0]
 
         comps = self.splitPath(path)
-        
+
 
         if level >=0:
 
             results = []
             for i in range(len(comps)):
-                
+
                 comp = comps[i]
 
                 if not self._index.has_key(comp): return IISet()
@@ -227,19 +227,19 @@
             results = IISet()
 
             for level in range(0,self._depth):
-           
+
                 ids = None
                 error = 0
 
                 for cn in range(0,len(comps)):
                     comp = comps[cn]
 
-                    try: 
+                    try:
                         ids = intersection(ids,self._index[comp][level+cn])
                     except:
                         error = 1
 
-                if error==0: 
+                if error==0:
                     results = union(results,ids)
 
             return results
@@ -256,20 +256,20 @@
         return len(self._unindex)
 
 
-    def keys(self):   
+    def keys(self):
         """ return list of all path components """
         keys = []
         for k in self._index.keys(): keys.append(k)
         return keys
 
 
-    def values(self):   
+    def values(self):
         values = []
         for k in self._index.values(): values.append(k)
         return values
 
 
-    def items(self):   
+    def items(self):
         """ mapping path components : documentIds """
 
         items = []
@@ -277,7 +277,7 @@
         return items
 
 
-    def _apply_index(self, request, cid=''): 
+    def _apply_index(self, request, cid=''):
         """ hook for (Z)Catalog
         request   mapping type (usually {"path": "..." }
                   additionaly a parameter "path_level" might be passed
@@ -296,7 +296,7 @@
                           "'level' key to specify the operator." % cid)
 
 
-        # get the level parameter 
+        # get the level parameter
         level    = record.get("level",0)
 
         # experimental code for specifing the operator
@@ -314,10 +314,10 @@
 
         if res:
             return res, (self.id,)
-        else: 
+        else:
             return IISet(), (self.id,)
 
-    
+
     def uniqueValues(self,name=None,withLength=0):
         """ needed to be consistent with the interface """
 
@@ -328,11 +328,11 @@
         """ Takes a document ID and returns all the information we have
         on that specific object. """
 
-        try:        
+        try:
             return self._unindex[documentId]
         except:
             return None
-        
+
 
     index_html = DTMLFile('dtml/index', globals())
     manage_workspace = DTMLFile('dtml/managePathIndex', globals())