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 = mapfile.parse(contents)
         contents = mapfile.generate(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 = mapfile.parse(contents)
         contents = mapfile.generate(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 = mapfile.generate(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 = mapfile.generate(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 = 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_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 = 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_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(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_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(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 save_settings(self):
     mf = mapfile.generate(self._get_saved_settings())
     self.storage.set(self.id.storage('settings'), mf)
Example #14
0
 def save_settings(self):
     mf = mapfile.generate(self._get_saved_settings())
     self.storage.set(self.id.storage('settings'), mf)
 def save_settings(self):
     if self.uuid == INVALID_UUID:
         return
     mf = mapfile.generate(self._get_saved_settings())
     self.storage.set(self.id.storage("values"), mf)
Example #16
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 #17
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 #18
0
 def save_settings(self):
     if self.uuid == INVALID_UUID:
         return
     mf = mapfile.generate(self._get_saved_settings())
     self.storage.set(self.id.storage("values"), mf)