36 lines
774 B
Python
36 lines
774 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
import json
|
||
|
import os
|
||
|
from zipfile import ZipFile
|
||
|
|
||
|
modFiles = [
|
||
|
"info.json",
|
||
|
"changelog.txt",
|
||
|
"thumbnail.png",
|
||
|
"LICENSE.md",
|
||
|
|
||
|
"data-final-fixes.lua",
|
||
|
]
|
||
|
modFolders = [
|
||
|
"baseless",
|
||
|
"prototypes",
|
||
|
]
|
||
|
|
||
|
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}")
|