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 load_settings(self, settings_mapfile=None):
     if settings_mapfile == None:
         settings_mapfile = self.storage.get(self.id.storage("settings"), default="\n")
     try:
         settings = mapfile.parse(settings_mapfile)
     except mapfile.InvalidMapfileContents, e:
         raise Exception("Invalid settings file for bugdir %s\n" "(BE version missmatch?)" % self.id.user())
 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)
Exemple #4
0
 def load_settings(self, settings_mapfile=None):
     if settings_mapfile == None:
         settings_mapfile = \
             self.storage.get(self.id.storage('settings'), default='{}\n')
     try:
         settings = mapfile.parse(settings_mapfile)
     except mapfile.InvalidMapfileContents, e:
         raise Exception('Invalid settings file for bugdir %s\n'
                         '(BE version missmatch?)' % self.id.user())
 def load_settings(self, settings_mapfile=None):
     if settings_mapfile == None:
         settings_mapfile = \
             self.storage.get(self.id.storage('settings'), default='\n')
     try:
         settings = mapfile.parse(settings_mapfile)
     except mapfile.InvalidMapfileContents, e:
         raise Exception('Invalid settings file for bugdir %s\n'
                         '(BE version missmatch?)' % self.id.user())
 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 load_settings(self, settings_mapfile=None):
     if self.uuid == INVALID_UUID:
         return
     if settings_mapfile == None:
         settings_mapfile = self.storage.get(
             self.id.storage('values'), '\n')
     try:
         settings = mapfile.parse(settings_mapfile)
     except mapfile.InvalidMapfileContents, e:
         raise Exception('Invalid settings file for comment %s\n'
                         '(BE version missmatch?)' % self.id.user())
 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)
Exemple #11
0
 def load_settings(self, settings_mapfile=None):
     if self.uuid == INVALID_UUID:
         return
     if settings_mapfile == None:
         settings_mapfile = self.storage.get(self.id.storage('values'),
                                             '{}\n')
     try:
         settings = mapfile.parse(settings_mapfile)
     except mapfile.InvalidMapfileContents, e:
         raise Exception('Invalid settings file for comment %s\n'
                         '(BE version missmatch?)' % self.id.user())
    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 = 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(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 _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 _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