51 lines
1.1 KiB
Python
51 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Unpack LocalMods.zip into LocalMods/ and remove the archive."""
|
|
|
|
import os
|
|
import sys
|
|
import zipfile
|
|
|
|
BASE = os.path.dirname(os.path.abspath(__file__))
|
|
ZIP_PATH = os.path.join(BASE, "LocalMods.zip")
|
|
LOCALMODS_DIR = os.path.join(BASE, "LocalMods")
|
|
|
|
|
|
def log_ok(msg):
|
|
print(f"\033[92m✓\033[0m {msg}")
|
|
|
|
def log_info(msg):
|
|
print(f"• {msg}")
|
|
|
|
def log_warn(msg):
|
|
print(f"\033[93m⚠\033[0m {msg}")
|
|
|
|
def log_err(msg):
|
|
print(f"\033[91m✗\033[0m {msg}", file=sys.stderr)
|
|
|
|
|
|
def main():
|
|
print()
|
|
|
|
if not os.path.isfile(ZIP_PATH):
|
|
log_err(f"Not found: {ZIP_PATH}")
|
|
sys.exit(1)
|
|
|
|
log_info(f"Unzipping: {ZIP_PATH}")
|
|
with zipfile.ZipFile(ZIP_PATH, "r") as zf:
|
|
zf.extractall(BASE)
|
|
|
|
size = os.path.getsize(ZIP_PATH)
|
|
file_count = 0
|
|
for root, dirs, files in os.walk(LOCALMODS_DIR):
|
|
file_count += len(files)
|
|
|
|
log_ok(f"Extracted {file_count} files to {LOCALMODS_DIR}/")
|
|
|
|
os.remove(ZIP_PATH)
|
|
log_ok(f"Removed: {ZIP_PATH} ({size / 1024:.1f} KB freed)")
|
|
print()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|