mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-03 00:51:11 +03:00
Removed repeated int(key)
With the previous formatting changes there is no reason to leave key as possibly a string anywhere, as it was already being converted to an int everywhere anyway
This commit is contained in:
parent
6a917acde0
commit
8268bfe5da
17
collate.py
17
collate.py
@ -99,7 +99,8 @@ def addmodules(data):
|
|||||||
|
|
||||||
for key, module in data['lastStarport'].get('modules').items():
|
for key, module in data['lastStarport'].get('modules').items():
|
||||||
# sanity check
|
# sanity check
|
||||||
if int(key) != module.get('id'):
|
key = int(key)
|
||||||
|
if key != module.get('id'):
|
||||||
raise ValueError('id: {} != {}'.format(key, module['id']))
|
raise ValueError('id: {} != {}'.format(key, module['id']))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -111,7 +112,7 @@ def addmodules(data):
|
|||||||
new = None
|
new = None
|
||||||
|
|
||||||
if new:
|
if new:
|
||||||
old = modules.get(int(key))
|
old = modules.get(key)
|
||||||
if old:
|
if old:
|
||||||
# check consistency with existing data
|
# check consistency with existing data
|
||||||
for thing in fields:
|
for thing in fields:
|
||||||
@ -121,7 +122,7 @@ def addmodules(data):
|
|||||||
elif str(new.get(thing, '')) != old.get(thing):
|
elif str(new.get(thing, '')) != old.get(thing):
|
||||||
raise ValueError('{}: {} {!r}!={!r}'.format(key, thing, new.get(thing), old.get(thing)))
|
raise ValueError('{}: {} {!r}!={!r}'.format(key, thing, new.get(thing), old.get(thing)))
|
||||||
|
|
||||||
modules[int(key)] = new
|
modules[key] = new
|
||||||
|
|
||||||
if len(modules) > size_pre:
|
if len(modules) > size_pre:
|
||||||
if isfile(outfile):
|
if isfile(outfile):
|
||||||
@ -158,21 +159,21 @@ def addships(data):
|
|||||||
data_ships = data['lastStarport']['ships']
|
data_ships = data['lastStarport']['ships']
|
||||||
for ship in tuple(data_ships.get('shipyard_list', {}).values()) + data_ships.get('unavailable_list'):
|
for ship in tuple(data_ships.get('shipyard_list', {}).values()) + data_ships.get('unavailable_list'):
|
||||||
# sanity check
|
# sanity check
|
||||||
key = ship['id']
|
key = int(ship['id'])
|
||||||
new = {'id': int(key), 'symbol': ship['name'], 'name': companion.ship_map.get(ship['name'].lower())}
|
new = {'id': key, 'symbol': ship['name'], 'name': companion.ship_map.get(ship['name'].lower())}
|
||||||
if new:
|
if new:
|
||||||
old = ships.get(int(key))
|
old = ships.get(key)
|
||||||
if old:
|
if old:
|
||||||
# check consistency with existing data
|
# check consistency with existing data
|
||||||
for thing in fields:
|
for thing in fields:
|
||||||
if not old.get(thing) and new.get(thing):
|
if not old.get(thing) and new.get(thing):
|
||||||
ships[int(key)] = new
|
ships[key] = new
|
||||||
size_pre -= 1
|
size_pre -= 1
|
||||||
|
|
||||||
elif str(new.get(thing, '')) != old.get(thing):
|
elif str(new.get(thing, '')) != old.get(thing):
|
||||||
raise ValueError('{}: {} {!r} != {!r}'.format(key, thing, new.get(thing), old.get(thing)))
|
raise ValueError('{}: {} {!r} != {!r}'.format(key, thing, new.get(thing), old.get(thing)))
|
||||||
|
|
||||||
ships[int(key)] = new
|
ships[key] = new
|
||||||
|
|
||||||
if len(ships) > size_pre:
|
if len(ships) > size_pre:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user