Skip to content

Instantly share code, notes, and snippets.

@chirimenmonster
Created November 23, 2017 04:53
Show Gist options
  • Save chirimenmonster/70e401151eeca8a8371baa8aac54f5c9 to your computer and use it in GitHub Desktop.
Save chirimenmonster/70e401151eeca8a8371baa8aac54f5c9 to your computer and use it in GitHub Desktop.
WoT車輌一覧取得(ログインしている状態であること)
from helpers import dependency
from skeletons.gui.shared import IItemsCache
from gui.shared.utils.requesters import REQ_CRITERIA
# 車輌一覧取得
itemCache = dependency.instance(IItemsCache)
vlist = itemCache.items.getVehicles(REQ_CRITERIA.EMPTY)
# 各車輌の属性を付加したリストを作成
attrs = ('intCD', 'name', 'userName', 'nationName', 'level', 'type', 'fullDescription')
names = map(lambda v: { k:getattr(v, k) for k in attrs }, vlist.itervalues())
# 並び替え
order_type = { 'lightTank':1, 'mediumTank':2, 'heavyTank':3, 'AT-SPG':4, 'SPG':5 }
order_nation = { 'germany':1, 'ussr':2, 'usa':3, 'france':4, 'uk':5, 'china':6, 'japan':7, 'czech':8, 'sweden':9, 'poland':10 }
names = sorted(names, key=lambda v:(v['level'],order_nation[v['nationName']],order_type[v['type']],v['intCD']))
# JSON形式でファイルに出力
import json
f = open('test.json', 'w')
f.write(json.dumps(names))
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment