From 808fd0ccb5cfe22bdc70da232a3829be15972993 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Tue, 27 Jun 2023 19:26:20 +0800 Subject: [PATCH] update: enhance GVLK fetch script --- gvlk/fetch.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gvlk/fetch.py b/gvlk/fetch.py index a1e8921..130800d 100755 --- a/gvlk/fetch.py +++ b/gvlk/fetch.py @@ -40,20 +40,20 @@ def combineGvlks(rawData: dict) -> dict: # merge multiple languages def combined(version: str) -> dict: keys = [x for _, x in firstVal(rawData)[version]['content'].items()] - gvlksItem = { + result = { 'name': {lang: data[version]['name'] for (lang, data) in rawData.items()}, 'content': [{'name': {}, 'key': x} for x in keys] } for index in range(len(keys)): for (lang, data) in rawData.items(): data = flipDict(data[version]['content']) - gvlksItem['content'][index]['name'][lang] = data[keys[index]] - return gvlksItem + result['content'][index]['name'][lang] = data[keys[index]] + return result return {x: combined(x) for x in list(firstVal(rawData))} if __name__ == '__main__': - gvlksData = combineGvlks({x: fetchGvlks(x) for x in LANG}) - with open('raw.json', 'w') as fp: # output at `raw.json` - fp.write(json.dumps(gvlksData, indent = 2, ensure_ascii = False) + '\n') + gvlkData = combineGvlks({x: fetchGvlks(x) for x in LANG}) + with open('raw.json', 'w') as fp: # output as `raw.json` + fp.write(json.dumps(gvlkData, indent = 2, ensure_ascii = False) + '\n')