mirror of
https://github.com/NinjaCheetah/libWiiPy.git
synced 2026-02-27 22:15:27 -05:00
Rewrote all docs in Markdown instead of the default reST
This commit is contained in:
@@ -7,7 +7,7 @@ import io
|
||||
import sys
|
||||
import hashlib
|
||||
from typing import List
|
||||
from ..types import ContentRecord
|
||||
from ..types import _ContentRecord
|
||||
from .crypto import decrypt_content, encrypt_content
|
||||
|
||||
|
||||
@@ -18,20 +18,20 @@ class ContentRegion:
|
||||
|
||||
Attributes
|
||||
----------
|
||||
content_records : List[ContentRecord]
|
||||
content_records : List[_ContentRecord]
|
||||
The content records for the content stored in the region.
|
||||
num_contents : int
|
||||
The total number of contents stored in the region.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.content_records: List[ContentRecord] = []
|
||||
self.content_records: List[_ContentRecord] = []
|
||||
self.content_region_size: int = 0 # Size of the content region.
|
||||
self.num_contents: int = 0 # Number of contents in the content region.
|
||||
self.content_start_offsets: List[int] = [0] # The start offsets of each content in the content region.
|
||||
self.content_list: List[bytes] = []
|
||||
|
||||
def load(self, content_region: bytes, content_records: List[ContentRecord]) -> None:
|
||||
def load(self, content_region: bytes, content_records: List[_ContentRecord]) -> None:
|
||||
"""
|
||||
Loads the raw content region and builds a list of all the contents.
|
||||
|
||||
@@ -39,7 +39,7 @@ class ContentRegion:
|
||||
----------
|
||||
content_region : bytes
|
||||
The raw data for the content region being loaded.
|
||||
content_records : list[ContentRecord]
|
||||
content_records : list[_ContentRecord]
|
||||
A list of ContentRecord objects detailing all contents contained in the region.
|
||||
"""
|
||||
self.content_records = content_records
|
||||
@@ -256,7 +256,7 @@ class ContentRegion:
|
||||
if (index + 1) > num_contents + 1:
|
||||
raise ValueError("You are trying to set the content at position " + str(index) + ", but no content "
|
||||
"exists at position " + str(index - 1) + "!")
|
||||
self.content_records.append(ContentRecord(cid, index, content_type, content_size, content_hash))
|
||||
self.content_records.append(_ContentRecord(cid, index, content_type, content_size, content_hash))
|
||||
# If it does, reassign the values in it.
|
||||
else:
|
||||
self.content_records[index].content_id = cid
|
||||
|
||||
@@ -7,7 +7,7 @@ import io
|
||||
import binascii
|
||||
import struct
|
||||
from typing import List
|
||||
from ..types import ContentRecord
|
||||
from ..types import _ContentRecord
|
||||
|
||||
|
||||
class TMD:
|
||||
@@ -52,7 +52,7 @@ class TMD:
|
||||
self.title_version: int = 0 # The version of the associated title.
|
||||
self.num_contents: int = 0 # The number of contents contained in the associated title.
|
||||
self.boot_index: int = 0 # The content index that contains the bootable executable.
|
||||
self.content_records: List[ContentRecord] = []
|
||||
self.content_records: List[_ContentRecord] = []
|
||||
|
||||
def load(self, tmd: bytes) -> None:
|
||||
"""
|
||||
@@ -142,9 +142,9 @@ class TMD:
|
||||
tmd_data.seek(0x1E4 + (36 * content))
|
||||
content_record_hdr = struct.unpack(">LHH4x4s20s", tmd_data.read(36))
|
||||
self.content_records.append(
|
||||
ContentRecord(int(content_record_hdr[0]), int(content_record_hdr[1]),
|
||||
int(content_record_hdr[2]), int.from_bytes(content_record_hdr[3]),
|
||||
binascii.hexlify(content_record_hdr[4])))
|
||||
_ContentRecord(int(content_record_hdr[0]), int(content_record_hdr[1]),
|
||||
int(content_record_hdr[2]), int.from_bytes(content_record_hdr[3]),
|
||||
binascii.hexlify(content_record_hdr[4])))
|
||||
|
||||
def dump(self) -> bytes:
|
||||
"""
|
||||
@@ -310,7 +310,7 @@ class TMD:
|
||||
case _:
|
||||
return "Unknown"
|
||||
|
||||
def get_content_record(self, record) -> ContentRecord:
|
||||
def get_content_record(self, record) -> _ContentRecord:
|
||||
"""
|
||||
Gets the content record at the specified index.
|
||||
|
||||
@@ -321,7 +321,7 @@ class TMD:
|
||||
|
||||
Returns
|
||||
-------
|
||||
ContentRecord
|
||||
_ContentRecord
|
||||
A ContentRecord object containing the data in the content record.
|
||||
"""
|
||||
if record < self.num_contents:
|
||||
|
||||
@@ -4,7 +4,7 @@ from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class ContentRecord:
|
||||
class _ContentRecord:
|
||||
"""
|
||||
A content record object that contains the details of a content contained in a title. This information must match
|
||||
the content stored at the index in the record, or else the content will not decrypt properly, as the hash of the
|
||||
|
||||
Reference in New Issue
Block a user