def branch(self, branch): self._branch = branch self.branch_path = os.path.join(self.path, self._branch) self.index_path = os.path.join(self.branch_path, AIM_COMMIT_INDEX_DIR_NAME) self.objects_dir_path = os.path.join(self.index_path, AIM_OBJECTS_DIR_NAME) self.media_dir_path = os.path.join(self.objects_dir_path, AIM_MEDIA_DIR_NAME) if self.records_storage: self.records_storage.close() if os.path.exists(self.branch_path): aimrecords = import_module('aimrecords') storage = aimrecords.Storage self.records_storage = storage(self.objects_dir_path, storage.WRITING_MODE)
def branch(self, branch): self._branch = branch if not self._branch in self.list_branches(): self.create_branch(self._branch) self.branch_path = os.path.join(self.path, self._branch) self.index_path = os.path.join(self.branch_path, self.active_commit) self.objects_dir_path = os.path.join(self.index_path, AIM_OBJECTS_DIR_NAME) self.media_dir_path = os.path.join(self.objects_dir_path, AIM_MEDIA_DIR_NAME) if not os.path.isdir(self.index_path): os.makedirs(self.index_path) if self.records_storage: self.records_storage.close() if os.path.exists(self.branch_path): aimrecords = import_module('aimrecords') storage = aimrecords.Storage self.records_storage = storage(self.objects_dir_path, storage.WRITING_MODE)
def get_records_storage(self, path, mode): aimrecords = import_module('aimrecords') storage = aimrecords.Storage storage_inst = storage(path, mode) return storage_inst