diff --git a/gvlk/config.yml b/gvlk/config.yml index bfbc788..efc98c4 100644 --- a/gvlk/config.yml +++ b/gvlk/config.yml @@ -2,3 +2,27 @@ lang: - en-us - zh-cn - zh-tw + +path: ../assets/gvlk/ + +win: + - 'windows-vista' + - 'windows-7' + - 'windows-8' + - 'windows-81' + - 'windows-11-and-windows-10-semi-annual-channel-versions' + - 'windows-10-ltsb-2015' + - 'windows-10-ltsb-2016' + - 'windows-10-ltsc-2021-and-2019' + +win-server: + - 'windows-server-version-1709' + - 'windows-server-version-1803' + - 'windows-server-versions-20h2-2004-1909-1903-and-1809' + - 'windows-server-2016' + - 'windows-server-2019' + - 'windows-server-2022' + - 'windows-server-2012-r2' + - 'windows-server-2012' + - 'windows-server-2008-r2' + - 'windows-server-2008' diff --git a/gvlk/ok.json b/gvlk/data.json similarity index 100% rename from gvlk/ok.json rename to gvlk/data.json diff --git a/gvlk/fetch.py b/gvlk/fetch.py index 01aba3c..3a07b16 100755 --- a/gvlk/fetch.py +++ b/gvlk/fetch.py @@ -71,8 +71,7 @@ def combineGvlk(rawData: dict) -> dict: # merge multiple languages return result -gvlkData = combineGvlk({x: fetchGvlk(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)) - fp.write('\n') +if __name__ == '__main__': + gvlkData = combineGvlk({x: fetchGvlk(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') diff --git a/gvlk/release.py b/gvlk/release.py new file mode 100755 index 0000000..1476dd7 --- /dev/null +++ b/gvlk/release.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 + +import os +import json +import yaml + +Config = yaml.full_load(open('config.yml').read()) +AllGvlkData = json.loads(open('data.json').read()) + + +def dumpItem(lang: str, version: str) -> tuple[str, dict]: + gvlkData = AllGvlkData[version] + verName = gvlkData['name'][lang] + return verName, {x['name'][lang]: x['key'] for x in gvlkData['content']} + + +def dumpGroup(lang: str, versions: str) -> dict: + result = {} + for version in versions: + name, data = dumpItem(lang, version) + result[name] = data + return result + + +def dumpGvlk(lang: str) -> str: + return json.dumps({ + 'win': dumpGroup(lang, Config['win']), + 'win-server': dumpGroup(lang, Config['win-server']), + }, indent = 2, ensure_ascii = False) + + +def release(path: str) -> None: + for lang in Config['lang']: + with open(os.path.join(path, '%s.json' % lang), 'w') as fp: + fp.write(dumpGvlk(lang) + '\n') + + +if __name__ == '__main__': + if not os.path.exists(Config['path']): + os.makedirs(Config['path']) + release(Config['path'])