def _upgrade_mapfile(self, path): contents = encoding.get_file_contents(path, decode=True) old_format = False for line in contents.splitlines(): if len(line.split("=")) == 2: old_format = True break if old_format == True: # translate to YAML. newlines = [] for line in contents.splitlines(): line = line.rstrip("\n") if len(line) == 0: continue fields = line.split("=") if len(fields) == 2: key, value = fields newlines.append('%s: "%s"' % (key, value.replace('"', '\\"'))) else: newlines.append(line) contents = "\n".join(newlines) # load the YAML and save map = parse_yaml_mapfile(contents) if type(map) == types.StringType: raise ValueError((path, contents)) contents = generate_yaml_mapfile(map) encoding.set_file_contents(path, contents) self.vcs._vcs_update(path)
def _upgrade_mapfile(self, path): contents = encoding.get_file_contents(path, decode=True) old_format = False for line in contents.splitlines(): if len(line.split('=')) == 2: old_format = True break if old_format == True: # translate to YAML. newlines = [] for line in contents.splitlines(): line = line.rstrip('\n') if len(line) == 0: continue fields = line.split("=") if len(fields) == 2: key,value = fields newlines.append('%s: "%s"' % (key, value.replace('"','\\"'))) else: newlines.append(line) contents = '\n'.join(newlines) # load the YAML and save map = parse_yaml_mapfile(contents) if type(map) == types.StringType: raise ValueError((path, contents)) contents = generate_yaml_mapfile(map) encoding.set_file_contents(path, contents) self.vcs._vcs_update(path)
def _save_bug_settings(self, bug): # The target bugs don't have comments path = self.get_path('bugs', bug.uuid, 'values') if not os.path.exists(path): self.vcs._add_path(path, directory=False) path = self.get_path('bugs', bug.uuid, 'values') mf = generate_yaml_mapfile(bug._get_saved_settings()) encoding.set_file_contents(path, mf) self.vcs._vcs_update(path)
def _save_bug_settings(self, bug): # The target bugs don't have comments path = self.get_path("bugs", bug.uuid, "values") if not os.path.exists(path): self.vcs._add_path(path, directory=False) path = self.get_path("bugs", bug.uuid, "values") mf = generate_yaml_mapfile(bug._get_saved_settings()) encoding.set_file_contents(path, mf) self.vcs._vcs_update(path)
def _upgrade(self): """ BugDir settings field "rcs_name" -> "vcs_name". """ path = self.get_path('settings') settings = mapfile.parse(encoding.get_file_contents(path)) if 'rcs_name' in settings: settings['vcs_name'] = settings.pop('rcs_name') encoding.set_file_contents(path, mapfile.generate(settings)) self.vcs._vcs_update(path)
def _upgrade(self): """ BugDir settings field "rcs_name" -> "vcs_name". """ path = self.get_path("settings") settings = parse_yaml_mapfile(encoding.get_file_contents(path)) if "rcs_name" in settings: settings["vcs_name"] = settings.pop("rcs_name") encoding.set_file_contents(path, generate_yaml_mapfile(settings)) self.vcs._vcs_update(path)
def _upgrade(self): """ BugDir settings field "rcs_name" -> "vcs_name". """ path = self.get_path('settings') settings = parse_yaml_mapfile(encoding.get_file_contents(path)) if 'rcs_name' in settings: settings['vcs_name'] = settings.pop('rcs_name') encoding.set_file_contents(path, generate_yaml_mapfile(settings)) self.vcs._vcs_update(path)
def _upgrade_bugdir_mapfile(self): path = self.get_path('settings') mf = encoding.get_file_contents(path) if mf == libbe.util.InvalidObject: return # settings file does not exist settings = parse_yaml_mapfile(mf) if 'target' in settings: settings['target'] = self._target_bug(settings['target']).uuid mf = generate_yaml_mapfile(settings) encoding.set_file_contents(path, mf) self.vcs._vcs_update(path)
def _upgrade_bugdir_mapfile(self): path = self.get_path('settings') mf = encoding.get_file_contents(path) if mf == libbe.util.InvalidObject: return # settings file does not exist settings = mapfile.parse(mf) if 'target' in settings: settings['target'] = self._target_bug(settings['target']).uuid mf = mapfile.generate(settings) encoding.set_file_contents(path, mf) self.vcs._vcs_update(path)
def _upgrade_bugdir_mapfile(self): path = self.get_path("settings") mf = encoding.get_file_contents(path) if mf == libbe.util.InvalidObject: return # settings file does not exist settings = parse_yaml_mapfile(mf) if "target" in settings: settings["target"] = self._target_bug(settings["target"]).uuid mf = generate_yaml_mapfile(settings) encoding.set_file_contents(path, mf) self.vcs._vcs_update(path)
def _upgrade_bug_mapfile(self, bug_uuid): import libbe.command.depend as dep path = self.get_path('bugs', bug_uuid, 'values') mf = encoding.get_file_contents(path) if mf == libbe.util.InvalidObject: return # settings file does not exist settings = parse_yaml_mapfile(mf) if 'target' in settings: target_bug = self._target_bug(settings['target']) blocked_by_string = '%s%s' % (dep.BLOCKED_BY_TAG, bug_uuid) dep._add_remove_extra_string(target_bug, blocked_by_string, add=True) blocks_string = dep._generate_blocks_string(target_bug) estrs = settings.get('extra_strings', []) estrs.append(blocks_string) settings['extra_strings'] = sorted(estrs) settings.pop('target') mf = generate_yaml_mapfile(settings) encoding.set_file_contents(path, mf) self.vcs._vcs_update(path)
def _upgrade_bug_mapfile(self, bug_uuid): import libbe.command.depend as dep path = self.get_path('bugs', bug_uuid, 'values') mf = encoding.get_file_contents(path) if mf == libbe.util.InvalidObject: return # settings file does not exist settings = mapfile.parse(mf) if 'target' in settings: target_bug = self._target_bug(settings['target']) blocked_by_string = '%s%s' % (dep.BLOCKED_BY_TAG, bug_uuid) dep._add_remove_extra_string(target_bug, blocked_by_string, add=True) blocks_string = dep._generate_blocks_string(target_bug) estrs = settings.get('extra_strings', []) estrs.append(blocks_string) settings['extra_strings'] = sorted(estrs) settings.pop('target') mf = mapfile.generate(settings) encoding.set_file_contents(path, mf) self.vcs._vcs_update(path)
def _upgrade_bug_mapfile(self, bug_uuid): import libbe.command.depend as dep path = self.get_path("bugs", bug_uuid, "values") mf = encoding.get_file_contents(path) if mf == libbe.util.InvalidObject: return # settings file does not exist settings = parse_yaml_mapfile(mf) if "target" in settings: target_bug = self._target_bug(settings["target"]) blocked_by_string = "%s%s" % (dep.BLOCKED_BY_TAG, bug_uuid) dep._add_remove_extra_string(target_bug, blocked_by_string, add=True) blocks_string = dep._generate_blocks_string(target_bug) estrs = settings.get("extra_strings", []) estrs.append(blocks_string) settings["extra_strings"] = sorted(estrs) settings.pop("target") mf = generate_yaml_mapfile(settings) encoding.set_file_contents(path, mf) self.vcs._vcs_update(path)
def _upgrade(self): """ Comment value field "From" -> "Author". Homegrown mapfile -> YAML. """ path = self.get_path("settings") self._upgrade_mapfile(path) for bug_uuid in os.listdir(self.get_path("bugs")): path = self.get_path("bugs", bug_uuid, "values") self._upgrade_mapfile(path) c_path = ["bugs", bug_uuid, "comments"] if not os.path.exists(self.get_path(*c_path)): continue # no comments for this bug for comment_uuid in os.listdir(self.get_path(*c_path)): path_list = c_path + [comment_uuid, "values"] path = self.get_path(*path_list) self._upgrade_mapfile(path) settings = parse_yaml_mapfile(encoding.get_file_contents(path)) if "From" in settings: settings["Author"] = settings.pop("From") encoding.set_file_contents(path, generate_yaml_mapfile(settings)) self.vcs._vcs_update(path)
def _upgrade(self): """ Comment value field "From" -> "Author". Homegrown mapfile -> YAML. """ path = self.get_path('settings') self._upgrade_mapfile(path) for bug_uuid in os.listdir(self.get_path('bugs')): path = self.get_path('bugs', bug_uuid, 'values') self._upgrade_mapfile(path) c_path = ['bugs', bug_uuid, 'comments'] if not os.path.exists(self.get_path(*c_path)): continue # no comments for this bug for comment_uuid in os.listdir(self.get_path(*c_path)): path_list = c_path + [comment_uuid, 'values'] path = self.get_path(*path_list) self._upgrade_mapfile(path) settings = mapfile.parse(encoding.get_file_contents(path)) if 'From' in settings: settings['Author'] = settings.pop('From') encoding.set_file_contents(path, mapfile.generate(settings)) self.vcs._vcs_update(path)
def _upgrade(self): """ Comment value field "From" -> "Author". Homegrown mapfile -> YAML. """ path = self.get_path('settings') self._upgrade_mapfile(path) for bug_uuid in os.listdir(self.get_path('bugs')): path = self.get_path('bugs', bug_uuid, 'values') self._upgrade_mapfile(path) c_path = ['bugs', bug_uuid, 'comments'] if not os.path.exists(self.get_path(*c_path)): continue # no comments for this bug for comment_uuid in os.listdir(self.get_path(*c_path)): path_list = c_path + [comment_uuid, 'values'] path = self.get_path(*path_list) self._upgrade_mapfile(path) settings = mapfile.parse( encoding.get_file_contents(path)) if 'From' in settings: settings['Author'] = settings.pop('From') encoding.set_file_contents( path, mapfile.generate(settings)) self.vcs._vcs_update(path)
def _upgrade_mapfile(self, path): contents = encoding.get_file_contents(path) data = parse_yaml_mapfile(contents) contents = mapfile.generate(data) encoding.set_file_contents(path, contents) self.vcs._vcs_update(path)
def set_version(self): path = self.get_path("version") encoding.set_file_contents(path, self.final_version + "\n") self.vcs._vcs_update(path)
def set_version(self): path = self.get_path('version') encoding.set_file_contents(path, self.final_version+'\n') self.vcs._vcs_update(path)