def new(self, profile_name): ''' Creates a new profile with name 'profile_name' ''' if not profile_name in self.index: self.index[profile_name] = dict() self.index[profile_name]["directory"] = [FileTools.create_valid_name(profile_name)] profile_metadata = dict() FileTools.write_json(str(self.BASE_PATH.joinpath(profile_name + "/yamcl_metadata.json")), profile_metadata) self._flush_index()
def rename(self, current_profile_name, new_profile_name): ''' Renames a profile 'current_profile_name' to a new name 'new_profile_name' ''' if not current_profile_name in self.index: raise Exception("Cannot rename: " + current_profile_name + " does not exist") if new_profile_name in self.index: raise Exception("Cannot rename: " + new_profile_name + " already exists") FileTools.rename(str(self.BASE_PATH.joinpath(*self.index[current_profile_name]["directory"])), str(self.BASE_PATH.joinpath(FileTools.create_valid_name(new_profile_name)))) del self.index[current_profile_name] self.index[new_profile_name] = dict() self.index[new_profile_name]["directory"] = [FileTools.create_valid_name(new_profile_name)] self._flush_index()