Baseless/package.py

36 lines
774 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",
2024-09-15 08:33:31 +00:00
"LICENSE.md",
2020-04-26 03:48:47 +00:00
"data-final-fixes.lua",
2020-04-22 04:35:40 +00:00
]
modFolders = [
2024-09-15 08:33:31 +00:00
"baseless",
2020-04-22 04:35:40 +00:00
"prototypes",
]
with open("info.json") as file:
modInfo = json.load(file)
2024-09-15 08:33:31 +00:00
mod_name = modInfo["name"]
mod_version = modInfo["version"]
zipName = f"{mod_name}_{mod_version}"
2020-04-22 04:35:40 +00:00
2024-09-15 08:33:31 +00:00
with ZipFile(f"{zipName}.zip", 'w') as modZip:
2020-04-22 04:35:40 +00:00
for file in modFiles:
2024-09-15 08:33:31 +00:00
modZip.write(file, arcname=f"{zipName}/{file}")
2020-04-22 04:35:40 +00:00
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, '..'))
2024-09-15 08:33:31 +00:00
modZip.write(filePath, arcname=f"{zipName}/{archivePath}")