diff options
Diffstat (limited to 'libbe/storage/util/upgrade.py')
-rw-r--r-- | libbe/storage/util/upgrade.py | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/libbe/storage/util/upgrade.py b/libbe/storage/util/upgrade.py index c3a5df1..12d177a 100644 --- a/libbe/storage/util/upgrade.py +++ b/libbe/storage/util/upgrade.py @@ -49,14 +49,14 @@ def generate_yaml_mapfile(map): >>> generate_yaml_mapfile({'q':'p'}) 'q: p\\n\\n' - >>> generate_yaml_mapfile({'q':u'Fran\u00e7ais'}) + >>> generate_yaml_mapfile({'q':u'Fran\\u00e7ais'}) 'q: Fran\\xc3\\xa7ais\\n\\n' >>> generate_yaml_mapfile({'q':u'hello'}) 'q: hello\\n\\n' """ if yaml is None: raise _yaml_import_error - keys = map.keys() + keys = list(map.keys()) keys.sort() for key in keys: try: @@ -66,9 +66,9 @@ def generate_yaml_mapfile(map): assert(':' not in key) assert(len(key) > 0) except AssertionError: - raise ValueError(unicode(key).encode('unicode_escape')) + raise ValueError(str(key).encode('unicode_escape')) if '\n' in map[key]: - raise ValueError(unicode(map[key]).encode('unicode_escape')) + raise ValueError(str(map[key]).encode('unicode_escape')) lines = [] for key in keys: @@ -94,7 +94,7 @@ def parse_yaml_mapfile(contents): 'd' >>> dict['e'] 'f' - >>> contents = generate_yaml_mapfile({'q':u'Fran\u00e7ais'}) + >>> contents = generate_yaml_mapfile({'q':u'Fran\\u00e7ais'}) >>> dict = parse_yaml_mapfile(contents) >>> dict['q'] u'Fran\\xe7ais' @@ -102,7 +102,7 @@ def parse_yaml_mapfile(contents): if yaml is None: raise _yaml_import_error c = yaml.safe_load(contents) - if type(c) == types.StringType: + if type(c) == bytes: raise mapfile.InvalidMapfileContents( 'Unable to parse YAML (BE format missmatch?):\n\n%s' % contents) return c or {} @@ -146,8 +146,8 @@ class Upgrader (object): self.vcs._vcs_update(path) def upgrade(self): - print >> sys.stderr, 'upgrading bugdir from "%s" to "%s"' \ - % (self.initial_version, self.final_version) + print('upgrading bugdir from "%s" to "%s"' \ + % (self.initial_version, self.final_version), file=sys.stderr) self.check_initial_version() self.set_version() self._upgrade() @@ -191,7 +191,7 @@ class Upgrade_1_0_to_1_1 (Upgrader): contents = '\n'.join(newlines) # load the YAML and save map = parse_yaml_mapfile(contents) - if type(map) == types.StringType: + if type(map) == bytes: raise ValueError((path, contents)) contents = generate_yaml_mapfile(map) encoding.set_file_contents(path, contents) @@ -317,7 +317,7 @@ class Upgrade_1_2_to_1_3 (Upgrader): for bug_uuid in os.listdir(self.get_path('bugs')): self._upgrade_bug_mapfile(bug_uuid) self._upgrade_bugdir_mapfile() - for bug in self._targets.values(): + for bug in list(self._targets.values()): self._save_bug_settings(bug) class Upgrade_1_3_to_1_4 (Upgrader): @@ -418,11 +418,9 @@ def upgrade(path, current_version, use consecutive conversion functions. """ if current_version not in STORAGE_VERSIONS: - raise NotImplementedError, \ - "Cannot handle version '%s' yet." % current_version + raise NotImplementedError("Cannot handle version '%s' yet." % current_version) if target_version not in STORAGE_VERSIONS: - raise NotImplementedError, \ - "Cannot handle version '%s' yet." % current_version + raise NotImplementedError("Cannot handle version '%s' yet." % current_version) if (current_version, target_version) in upgrade_classes: # direct conversion @@ -438,9 +436,8 @@ def upgrade(path, current_version, try: upgrade_class = upgrade_classes[(version_a, version_b)] except KeyError: - raise NotImplementedError, \ - "Cannot convert version '%s' to '%s' yet." \ - % (version_a, version_b) + raise NotImplementedError("Cannot convert version '%s' to '%s' yet." \ + % (version_a, version_b)) u = upgrade_class(path) u.upgrade() if version_b == target_version: |