diff --git a/.gitignore b/.gitignore index aef39b9..64ae49c 100644 --- a/.gitignore +++ b/.gitignore @@ -22,11 +22,13 @@ var/ wheels/ share/python-wheels/ *.egg-info/ -main.build/ -main.dist/ +*.build/ +*.dist/ +*.onefile-build/ .installed.cfg *.egg MANIFEST +*.bin # PyInstaller # Usually these files are written by a python script from a template @@ -164,6 +166,9 @@ cython_debug/ # Allows me to keep TMD files in my repository folder for testing without accidentally publishing them *.tmd *.wad +*.app +*.arc +*.ash out_prod/ remakewad.pl diff --git a/README.md b/README.md index 92f8727..2d8f9b1 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# libWiiPy-cli +# WiiPy A simple CLI tool that serves as a reference implementation of libWiiPy. diff --git a/modules/ash.py b/modules/ash.py new file mode 100644 index 0000000..85a055e --- /dev/null +++ b/modules/ash.py @@ -0,0 +1,23 @@ +# "ash.py" from WiiPy by NinjaCheetah +# https://github.com/NinjaCheetah/WiiPy + +import os +import libWiiPy + + +def decompress_ash(in_file: str, out_file: str = None): + if not os.path.isfile(in_file): + raise FileNotFoundError(in_file) + + ash_file = open(in_file, "rb") + ash_data = ash_file.read() + ash_file.close() + + ash_decompressed = libWiiPy.archive.decompress_ash(ash_data) + + if out_file is None: + out_file = in_file + ".arc" + + ash_out = open(out_file, "wb") + ash_out.write(ash_decompressed) + ash_out.close() diff --git a/modules/nus.py b/modules/nus.py index c5fb4da..9fd9cbd 100644 --- a/modules/nus.py +++ b/modules/nus.py @@ -1,5 +1,5 @@ -# "nus.py" from libWiiPy-cli by NinjaCheetah -# https://github.com/NinjaCheetah/libWiiPy-cli +# "nus.py" from WiiPy by NinjaCheetah +# https://github.com/NinjaCheetah/WiiPy import libWiiPy diff --git a/modules/u8.py b/modules/u8.py index a30dad7..fe89ea2 100644 --- a/modules/u8.py +++ b/modules/u8.py @@ -1,5 +1,5 @@ -# "u8.py" from libWiiPy-cli by NinjaCheetah -# https://github.com/NinjaCheetah/libWiiPy-cli +# "u8.py" from WiiPy by NinjaCheetah +# https://github.com/NinjaCheetah/WiiPy import os import libWiiPy diff --git a/modules/wad.py b/modules/wad.py index 7c95e19..903967e 100644 --- a/modules/wad.py +++ b/modules/wad.py @@ -1,5 +1,5 @@ -# "wad.py" from libWiiPy-cli by NinjaCheetah -# https://github.com/NinjaCheetah/libWiiPy-cli +# "wad.py" from WiiPy by NinjaCheetah +# https://github.com/NinjaCheetah/WiiPy import os import pathlib diff --git a/requirements.txt b/requirements.txt index 0dc1008..61850f0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ git+https://github.com/NinjaCheetah/libWiiPy +nuitka diff --git a/main.py b/wiipy.py similarity index 59% rename from main.py rename to wiipy.py index 0b196f0..3503493 100644 --- a/main.py +++ b/wiipy.py @@ -1,10 +1,11 @@ -# "main.py" from libWiiPy-cli by NinjaCheetah -# https://github.com/NinjaCheetah/libWiiPy-cli +# "wiipy.py" from WiiPy by NinjaCheetah +# https://github.com/NinjaCheetah/WiiPy import sys from modules.wad import * from modules.nus import * from modules.u8 import * +from modules.ash import * opts = [opt for opt in sys.argv[1:] if opt.startswith("-")] args = [arg for arg in sys.argv[1:] if not arg.startswith("-")] @@ -14,30 +15,47 @@ if __name__ == "__main__": if "-u" in opts: if len(args) == 3: extract_wad_to_folder(args[1], args[2]) - exit(0) + print("Success!") + sys.exit(0) if "-p" in opts: if len(args) == 3: pack_wad_from_folder(args[1], args[2]) - exit(0) + print("Success!") + sys.exit(0) raise SystemExit(f"Usage: {sys.argv[0]} WAD (-u | -p) ") elif "NUS" in args: if "-d" in opts: if len(args) == 2: download_title(args[1]) - exit(0) + print("Success!") + sys.exit(0) elif len(args) == 3: download_title(args[1], args[2]) - exit(0) + print("Success!") + sys.exit(0) raise SystemExit(f"Usage: {sys.argv[0]} NUS -d <Title Version (Optional)>") elif "U8" in args: if "-u" in opts: if len(args) == 3: extract_u8_to_folder(args[1], args[2]) - exit(0) + print("Success!") + sys.exit(0) elif "-p" in opts: if len(args) == 3: pack_u8_from_folder(args[1], args[2]) - exit(0) + print("Success!") + sys.exit(0) raise SystemExit(f"Usage: {sys.argv[0]} U8 (-u | -p) <input> <output>") + elif "ASH" in args: + if "-d" in opts: + if len(args) == 2: + decompress_ash(args[1]) + print("Success!") + sys.exit(0) + elif len(args) == 3: + decompress_ash(args[1], args[2]) + print("Success!") + sys.exit(0) + raise SystemExit(f"Usage: {sys.argv[0]} ASH -d <input> <output (Optional)>") else: raise SystemExit(f"Usage: {sys.argv[0]} WAD (-u | -p) <input> <output>")