fmsl/package.py

37 lines
764 B
Python
Raw Normal View History

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