Diff for /cdli/cdli_files.py between versions 1.56 and 1.57

version 1.56, 2007/01/08 14:36:28 version 1.57, 2007/01/09 16:06:09
Line 22  from ZPublisher.HTTPResponse import HTTP Line 22  from ZPublisher.HTTPResponse import HTTP
 from ZPublisher.BaseRequest import RequestContainer  from ZPublisher.BaseRequest import RequestContainer
 import threading  import threading
 from BTrees.OOBTree import OOBTree  from BTrees.OOBTree import OOBTree
   import logging
   
 def unique(s):  def unique(s):
     """Return a list of the elements in s, but without duplicates.      """Return a list of the elements in s, but without duplicates.
Line 1932  class CDLIRoot(Folder): Line 1933  class CDLIRoot(Folder):
     meta_type="CDLIRoot"      meta_type="CDLIRoot"
     downloadCounterBaskets=0# counts the current basket downloads if counter > 10 no downloads are possible      downloadCounterBaskets=0# counts the current basket downloads if counter > 10 no downloads are possible
           
       def findWordRegExp(self,searchTerm):
           """find all words in index which match regexp in SearchTerm"""
           ret=[]
           for x in self.lineIndex.iterkeys():
               if re.match(searchTerm,x):
                   ret.append(x)
           return ret
       
       def searchRegExpInLineIndexDocs(self,searchTerm):
           """search in inLineIndex with regexp"""
           if not searchTerm:
               return []
           ret=[]
           words=self.findWordRegExp(searchTerm) # suche nach allen Treffern
           logging.info("wd:%s"%words)
           for word in words:
               ret+=self.searchInLineIndexDocs(word)
           
           return unique(ret)
           
     def showInLineIndex(self):      def showInLineIndex(self):
         """get the index for debug purposes"""          """get the index for debug purposes"""
         print "show"          print "show"
         for x in self.lineIndex.iterkeys():          for x in self.lineIndex.iterkeys():
             print "word:",repr(x)              logging.info("word:%s"%repr(x))
             #for y in self.lineIndex[x].iterkeys():              #for y in self.lineIndex[x].iterkeys():
             #    print "doc",repr(y),repr(self.lineIndex[x][y])              #    print "doc",repr(y),repr(self.lineIndex[x][y])
                                   
         return self.lineIndex          return self.lineIndex
                   
     def searchInLineIndexDocs(self,word,uniq=True):      def searchInLineIndexDocs(self,word,uniq=True,regExp=False):
         """search occurences"""          """search occurences"""
                   
           if regExp:
               return self.searchRegExpInLineIndexDocs(word)
           
         try:              try:    
             lst=list(self.lineIndex.get(word).keys())              lst=list(self.lineIndex.get(word).keys())
     except:      except:
Line 1954  class CDLIRoot(Folder): Line 1978  class CDLIRoot(Folder):
         else:          else:
             return lst              return lst
                   
     def getLinesFromIndex(self,word,doc):      def getLinesFromIndex(self,word,doc,regExp=False):
         """get lines"""          """get lines"""
               if not regExp:
         return self.lineIndex.get(word)[doc]          return self.lineIndex.get(word)[doc]
           else: # wenn regexp, suche welches word
               for w in self.findWordRegExp(word):
                   if self.lineIndex.get(w): # ein word in im dex gefunden
                       try:    
                           dc=self.lineIndex.get(word)[doc]
                           return dc # und ein document dann gib es zurueck
                       except:
                            pass #andernfalls weiter
   
     def cleanInLineIndex(self):      def cleanInLineIndex(self):
         """delete InlineIndex"""          """delete InlineIndex"""

Removed from v.1.56  
changed lines
  Added in v.1.57


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>