From fd3a4852f2d2df1cc9aca807dd04e72ed2e8d135 Mon Sep 17 00:00:00 2001 From: A_D Date: Mon, 13 Jul 2020 06:03:37 +0200 Subject: [PATCH] replace modulo formatting with .format --- collate.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/collate.py b/collate.py index ccfa9271..a1d2367d 100755 --- a/collate.py +++ b/collate.py @@ -45,7 +45,7 @@ def addcommodities(data): if old and companion.category_map.get(commodity['categoryname'], True): if new['symbol'] != old['symbol'] or new['name'] != old['name']: - raise AssertionError('%s: "%s"!="%s"' % (key, new, old)) + raise AssertionError('{}: {!r} != {!r}'.format(key, new, old)) commodities[key] = new @@ -63,7 +63,7 @@ def addcommodities(data): for key in sorted(commodities): writer.writerow(commodities[key]) - print('Added %d new commodities' % (len(commodities) - size_pre)) + print('Added {} new commodities'.format(len(commodities) - size_pre)) # keep a summary of modules found @@ -87,13 +87,13 @@ def addmodules(data): for key, module in data['lastStarport'].get('modules').items(): # sanity check if int(key) != module.get('id'): - raise AssertionError('id: %s!=%s' % (key, module['id'])) + raise AssertionError('id: {} != {}'.format(key, module['id'])) try: new = outfitting.lookup(module, companion.ship_map, True) - except: - print('%d, %s:' % (module['id'], module['name'])) + except Exception: + print('{}, {}:'.format(module['id'], module['name'])) print_exc(0) new = None @@ -106,7 +106,7 @@ def addmodules(data): size_pre -= 1 elif str(new.get(thing, '')) != old.get(thing): - raise AssertionError('%s: %s "%s"!="%s"' % (key, thing, new.get(thing), old.get(thing))) + raise AssertionError('{}: {} {!r}!={!r}'.format(key, thing, new.get(thing), old.get(thing))) modules[int(key)] = new @@ -124,7 +124,7 @@ def addmodules(data): for key in sorted(modules): writer.writerow(modules[key]) - print('Added %d new modules' % (len(modules) - size_pre)) + print('Added {} new modules'.format(len(modules) - size_pre)) # keep a summary of ships found @@ -160,7 +160,7 @@ def addships(data): size_pre -= 1 elif str(new.get(thing, '')) != old.get(thing): - raise AssertionError('%s: %s "%s"!="%s"' % (key, thing, new.get(thing), old.get(thing))) + raise AssertionError('{}: {} {!r} != {!r}'.format(key, thing, new.get(thing), old.get(thing))) ships[int(key)] = new @@ -179,7 +179,7 @@ def addships(data): for key in sorted(ships): writer.writerow(ships[key]) - print('Added %d new ships' % (len(ships) - size_pre)) + print('Added {} new ships'.format(len(ships) - size_pre)) if __name__ == "__main__":