feat: automatically insert manifest into zips
This commit is contained in:
parent
9d4ec87525
commit
f32860d5f5
|
@ -1,5 +1,6 @@
|
|||
import yaml
|
||||
import json
|
||||
from zipfile import ZipFile, ZIP_DEFLATED
|
||||
|
||||
DEFAULTS = {
|
||||
'IsHide': False,
|
||||
|
@ -11,7 +12,26 @@ DUPLICATES = {
|
|||
'DownloadLinkInstall': ['DownloadLinkTesting', 'DownloadLinkUpdate'],
|
||||
}
|
||||
|
||||
TRIMMED_KEYS = [
|
||||
'Author',
|
||||
'Name',
|
||||
'Description',
|
||||
'InternalName',
|
||||
'AssemblyVersion',
|
||||
'RepoUrl',
|
||||
'ApplicableVersion',
|
||||
'Tags',
|
||||
'DalamudApiLevel',
|
||||
]
|
||||
|
||||
def main():
|
||||
# convert and write the master
|
||||
master = convert_master()
|
||||
|
||||
for plugin in master:
|
||||
insert_zip(plugin)
|
||||
|
||||
def convert_master():
|
||||
# load in the source
|
||||
with open('pluginmaster.yaml') as f:
|
||||
snake_master = yaml.load(f, Loader=yaml.SafeLoader)
|
||||
|
@ -35,6 +55,19 @@ def main():
|
|||
with open('pluginmaster.json', 'w') as f:
|
||||
json.dump(master, f, indent=4)
|
||||
|
||||
# return the master
|
||||
return master
|
||||
|
||||
def trim_manifest(plugin):
|
||||
return {k: plugin[k] for k in TRIMMED_KEYS if k in plugin}
|
||||
|
||||
def insert_zip(plugin):
|
||||
name = plugin['InternalName']
|
||||
|
||||
with ZipFile(f'plugins/{name}/latest.zip', mode='a', compression=ZIP_DEFLATED) as z:
|
||||
manifest = json.dumps(trim_manifest(plugin), indent=4)
|
||||
z.writestr(f'{name}.json', manifest)
|
||||
|
||||
def snake_to_pascal(name):
|
||||
return ''.join(part.title() for part in name.split('_'))
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user