43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
import yaml
|
|
import json
|
|
|
|
DEFAULTS = {
|
|
'IsHide': False,
|
|
'IsTestingExclusive': False,
|
|
'ApplicableVersion': 'any',
|
|
}
|
|
|
|
DUPLICATES = {
|
|
'DownloadLinkInstall': ['DownloadLinkTesting', 'DownloadLinkUpdate'],
|
|
}
|
|
|
|
def main():
|
|
# load in the source
|
|
with open('pluginmaster.yaml') as f:
|
|
snake_master = yaml.load(f, Loader=yaml.SafeLoader)
|
|
# convert all keys to pascal case
|
|
master = [ { snake_to_pascal(k): v for k, v in item.items() } for item in snake_master ]
|
|
# generate the download link from the internal assembly name
|
|
for item in master:
|
|
item['DownloadLinkInstall'] = f'https://git.sr.ht/~jkcclemens/plugin_repo/blob/master/plugins/{item["InternalName"]}/latest.zip'
|
|
# add default values if missing
|
|
for k, v in DEFAULTS.items():
|
|
for item in master:
|
|
if k not in item:
|
|
item[k] = v
|
|
# duplicate keys as specified in DUPLICATES
|
|
for item in master:
|
|
for source, keys in DUPLICATES.items():
|
|
for k in keys:
|
|
if k not in item:
|
|
item[k] = item[source]
|
|
# write as pretty json
|
|
with open('pluginmaster.json', 'w') as f:
|
|
json.dump(master, f, indent=4)
|
|
|
|
def snake_to_pascal(name):
|
|
return ''.join(part.title() for part in name.split('_'))
|
|
|
|
if __name__ == '__main__':
|
|
main()
|