mirror of
https://github.com/NinjaCheetah/WiiPy.git
synced 2025-06-28 23:21:01 -04:00
Restructured command files, updated U8 command syntax to match others
This commit is contained in:
parent
33197c36f1
commit
ec7cb1063f
@ -1,4 +1,4 @@
|
||||
# "modules/archive/ash.py" from WiiPy by NinjaCheetah
|
||||
# "commands/archive/ash.py" from WiiPy by NinjaCheetah
|
||||
# https://github.com/NinjaCheetah/WiiPy
|
||||
|
||||
import pathlib
|
4
commands/archive/theme.py
Normal file
4
commands/archive/theme.py
Normal file
@ -0,0 +1,4 @@
|
||||
# "commands/archive/theme.py" from WiiPy by NinjaCheetah
|
||||
# https://github.com/NinjaCheetah/WiiPy
|
||||
|
||||
|
38
commands/archive/u8.py
Normal file
38
commands/archive/u8.py
Normal file
@ -0,0 +1,38 @@
|
||||
# "commands/archive/u8.py" from WiiPy by NinjaCheetah
|
||||
# https://github.com/NinjaCheetah/WiiPy
|
||||
|
||||
import pathlib
|
||||
import libWiiPy
|
||||
|
||||
|
||||
def handle_u8_pack(args):
|
||||
input_path = pathlib.Path(args.input)
|
||||
output_path = pathlib.Path(args.output)
|
||||
|
||||
try:
|
||||
u8_data = libWiiPy.archive.pack_u8(input_path)
|
||||
except ValueError:
|
||||
print("Error: Specified input file/folder does not exist!")
|
||||
return
|
||||
|
||||
out_file = open(output_path, "wb")
|
||||
out_file.write(u8_data)
|
||||
out_file.close()
|
||||
|
||||
print("U8 archive packed!")
|
||||
|
||||
|
||||
def handle_u8_unpack(args):
|
||||
input_path = pathlib.Path(args.input)
|
||||
output_path = pathlib.Path(args.output)
|
||||
|
||||
if not input_path.exists():
|
||||
raise FileNotFoundError(args.input)
|
||||
|
||||
u8_data = open(input_path, "rb").read()
|
||||
|
||||
# Output path is deliberately not checked in any way because libWiiPy already has those checks, and it's easier
|
||||
# and cleaner to only have one component doing all the checks.
|
||||
libWiiPy.archive.extract_u8(u8_data, str(output_path))
|
||||
|
||||
print("U8 archive unpacked!")
|
@ -1,4 +1,4 @@
|
||||
# "modules/nand/emunand.py" from WiiPy by NinjaCheetah
|
||||
# "commands/nand/emunand.py" from WiiPy by NinjaCheetah
|
||||
# https://github.com/NinjaCheetah/WiiPy
|
||||
|
||||
import pathlib
|
@ -1,4 +1,4 @@
|
||||
# "modules/nand/setting.py" from WiiPy by NinjaCheetah
|
||||
# "commands/nand/setting.py" from WiiPy by NinjaCheetah
|
||||
# https://github.com/NinjaCheetah/WiiPy
|
||||
|
||||
import pathlib
|
@ -1,4 +1,4 @@
|
||||
# "modules/title/ciosbuild.py" from WiiPy by NinjaCheetah
|
||||
# "commands/title/ciosbuild.py" from WiiPy by NinjaCheetah
|
||||
# https://github.com/NinjaCheetah/WiiPy
|
||||
|
||||
import io
|
||||
@ -59,7 +59,7 @@ def build_cios(args):
|
||||
|
||||
# We're ready to begin building the cIOS now. Find all the <content> tags that have <patch> tags, and then apply
|
||||
# the patches listed in them to the content.
|
||||
print("Patching existing modules...")
|
||||
print("Patching existing commands...")
|
||||
for content in target_base.findall("content"):
|
||||
patches = content.findall("patch")
|
||||
if patches:
|
||||
@ -91,8 +91,8 @@ def build_cios(args):
|
||||
# Set the content in the title to the newly-patched content, and set the type to normal.
|
||||
title.set_content(dec_content, content_index, content_type=libWiiPy.title.ContentType.NORMAL)
|
||||
|
||||
# Next phase of cIOS building is to add the required extra modules.
|
||||
print("Adding required additional modules...")
|
||||
# Next phase of cIOS building is to add the required extra commands.
|
||||
print("Adding required additional commands...")
|
||||
for content in target_base.findall("content"):
|
||||
target_module = content.get("module")
|
||||
if target_module is not None:
|
@ -1,4 +1,4 @@
|
||||
# "modules/title/fakesign.py" from WiiPy by NinjaCheetah
|
||||
# "commands/title/fakesign.py" from WiiPy by NinjaCheetah
|
||||
# https://github.com/NinjaCheetah/WiiPy
|
||||
|
||||
import pathlib
|
@ -1,4 +1,4 @@
|
||||
# "modules/title/info.py" from WiiPy by NinjaCheetah
|
||||
# "commands/title/info.py" from WiiPy by NinjaCheetah
|
||||
# https://github.com/NinjaCheetah/WiiPy
|
||||
|
||||
import pathlib
|
@ -1,4 +1,4 @@
|
||||
# "modules/title/iospatcher.py" from WiiPy by NinjaCheetah
|
||||
# "commands/title/iospatcher.py" from WiiPy by NinjaCheetah
|
||||
# https://github.com/NinjaCheetah/WiiPy
|
||||
|
||||
import pathlib
|
@ -1,4 +1,4 @@
|
||||
# "modules/title/nus.py" from WiiPy by NinjaCheetah
|
||||
# "commands/title/nus.py" from WiiPy by NinjaCheetah
|
||||
# https://github.com/NinjaCheetah/WiiPy
|
||||
|
||||
import hashlib
|
@ -1,4 +1,4 @@
|
||||
# "modules/title/tmd.py" from WiiPy by NinjaCheetah
|
||||
# "commands/title/tmd.py" from WiiPy by NinjaCheetah
|
||||
# https://github.com/NinjaCheetah/WiiPy
|
||||
|
||||
import pathlib
|
@ -1,4 +1,4 @@
|
||||
# "modules/title/wad.py" from WiiPy by NinjaCheetah
|
||||
# "commands/title/wad.py" from WiiPy by NinjaCheetah
|
||||
# https://github.com/NinjaCheetah/WiiPy
|
||||
|
||||
import pathlib
|
@ -1,37 +0,0 @@
|
||||
# "modules/archive/u8.py" from WiiPy by NinjaCheetah
|
||||
# https://github.com/NinjaCheetah/WiiPy
|
||||
|
||||
import pathlib
|
||||
import libWiiPy
|
||||
|
||||
|
||||
def handle_u8(args):
|
||||
input_path = pathlib.Path(args.input)
|
||||
output_path = pathlib.Path(args.output)
|
||||
|
||||
# Code for if the --pack argument was passed.
|
||||
if args.pack:
|
||||
try:
|
||||
u8_data = libWiiPy.archive.pack_u8(input_path)
|
||||
except ValueError:
|
||||
print("Error: Specified input file/folder does not exist!")
|
||||
return
|
||||
|
||||
out_file = open(output_path, "wb")
|
||||
out_file.write(u8_data)
|
||||
out_file.close()
|
||||
|
||||
print("U8 archive packed!")
|
||||
|
||||
# Code for if the --unpack argument was passed.
|
||||
elif args.unpack:
|
||||
if not input_path.exists():
|
||||
raise FileNotFoundError(args.input)
|
||||
|
||||
u8_data = open(input_path, "rb").read()
|
||||
|
||||
# Output path is deliberately not checked in any way because libWiiPy already has those checks, and it's easier
|
||||
# and cleaner to only have one component doing all the checks.
|
||||
libWiiPy.archive.extract_u8(u8_data, str(output_path))
|
||||
|
||||
print("U8 archive unpacked!")
|
@ -1,2 +1,2 @@
|
||||
git+https://github.com/NinjaCheetah/libWiiPy
|
||||
nuitka==2.3.11
|
||||
nuitka
|
||||
|
45
wiipy.py
45
wiipy.py
@ -4,17 +4,17 @@
|
||||
import argparse
|
||||
from importlib.metadata import version
|
||||
|
||||
from modules.archive.ash import *
|
||||
from modules.archive.u8 import *
|
||||
from modules.nand.emunand import *
|
||||
from modules.nand.setting import *
|
||||
from modules.title.ciosbuild import *
|
||||
from modules.title.fakesign import *
|
||||
from modules.title.info import *
|
||||
from modules.title.iospatcher import *
|
||||
from modules.title.nus import *
|
||||
from modules.title.tmd import *
|
||||
from modules.title.wad import *
|
||||
from commands.archive.ash import *
|
||||
from commands.archive.u8 import *
|
||||
from commands.nand.emunand import *
|
||||
from commands.nand.setting import *
|
||||
from commands.title.ciosbuild import *
|
||||
from commands.title.fakesign import *
|
||||
from commands.title.info import *
|
||||
from commands.title.iospatcher import *
|
||||
from commands.title.nus import *
|
||||
from commands.title.tmd import *
|
||||
from commands.title.wad import *
|
||||
|
||||
wiipy_ver = "1.4.0"
|
||||
|
||||
@ -64,8 +64,8 @@ if __name__ == "__main__":
|
||||
cios_parser.add_argument("output", metavar="OUT", type=str, help="file to output the cIOS to")
|
||||
cios_parser.add_argument("-c", "--cios-ver", metavar="CIOS", type=str,
|
||||
help="cIOS version from the map to build", required=True)
|
||||
cios_parser.add_argument("-m", "--modules", metavar="MODULES", type=str,
|
||||
help="directory to look for cIOS modules in (optional, defaults to current directory)")
|
||||
cios_parser.add_argument("-m", "--commands", metavar="MODULES", type=str,
|
||||
help="directory to look for cIOS commands in (optional, defaults to current directory)")
|
||||
cios_parser.add_argument("-s", "--slot", metavar="SLOT", type=int,
|
||||
help="slot that this cIOS will install to (optional, defaults to 249)", default=249)
|
||||
cios_parser.add_argument("-v", "--version", metavar="VERSION", type=int,
|
||||
@ -218,12 +218,19 @@ if __name__ == "__main__":
|
||||
# Argument parser for the U8 subcommand.
|
||||
u8_parser = subparsers.add_parser("u8", help="pack/unpack a U8 archive",
|
||||
description="pack/unpack a U8 archive")
|
||||
u8_parser.set_defaults(func=handle_u8)
|
||||
u8_group = u8_parser.add_mutually_exclusive_group(required=True)
|
||||
u8_group.add_argument("-p", "--pack", help="pack a directory to a U8 archive", action="store_true")
|
||||
u8_group.add_argument("-u", "--unpack", help="unpack a U8 archive to a directory", action="store_true")
|
||||
u8_parser.add_argument("input", metavar="IN", type=str, help="input file")
|
||||
u8_parser.add_argument("output", metavar="OUT", type=str, help="output file")
|
||||
u8_subparsers = u8_parser.add_subparsers(dest="subcommand", required=True)
|
||||
# Pack U8 subcommand.
|
||||
u8_pack_parser = u8_subparsers.add_parser("pack", help="pack a folder into U8 archive",
|
||||
description="pack a folder into U8 archive")
|
||||
u8_pack_parser.set_defaults(func=handle_u8_pack)
|
||||
u8_pack_parser.add_argument("input", metavar="IN", type=str, help="folder to pack")
|
||||
u8_pack_parser.add_argument("output", metavar="OUT", type=str, help="output U8 archive")
|
||||
# Unpack U8 subcommand.
|
||||
u8_unpack_parser = u8_subparsers.add_parser("unpack", help="unpack a U8 archive into a folder",
|
||||
description="unpack a U8 archive into a folder")
|
||||
u8_unpack_parser.set_defaults(func=handle_u8_unpack)
|
||||
u8_unpack_parser.add_argument("input", metavar="IN", type=str, help="U8 archive to unpack")
|
||||
u8_unpack_parser.add_argument("output", metavar="OUT", type=str, help="folder to output to")
|
||||
|
||||
# Argument parser for the WAD subcommand.
|
||||
wad_parser = subparsers.add_parser("wad", help="pack/unpack a WAD file",
|
||||
|
Loading…
x
Reference in New Issue
Block a user