WiiPy/modules/ash.py
NinjaCheetah 5e1bf6ed4e
Rewrote entire source to be based around argparse
This does change a large amount of the syntax for using the CLI, but I think that's for the better. This new system also allows for having help pages for each sub command, making the tool a lot easier to use. It also allows for having more arguments available for each subcommand, which is especially necessary for the ASH module.
2024-06-24 00:41:07 -04:00

34 lines
926 B
Python

# "ash.py" from WiiPy by NinjaCheetah
# https://github.com/NinjaCheetah/WiiPy
import pathlib
import libWiiPy
def handle_ash(args):
input_path = pathlib.Path(args.input)
output_path = pathlib.Path(args.output)
if args.compress:
print("Compression is not implemented yet.")
elif args.decompress:
sym_tree_bits = args.sym_bits
dist_tree_bits = args.dist_bits
if not input_path.exists():
raise FileNotFoundError(input_path)
ash_file = open(input_path, "rb")
ash_data = ash_file.read()
ash_file.close()
ash_decompressed = libWiiPy.archive.decompress_ash(ash_data, sym_tree_bits=sym_tree_bits,
dist_tree_bits=dist_tree_bits)
ash_out = open(output_path, "wb")
ash_out.write(ash_decompressed)
ash_out.close()
print("ASH file decompressed!")