CleanFloor/package.py

34 lines
742 B
Python
Raw Normal View History

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