Baseless/package.py

35 lines
776 B
Python
Raw Normal View History

2020-04-22 04:35:40 +00:00
#!/usr/bin/env python3
import json
import os
from zipfile import ZipFile
modFiles = [
"info.json",
"changelog.txt",
"thumbnail.png",
2020-04-26 03:48:47 +00:00
"data.lua",
"data-final-fixes.lua",
2020-04-22 04:35:40 +00:00
]
modFolders = [
2020-04-26 03:48:47 +00:00
"Baseless",
"Helpers",
2020-04-22 04:35:40 +00:00
"prototypes",
]
with open("info.json") as file:
modInfo = json.load(file)
zipName = "{}_{}".format(modInfo["name"], modInfo["version"])
with ZipFile("{}.zip".format(zipName), 'w') as modZip:
for file in modFiles:
modZip.write(file, arcname="{}/{}".format(zipName, file))
for folder in modFolders:
for root, dirs, files in os.walk(folder):
for file in files:
filePath = os.path.join(root, file)
archivePath = os.path.relpath(filePath, os.path.join(folder, '..'))
modZip.write(filePath, arcname="{}/{}".format(zipName, archivePath))