Switch from zip to tar, fix prep
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Unpack LocalMods.zip into LocalMods/ and remove the archive."""
|
||||
"""Unpack LocalMods.tar.gz into LocalMods/ and remove the archive."""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
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")
|
||||
TAR_PATH = os.path.join(BASE, "LocalMods.tar.gz")
|
||||
|
||||
|
||||
def log_ok(msg):
|
||||
@@ -16,9 +15,6 @@ def log_ok(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)
|
||||
|
||||
@@ -26,23 +22,17 @@ def log_err(msg):
|
||||
def main():
|
||||
print()
|
||||
|
||||
if not os.path.isfile(ZIP_PATH):
|
||||
log_err(f"Not found: {ZIP_PATH}")
|
||||
if not os.path.isfile(TAR_PATH):
|
||||
log_err(f"Not found: {TAR_PATH}")
|
||||
sys.exit(1)
|
||||
|
||||
log_info(f"Unzipping: {ZIP_PATH}")
|
||||
with zipfile.ZipFile(ZIP_PATH, "r") as zf:
|
||||
zf.extractall(BASE)
|
||||
log_info(f"Extracting: {TAR_PATH}")
|
||||
subprocess.run(["tar", "-xzf", TAR_PATH, "-C", BASE], check=True)
|
||||
|
||||
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)")
|
||||
size = os.path.getsize(TAR_PATH)
|
||||
os.remove(TAR_PATH)
|
||||
log_ok(f"Extracted to {os.path.join(BASE, 'LocalMods')}/")
|
||||
log_ok(f"Removed archive ({size / 1024:.1f} KB freed)")
|
||||
print()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user