rpgmaker_mv_decoder package
Submodules
rpgmaker_mv_decoder.exceptions module
Custom Exception Types
- exception rpgmaker_mv_decoder.exceptions.Error(message: str)[source]
Bases:
ExceptionBase class for exceptions in this module.
Attributes:
message: Explanation of the error
- exception rpgmaker_mv_decoder.exceptions.FileFormatError(expression: str, message: str)[source]
Bases:
rpgmaker_mv_decoder.exceptions.ErrorException raised for errors in the input. Based on
ErrorclassAttributes:
expression: Input expression in which the error occurredmessage: Explanation of the error
- exception rpgmaker_mv_decoder.exceptions.NoValidFilesFound(message: str)[source]
Bases:
rpgmaker_mv_decoder.exceptions.ErrorException raised when no files are found. Based on
ErrorclassAttributes:
message: Explanation of the error
- exception rpgmaker_mv_decoder.exceptions.PNGHeaderError(expression: str, message: str)[source]
Bases:
rpgmaker_mv_decoder.exceptions.FileFormatErrorException raised for PNG images that when the IHDR section doesn’t checksum correctly.
Attributes:
expression– Input expression in which the error occurredmessage– Explanation of the error
- exception rpgmaker_mv_decoder.exceptions.RPGMakerHeaderError(expression: str, message: str)[source]
Bases:
rpgmaker_mv_decoder.exceptions.FileFormatErrorException raised for files missing the RPGMaker MV header.
Attributes:
expression– Input expression in which the error occurredmessage– Explanation of the error
rpgmaker_mv_decoder.utils module
Utility functions
- rpgmaker_mv_decoder.utils.decode_files(src: str, dst: str, key: str, detect_type: bool, pb_cb: Optional[Callable[[tkinter.ttk.Progressbar], bool]] = None) None[source]
decode_filesDecodes the filesFinds all rpgmvp and rpgmvo files and decodes them
Args:
src(str): Source directory to searchdst(str): Destination directory for outputkey(str): Key to use for decodingdetect_type(bool): If file extensions should be detected from the file contentspb_cb(Callable[[click._termui_impl.Progressbar], bool], optional): Callback to display current progress. Call withNonewhen bar is complete. ReturnsTrueif the user has canceled the operation. Defaults toNone.
- rpgmaker_mv_decoder.utils.encode_files(src: str, dst: str, key: str, pb_cb: Optional[Callable[[tkinter.ttk.Progressbar], bool]] = None) None[source]
encode_filesEncodes the filesFinds all images and audio files and encodes them
Args:
src(str): Source directory to searchdst(str): Destination directory for outputkey(str): Key to use for encodingpb_cb(Callable[[click._termui_impl.Progressbar], bool], optional): Callback to display current progress. Call withNonewhen bar is complete. ReturnsTrueif the user has canceled the operation. Defaults toNone.
- rpgmaker_mv_decoder.utils.encode_header(file_header: bytes, key: str) bytes[source]
encode_headerEncode a file with a keyTakes first 16 bytes and encodes per RPGMaker MV standard
Args:
file_header(bytes): 16 byteskey(str): Key to encode with
Returns:
bytes: First 32 bytes of the encoded file
- rpgmaker_mv_decoder.utils.get_file_ext(data: bytes) str[source]
get_file_extReturns a file extension based on the file contentsUses libmagic to figure out the actual file type and place a proper extension on the file
Args:
data(bytes): File data
Raises:
FileFormatError: Error if the file type is unknown
Returns:
str: Extension for the file
- rpgmaker_mv_decoder.utils.guess_at_key(src: pathlib.Path, pb_cb: Optional[Callable[[tkinter.ttk.Progressbar], bool]] = None) str[source]
guess_at_keyCheck the path for PNG images and return the decoding keyFinds image files under the specified path and looks for a key to decode all the files. This can fail if only a small number (less than 3) of the .rpgmvp files are .png images.
Args:
src(Path): Path to search for .rpgmvp filespb_cb(Callable[[click._termui_impl.Progressbar], bool], optional): Callback to display current progress. Call withNonewhen bar is complete. ReturnsTrueif the user has canceled the operation. Defaults toNone.
Raises:
NoValidFilesFound: If no valid PNG images are found
Returns:
str: Decoding key
- rpgmaker_mv_decoder.utils.read_header_and_decode(file_header: bytes, png_ihdr_data: Optional[bytes] = None, key: str = '89504e470d0a1a0a0000000d49484452') bytes[source]
read_header_and_decodetake a RPGMaker header and return the key or the actual file headerCheck’s the first 16 bytes for the standard RPGMaker header, then drops them. Takes the next 16 bytes and either calculates the key based on a PNG image, or uses the specify key to decode. If png_ihdr_data is provided, checks that the IHDR section checksums correctly.
Args:
file_header(bytes): First 32 bytes from the file, 16 bytes are the RPGMaker header, followed by 16 bytes of the file headerpng_ihdr_data(bytes): Next 17 bytes for a PNG image to check the IHDR sectionkey(str): Key to use for xor, defaults to a standard PNG header if left unspecified
Raises:
RPGMakerHeaderError: The header doesn’t match RPGMaker’s headerPNGHeaderError: The PNG’s IHDR section doesn’t checksum correctly
Returns:
bytes: If key was None, the key needed for a PNG image header, otherwise the decoded file header.
Module contents
Package for decoding RPGMaker MV/MZ encoded files