DarkNight/package.py

35 lines
755 B
Python
Raw Permalink Normal View History

2020-04-02 02:47:39 +00:00
#!/usr/bin/env python3
import json
import os
from zipfile import ZipFile
modFiles = [
"info.json",
"changelog.txt",
"thumbnail.png",
2024-09-15 17:41:45 +00:00
"LICENSE.md",
2020-04-02 02:47:39 +00:00
"data-updates.lua",
]
modFolders = [
"graphics",
]
with open("info.json") as file:
modInfo = json.load(file)
2024-09-15 17:41:45 +00:00
mod_name = modInfo["name"]
mod_version = modInfo["version"]
zipName = f"{mod_name}_{mod_version}"
2020-04-02 02:47:39 +00:00
2024-09-15 17:41:45 +00:00
with ZipFile(f"{zipName}.zip", 'w') as modZip:
2020-04-02 02:47:39 +00:00
for file in modFiles:
2024-09-15 17:41:45 +00:00
modZip.write(file, arcname=f"{zipName}/{file}")
2020-04-02 02:47:39 +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 17:41:45 +00:00
modZip.write(filePath, arcname=f"{zipName}/{archivePath}")