Example #1
0
File: upgrade.py Project: sbruce/be
 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)
Example #2
0
 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)
Example #3
0
File: upgrade.py Project: sbruce/be
 def _get_vcs_name(self):
     path = self.get_path("settings")
     settings = encoding.get_file_contents(path)
     for line in settings.splitlines(False):
         fields = line.split("=")
         if len(fields) == 2 and fields[0] == "rcs_name":
             return fields[1]
     return None
Example #4
0
 def _get_vcs_name(self):
     path = self.get_path('settings')
     settings = encoding.get_file_contents(path)
     for line in settings.splitlines(False):
         fields = line.split('=')
         if len(fields) == 2 and fields[0] == 'rcs_name':
             return fields[1]
     return None
Example #5
0
 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 = 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)
Example #7
0
File: upgrade.py Project: sbruce/be
 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)
Example #8
0
File: upgrade.py Project: sbruce/be
 def _get_vcs_name(self):
     path = self.get_path("settings")
     for p in os.listdir(self.get_path()):  # check each bugdir's settings
         path = os.path.join(self.get_path(), p)
         if os.path.isdir(path):
             settings_path = os.path.join(path, "settings")
             if os.path.isfile(settings_path):
                 settings = parse_yaml_mapfile(encoding.get_file_contents(settings_path))
                 if "vcs_name" in settings:
                     return settings["vcs_name"]  # first entry we found
     return None
Example #9
0
File: upgrade.py Project: sbruce/be
 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)
Example #11
0
 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)
Example #12
0
 def _get_vcs_name(self):
     path = self.get_path('settings')
     for p in os.listdir(self.get_path()):  # check each bugdir's settings
         path = os.path.join(self.get_path(), p)
         if os.path.isdir(path):
             settings_path = os.path.join(path, 'settings')
             if os.path.isfile(settings_path):
                 settings = parse_yaml_mapfile(encoding.get_file_contents(
                         settings_path))
                 if 'vcs_name' in settings:
                     return settings['vcs_name']  # first entry we found
     return None
Example #13
0
    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)
Example #15
0
File: upgrade.py Project: sbruce/be
    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)
Example #16
0
File: upgrade.py Project: sbruce/be
 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)
Example #19
0
 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)
Example #20
0
 def _get_vcs_name(self):
     path = self.get_path('settings')
     settings = parse_yaml_mapfile(encoding.get_file_contents(path))
     if 'vcs_name' in settings:
         return settings['vcs_name']
     return None
 def _get_vcs_name(self):
     path = self.get_path('settings')
     settings = mapfile.parse(encoding.get_file_contents(path))
     if 'vcs_name' in settings:
         return settings['vcs_name']
     return None
 def check_initial_version(self):
     path = self.get_path('version')
     version = encoding.get_file_contents(path, decode=True).rstrip('\n')
     assert version == self.initial_version, '%s: %s' % (path, version)
Example #23
0
File: upgrade.py Project: sbruce/be
 def check_initial_version(self):
     path = self.get_path("version")
     version = encoding.get_file_contents(path, decode=True).rstrip()
     assert version == self.initial_version, "%s: %s" % (path, version)
Example #24
0
File: upgrade.py Project: sbruce/be
 def _get_vcs_name(self):
     path = self.get_path("settings")
     settings = parse_yaml_mapfile(encoding.get_file_contents(path))
     if "vcs_name" in settings:
         return settings["vcs_name"]
     return None
Example #25
0
File: upgrade.py Project: sbruce/be
 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)
Example #26
0
 def check_initial_version(self):
     path = self.get_path('version')
     version = encoding.get_file_contents(path, decode=True).rstrip()
     assert version == self.initial_version, '%s: %s' % (path, version)