From 36fb53f0e7b8c065ab108eb490653960e3382d8c Mon Sep 17 00:00:00 2001 From: Jylpah Date: Thu, 29 Apr 2021 00:09:40 +0300 Subject: [PATCH] convert_tank_names(): Fix tank key sorting --- extract_tankopedia.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/extract_tankopedia.py b/extract_tankopedia.py index 1bbc1fc..3e213a7 100755 --- a/extract_tankopedia.py +++ b/extract_tankopedia.py @@ -115,13 +115,12 @@ async def extract_tanks(blitz_app_base : str, nation: str): for data in tankList['root'].keys(): tank_xml = tankList['root'][data] tank = dict() - tank['tank_id'] = await get_tank_id(nation, int(tank_xml['id'])) - tank['userStr'] = tank_xml['userString'] - tank['nation'] = nation - tank['tier'] = int(tank_xml['level']) - #debug(tank_xml['price']) tank['is_premium'] = issubclass(type(tank_xml['price']), dict) + tank['nation'] = nation + tank['tank_id'] = await get_tank_id(nation, int(tank_xml['id'])) + tank['tier'] = int(tank_xml['level']) tank['type'] = await get_tank_type(tank_xml['tags']) + tank['userStr'] = tank_xml['userString'] #bu.debug('Reading tank string: ' + tank['userStr'], force=True) tanks.append(tank) except Exception as err: @@ -165,7 +164,10 @@ async def convert_tank_names(tanklist : list, tank_strs: dict) -> dict: tank['name'] = tank_strs[tank['userStr']] #userStrs[tank['userStr'].split(':')[1]] = tank['name'] tank.pop('userStr', None) - tankopedia[str(tank['tank_id'])] = tank + tank_tmp = collections.OrderedDict() + for key in sorted(tank.keys()): + tank_tmp[key] = tank[key] + tankopedia[str(tank['tank_id'])] = tank_tmp for tank_str in tank_strs: skip = False