libWiiPy.archive package#
Submodules#
libWiiPy.archive.ash module#
- libWiiPy.archive.ash.decompress_ash(ash_data: bytes, sym_tree_bits: int = 9, dist_tree_bits: int = 11) bytes #
Decompresses the data of an ASH file and returns the decompressed data.
With the default parameters, this function can decompress ASH files found in the files of the Wii Menu and Animal Crossing: City Folk. Some ASH files, notably the ones found in the WiiWare title My Pokémon Ranch, require setting dist_tree_bits to 15 instead for a successful decompression. If an ASH file is failing to decompress with the default options, trying a dist_tree_bits value of 15 will likely fix it. No other leaf sizes are known to exist, however they might be out there.
- Parameters:
ash_data (bytes) – The data for the ASH file to decompress.
sym_tree_bits (int, option) – Number of bits for each leaf in the symbol tree. Defaults to 9.
dist_tree_bits (int, option) – Number of bits for each leaf in the distance tree. Defaults to 11.
libWiiPy.archive.u8 module#
- class libWiiPy.archive.u8.IMETHeader#
Bases:
object
An IMETHeader object that allows for parsing, editing, and generating an IMET header. These headers precede the data of a channel banner (00000000.app), and are used to store metadata about the banner and verify its data.
An IMET header is always 1,536 (0x600) bytes long.
- magic#
Magic number for the header, should be “IMD5”.
- Type:
str
- header_size#
Length of the M
- Type:
int
- imet_version#
Version of the IMET header. Normally always 3.
- Type:
int
- sizes#
The file sizes of icon.bin, banner.bin, and sound.bin.
- Type:
List[int]
- flag1#
Unknown.
- Type:
int
- channel_names#
The name of the channel this header is for in Japanese, English, German, French, Spanish, Italian, Dutch, Simplified Chinese, Traditional Chinese, and Korean, in that order.
- Type:
List[str]
- md5_hash#
MD5 sum of the entire header, with this field being all zeros during the hashing.
- Type:
bytes
- class LocalizedTitles(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
IntEnum
- TITLE_CHINESE_SIMPLIFIED = 7#
- TITLE_CHINESE_TRADITIONAL = 8#
- TITLE_DUTCH = 6#
- TITLE_ENGLISH = 1#
- TITLE_FRENCH = 3#
- TITLE_GERMAN = 2#
- TITLE_ITALIAN = 5#
- TITLE_JAPANESE = 0#
- TITLE_KOREAN = 9#
- TITLE_SPANISH = 4#
- create(sizes: List[int], channel_names: Tuple[int, str] | List[Tuple[int, str]]) None #
Create a new IMET header, specifying the sizes of the banner components and one or more localized channel names.
- Parameters:
sizes (List[int]) – The size in bytes of icon.bin, banner.bin, and sound.bin, in that order.
channel_names (Tuple(int, str), List[Tuple[int, str]]) – A pair or list of pairs of the target language and channel name for that language. Target languages are defined in LocalizedTitles.
- dump() bytes #
Dump the IMETHeader back into raw bytes.
- Returns:
The IMET header as bytes.
- Return type:
bytes
- get_channel_names(target_languages: int | List[int]) str | List[str] #
Get one or more channel names from the IMET header based on the specified languages.
- Parameters:
target_languages (int, List[int, str]) – One or more target languages. Target languages are defined in LocalizedTitles.
- Returns:
The channel name for the specified language, or a list of channel names in the same order as the specified languages.
- Return type:
str, List[str]
- load(imet_data: bytes) None #
Loads the raw data of an IMET header.
- Parameters:
imet_data (bytes) – The data for the IMET header to load.
- set_channel_names(channel_names: Tuple[int, str] | List[Tuple[int, str]]) None #
Specify one or more new channel names to set in the IMET header.
- Parameters:
channel_names (Tuple(int, str), List[Tuple[int, str]]) – A pair or list of pairs of the target language and channel name for that language. Target languages are defined in LocalizedTitles.
- class libWiiPy.archive.u8.U8Archive#
Bases:
object
A U8 object that allows for parsing and editing the contents of a U8 archive.
- u8_node_list#
A list of U8Node objects representing the nodes of the U8 archive.
- Type:
List[_U8Node]
- file_name_list#
A list of the names of the files in the U8 archive.
- Type:
List[str]
- file_data_list#
A list of file data for the files in the U8 archive; corresponds with file_name_list.
- Type:
List[bytes]
- header_size#
The size of the U8 archive header.
- Type:
int
- data_offset#
The offset of the data region of the U8 archive.
- Type:
int
- imet_header#
The IMET header of the U8 archive, if one exists. Otherwise, an empty IMETHeader object.
- Type:
- dump() bytes #
Dumps the U8Archive object into the raw data of a U8 archive.
- Returns:
The full U8 archive as bytes.
- Return type:
bytes
- load(u8_data: bytes) None #
Loads raw U8 data into a new U8 object. This allows for extracting the file and updating its contents.
- Parameters:
u8_data (bytes) – The data for the U8 file to load.
- libWiiPy.archive.u8.extract_u8(u8_data, output_folder) None #
Extracts the provided U8 archive file data into the provided output folder path. Note that the folder must not already exist to ensure that the output can correctly represent the file structure of the original U8 archive.
- Parameters:
u8_data (bytes) – The data for the U8 file to extract.
output_folder (str) – The path to a new folder to extract the archive to.
- libWiiPy.archive.u8.pack_u8(input_path, generate_imet=False, imet_titles: List[str] = None) bytes #
Packs the provided file or folder into a new U8 archive, and returns the raw file data for it.
To generate an IMET header for this U8 archive, the archive must contain the required banner files “icon.bin”, “banner.bin”, and “sound.bin”, because the sizes of these files are stored in the header.
- Parameters:
input_path – The path to the input file or folder.
generate_imet (bool, optional) – Whether an IMET header should be generated for this U8 archive or not. IMET headers are only used for channel banners (00000000.app), and required banner files must exist to generate this header. Defaults to False.
imet_titles (List[str], optional) – A list of the channel title in different languages for the IMET header. If only one item is provided, that item will be used for all entries in the header. Defaults to None, and is only used when generate_imet is True.
- Returns:
u8_archive – The data for the packed U8 archive.
- Return type:
bytes