def clear_index_directory(self): """Removes the indexed contents """ if self.path and self._path.startswith(settings.INDEXES_PATH): os.system('rm -rf %s' % self.path) log.warning('removed index at %s' % self.path) pass
def clear_index_directory(self): """Removes the indexed contents """ if self.path and self._path.startswith(settings.INDEXES_PATH): os.system('rm -rf %s' % self.path) log.warning('removed index at %s' % self.path) pass
def __index_path(self, path): """Indexes the items at the specified path.""" if os.path.isdir(path): self.__index_dir(path) elif os.path.isfile(path): self.__index_file(path) else: msg = 'Path %s is not valid for indexing' % path log.warning(msg) raise Exception(msg)
def __index_path(self, path): """Indexes the items at the specified path.""" if os.path.isdir(path): self.__index_dir(path) elif os.path.isfile(path): self.__index_file(path) else: msg = "Path %s is not valid for indexing" % path log.warning(msg) raise Exception(msg)
def __init__(self, hit, indexer, **kwargs): """Initializes this Result instance. :param hit: The raw indexer search hit this instance represents :param indexer: The sherlock.Indexer that holds this search result @param kwargs { path = Path of the file this result represents filename = Filename of the file } """ # the textual context of the hit self.context = '' self.path = kwargs.get('path') self.filename = kwargs.get('filename') self.index_path = self.path.replace(FULL_INDEX_PATH, '') try: self.process_hit(hit) except IOError, e: logger.warning('IOError while processing hit: %s:%s', self.path, e)
def __init__(self, hit, indexer, **kwargs): """Initializes this Result instance :param hit: The raw indexer search hit this instance represents :param indexer: The sherlock.Indexer that holds this search result @param kwargs { path = Path of the file this result represents filename = Filename of the file } """ # the textual context of the hit self.context = '' self.path = kwargs.get('path') self.filename = kwargs.get('filename') self.index_path = self.path.replace(FULL_INDEX_PATH, '') try: self.process_hit(hit) except IOError, e: logger.warning('IOError while processing hit: %s:%s' % (self.path, e)) pass
def open(self, index_path, **kwargs): """Creates or opens an index at the specified path.""" if not os.path.isdir(index_path): msg = 'Directory `%s` is not a valid index directory.' % index_path log.warning(msg) raise Exception(msg) # create the dir, if needed path = os.path.join(index_path, self._name) if not os.path.isdir(path): os.mkdir(path) log.warning('created index directory at %s' % path) # create or open the index if self._rebuild_index or not self._index.index_exists(path): log.debug('creating index at %s' % path) self._index.create_index(path) else: log.debug('opening index at %s' % path) self._index.open_index(path, writable=self._is_writable) # store indexes path self._path = path
def open(self, index_path, **kwargs): """Creates or opens an index at the specified path.""" if not os.path.isdir(index_path): msg = "Directory `%s` is not a valid index directory." % index_path log.warning(msg) raise Exception(msg) # create the dir, if needed path = os.path.join(index_path, self._name) if not os.path.isdir(path): os.mkdir(path) log.warning("created index directory at %s" % path) # create or open the index if self._rebuild_index or not self._index.index_exists(path): log.debug("creating index at %s" % path) self._index.create_index(path) else: log.debug("opening index at %s" % path) self._index.open_index(path, writable=self._is_writable) # store indexes path self._path = path
def clear_index_directory(self): """Removes the indexed contents.""" if self.path and self._path.startswith(settings.INDEXES_PATH): shutil.rmtree(self.path) log.warning('removed index at %s' % self.path)
def clear_index_directory(self): """Removes the indexed contents.""" if self.path and self._path.startswith(settings.INDEXES_PATH): shutil.rmtree(self.path) log.warning("removed index at %s" % self.path)