This commit is contained in:
Frank
2022-10-11 21:51:09 +02:00
parent 9f91de26ca
commit a315bc49af
+15 -9
View File
@@ -13,6 +13,7 @@ from pathlib import Path
from zipfile import ZipFile from zipfile import ZipFile
from shutil import rmtree, copy from shutil import rmtree, copy
import argparse import argparse
import filecmp
def update(f: Path, MooseLua: Path, Temp: Path): def update(f: Path, MooseLua: Path, Temp: Path):
""" """
@@ -26,15 +27,15 @@ def update(f: Path, MooseLua: Path, Temp: Path):
miz.extractall(Temp) miz.extractall(Temp)
# Folder where script is located # Folder where script is located
ScriptDir=Temp / "l10n/DEFAULT/" ScriptDir=Temp/"l10n/DEFAULT/"
# Check if that directory exists! GRP-600 - Respawn.miz was errorrous! # Check if that directory exists! GRP-600 - Respawn.miz was faulty
if not ScriptDir.is_dir(): if not ScriptDir.is_dir():
print(f"WARNING: {ScriptDir.name} does not exit!") print(f"WARNING: {ScriptDir.name} does not exit!")
return return
# Script file. # Script file.
ScriptFile=ScriptDir / Path(f.stem + ".lua") ScriptFile=ScriptDir/Path(f.stem + ".lua")
#Copy script file to directory. #Copy script file to directory.
if ScriptFile.is_file(): if ScriptFile.is_file():
@@ -43,13 +44,18 @@ def update(f: Path, MooseLua: Path, Temp: Path):
else: else:
print(f"Warning: expected script file {ScriptFile} does NOT exist in miz file!") print(f"Warning: expected script file {ScriptFile} does NOT exist in miz file!")
# Copy Moose.lua to temp dir. # Check if Moose.lua file is already.
copy(MooseLua, ScriptDir/"Moose.lua") if filecmp(MooseLua, ScriptDir/"Moose.lua"):
print(f"INFO: Moose.lua file is up-to-date ==> Nothing to do!")
else:
# Create new miz file # Copy Moose.lua to temp dir.
with ZipFile(f, mode='w') as archive: copy(MooseLua, ScriptDir/"Moose.lua")
for file_path in Temp.rglob("*"):
archive.write(file_path, arcname=file_path.relative_to(Temp)) # Create new miz file
with ZipFile(f, mode='w') as archive:
for file_path in Temp.rglob("*"):
archive.write(file_path, arcname=file_path.relative_to(Temp))
# Remove temp dir. # Remove temp dir.
try: try: