Diff for /cdli/cdli_files.py between versions 1.80.2.6 and 1.80.2.9

version 1.80.2.6, 2007/11/02 15:37:46 version 1.80.2.9, 2007/11/27 10:27:39
Line 2127  class CDLIRoot(Folder): Line 2127  class CDLIRoot(Folder):
     def searchText(self, query, index='graphemes'):      def searchText(self, query, index='graphemes'):
         """searches query in the fulltext index and returns a list of file ids/P-numbers"""          """searches query in the fulltext index and returns a list of file ids/P-numbers"""
         # see also: http://www.plope.com/Books/2_7Edition/SearchingZCatalog.stx#2-13          # see also: http://www.plope.com/Books/2_7Edition/SearchingZCatalog.stx#2-13
           logging.debug("searchtext for '%s' in index %s"%(query,index))
           #import Products.ZCTextIndex.QueryParser
           #qp = QueryParser.QueryParser()
           #logging.debug()
         idxQuery = {index:{'query':query}}          idxQuery = {index:{'query':query}}
         idx = getattr(self, self.file_catalog)          idx = getattr(self, self.file_catalog)
         # do search          # do search
Line 2163  class CDLIRoot(Folder): Line 2167  class CDLIRoot(Folder):
   
     def showWordInFile(self,fileId,word,indexName='graphemes',regExp=False,):      def showWordInFile(self,fileId,word,indexName='graphemes',regExp=False,):
         """get lines with word from FileId"""          """get lines with word from FileId"""
           logging.debug("showwordinfile word='%s' index=%s file=%s"%(word,indexName,fileId)) 
                   
         file = formatAtfFullLineNum(self.getFile(fileId))          file = formatAtfFullLineNum(self.getFile(fileId))
         ret=[]          ret=[]
Line 2171  class CDLIRoot(Folder): Line 2176  class CDLIRoot(Folder):
         bounds = self.splitter[indexName].bounds          bounds = self.splitter[indexName].bounds
         splitexp = "(%s|\s)(%%s)(%s|\s|\Z)"%(bounds,bounds)          splitexp = "(%s|\s)(%%s)(%s|\s|\Z)"%(bounds,bounds)
         # compile into regexp objects          # compile into regexp objects
         wordlist = [re.compile(splitexp%w,re.IGNORECASE) for w in word.split(' ')]          wordlist = [re.compile(splitexp%w) for w in word.split(' ')]
                           
         for line in file.split("\n"):          for line in file.split("\n"):
             for word in wordlist:              for word in wordlist:
Line 2184  class CDLIRoot(Folder): Line 2189  class CDLIRoot(Folder):
         return ret          return ret
           
   
       def showWordInFiles(self,fileIds,word,indexName='graphemes',regExp=False):
           """
           get lines with word from all ids in list FileIds.
           returns dict with id:lines pairs.
           """
           logging.debug("showwordinfiles word='%s' index=%s file=%s"%(word,indexName,fileIds))
           
           return dict([(id,self.showWordInFile(id, word, indexName, regExp)) for id in fileIds])
       
   
     def tagWordInFile(self,fileId,word,indexName='graphemes',regExp=False):      def tagWordInFile(self,fileId,word,indexName='graphemes',regExp=False):
         """get text with word highlighted from FileId"""          """get text with word highlighted from FileId"""
           logging.debug("tagwordinfile word='%s' index=%s file=%s"%(word,indexName,fileId)) 
                   
         file=self.getFile(fileId)          file=self.getFile(fileId)
         tagStart=u'<span class="found">'          tagStart=u'<span class="found">'
Line 2234  class CDLIRoot(Folder): Line 2250  class CDLIRoot(Folder):
         return u'<br>\n'.join(ret)          return u'<br>\n'.join(ret)
           
   
   
       def tagWordInFiles(self,fileIds,word,indexName='graphemes',regExp=False):
           """
           get texts with highlighted word from all ids in list FileIds.
           returns dict with id:text pairs.
           """
           logging.debug("tagwordinfiles word='%s' index=%s file=%s"%(word,indexName,fileIds)) 
           return dict([(id,self.tagWordInFile(id, word, indexName, regExp)) for id in fileIds])
       
   
     def URLquote(self,str):      def URLquote(self,str):
         """quote url"""          """quote url"""
         return urllib.quote(str)          return urllib.quote(str)

Removed from v.1.80.2.6  
changed lines
  Added in v.1.80.2.9


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