Пример #1
0
 def index_file(self, filepath, *args, **kwargs):
     assert self._index is not None
     contents = safe_read_file(filepath)
     if contents is None:
         return
     path = unicode(filepath)
     # build doc
     doc = dict(filename=unicode(os.path.basename(filepath)),
                path=path,
                content=contents + path)
     self._writer.update_document(**doc)
     pass
Пример #2
0
 def index_file(self, filepath, *args, **kwargs):
     assert self._index is not None
     contents = safe_read_file(filepath)
     if contents is None:
         return
     path = unicode(filepath)
     # build doc
     doc = dict(
         filename=unicode(os.path.basename(filepath)),
         path=path,
         content=contents + path
     )
     self._writer.update_document(**doc)
Пример #3
0
 def index_file(self, filepath, *args, **kwargs):
     # index file content
     contents = safe_read_file(filepath)
     if contents is None:
         return
     document = xapian.Document()
     # store file meta
     filename = os.path.basename(filepath)
     document.add_value(self.DOC_VALUE_FILENAME, filename)
     document.add_value(self.DOC_VALUE_FILEPATH, filepath)
     # index document and file path
     self.indexer.set_document(document)
     self.indexer.index_text(contents + ' ' + filepath)
     doc_id = kwargs.get('document_id')
     if doc_id:
         self.index.replace_document(doc_id, document)
     else:
         self.index.add_document(document)
Пример #4
0
 def index_file(self, filepath, *args, **kwargs):
     # index file content
     contents = safe_read_file(filepath)
     if contents is None:
         return
     document = xapian.Document()
     # store file meta
     filename = os.path.basename(filepath)
     document.add_value(self.DOC_VALUE_FILENAME, filename)
     document.add_value(self.DOC_VALUE_FILEPATH, filepath)
     # index document and file path
     self.indexer.set_document(document)
     self.indexer.index_text(contents+' '+filepath)
     doc_id = kwargs.get('document_id')
     if doc_id:
         self.index.replace_document(doc_id, document)
     else:
         self.index.add_document(document)