def set_indexed_commit_hash(self): """ Persists the git commit hash that the index was built on. """ current_commit_hash = lib_git.get_current_commit_hash() filepath = os.path.join(lib_repo.get_scripts_path(), '__index__', self.index_name, 'git.commit.base.txt' ) with open(filepath, 'wt') as f: f.write(current_commit_hash)
def get_indexed_uncommitted_files(self): """ Returns a list of uncommitted files in the index. """ filepath = os.path.join(lib_repo.get_scripts_path(), '__index__', self.index_name, 'indexed.uncommitted.pickle' ) if not os.path.isfile(filepath): return {} else: with open(filepath, 'rb') as f: return pickle.load(f)
def get_indexed_commit_hash(self): """ Returns the git commit hash that the index was built on. """ filepath = os.path.join(lib_repo.get_scripts_path(), '__index__', self.index_name, 'git.commit.base.txt' ) if not os.path.isfile(filepath): return 'does-not-exist' else: with open(filepath, 'rt') as f: commit_hash = f.read() return commit_hash
def get_index(self, force_rebuild=False): """ Returns a reference to the search index, creating if necessary. """ indices_path = os.path.join(lib_repo.get_scripts_path(), '__index__') index_path = os.path.join(indices_path, self.index_name) if force_rebuild and os.path.exists(index_path): shutil.rmtree(index_path) if not os.path.exists(indices_path): os.mkdir(indices_path) if not os.path.exists(index_path): os.mkdir(index_path) if not whoosh.index.exists_in(index_path, self.index_name): schema_dictionary = self.schema_dictionary whoosh.index.create_in(index_path, whoosh.fields.Schema(**schema_dictionary), self.index_name) return whoosh.index.open_dir(index_path, self.index_name)
def get_indices_path(self): return os.path.join(lib_repo.get_scripts_path(), '__index__')
def set_indexed_uncommitted_files(self, files=[]): """ Persist a list of uncommitted files in the index. """ filepath = os.path.join(lib_repo.get_scripts_path(), '__index__', self.index_name, 'indexed.uncommitted.pickle' ) with open(filepath, 'wb') as f: pickle.dump(files, f)
def set_indexed_uncommitted_files(self, files=[]): """ Persist a list of uncommitted files in the index. """ filepath = os.path.join(lib_repo.get_scripts_path(), '__index__', self.index_name, 'indexed.uncommitted.pickle') with open(filepath, 'wb') as f: pickle.dump(files, f)