rpgmaker_mv_decoder package

Submodules

rpgmaker_mv_decoder.callback module

callback module

Used to handle callbacks in a single object rather than multiple parameters

class rpgmaker_mv_decoder.callback.Callback(progressbar_callback: typing.Callable[[click._termui_impl.ProgressBar], bool] = <function _default_progressbar_callback>, overwrite_callback: typing.Callable[[str], bool] = <function _default_overwrite_callback>, error_callback: typing.Callable[[str], bool] = <function _default_error_callback>, warning_callback: typing.Callable[[str], bool] = <function _default_error_callback>)[source]

Bases: object

Callback encapsulates all the callbacks that might be used during execution

property error

error callback executed when an error occurs

Returns:

  • Callable[[str], bool]: Function to call. Error message should be specified via the parameter. If the user cancels the operation, this should return True

property overwrite

overwrite callback executed when a file is about to be overwitten

Returns:

  • Callable[[str], bool]: Function to call. Path to overwite should be specified as the string. If the function returns True the file should be overwritten. If the user cancels the operation this function should return None

property progressbar

progressbar callback for updating the progress of the operation

Returns:

  • Callable[[ProgressBar], bool]: Function to call. Progress data should be specified via the parameter. If the user cancels the operation, this should return True

property warning

warning callback executed when an warning occurs

Returns:

  • Callable[[str], bool]: Function to call. Warning message should be specified via the parameter. If the user cancels the operation, this should return True

rpgmaker_mv_decoder.cli_help module

Command line interface help classes

class rpgmaker_mv_decoder.cli_help.DecodeHelp(name: Optional[str], context_settings: Optional[Dict[str, Any]] = None, callback: Optional[Callable[[...], Any]] = None, params: Optional[List[click.core.Parameter]] = None, help: Optional[str] = None, epilog: Optional[str] = None, short_help: Optional[str] = None, options_metavar: Optional[str] = '[OPTIONS]', add_help_option: bool = True, no_args_is_help: bool = False, hidden: bool = False, deprecated: bool = False)[source]

Bases: click.core.Command

DecodeHelp help command override

Used to customize click help

format_help_text(ctx: click.core.Context, formatter: argparse.HelpFormatter)[source]

format_help_text formats the help

Override that adds arguments to the help properly

Args:

  • ctx (click.Context): context for click

  • formatter (HelpFormatter): formatter to use

class rpgmaker_mv_decoder.cli_help.EncodeHelp(name: Optional[str], context_settings: Optional[Dict[str, Any]] = None, callback: Optional[Callable[[...], Any]] = None, params: Optional[List[click.core.Parameter]] = None, help: Optional[str] = None, epilog: Optional[str] = None, short_help: Optional[str] = None, options_metavar: Optional[str] = '[OPTIONS]', add_help_option: bool = True, no_args_is_help: bool = False, hidden: bool = False, deprecated: bool = False)[source]

Bases: click.core.Command

EncodeHelp help command override

Used to customize click help

format_help_text(ctx: click.core.Context, formatter: argparse.HelpFormatter)[source]

format_help_text formats the help

Override that adds arguments to the help properly

Args:

  • ctx (click.Context): context for click

  • formatter (HelpFormatter): formatter to use

rpgmaker_mv_decoder.constants module

constants.py Constants for use by modules

rpgmaker_mv_decoder.exceptions module

Custom Exception Types

exception rpgmaker_mv_decoder.exceptions.Error(message: str)[source]

Bases: Exception

Base 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.Error

Exception raised for errors in the input. Based on Error class

Attributes:

  • expression: Input expression in which the error occurred

  • message: Explanation of the error

exception rpgmaker_mv_decoder.exceptions.NoValidFilesFound(message: str)[source]

Bases: rpgmaker_mv_decoder.exceptions.Error

Exception raised when no files are found. Based on Error class

Attributes:

  • message: Explanation of the error

exception rpgmaker_mv_decoder.exceptions.PNGHeaderError(expression: str, message: str)[source]

Bases: rpgmaker_mv_decoder.exceptions.FileFormatError

Exception raised for PNG images that when the IHDR section doesn’t checksum correctly.

Attributes:

  • expression – Input expression in which the error occurred

  • message – Explanation of the error

exception rpgmaker_mv_decoder.exceptions.RPGMakerHeaderError(expression: str, message: str)[source]

Bases: rpgmaker_mv_decoder.exceptions.FileFormatError

Exception raised for files missing the RPGMaker MV header.

Attributes:

  • expression – Input expression in which the error occurred

  • message – Explanation of the error

rpgmaker_mv_decoder.project module

project.py

Module for dealing with RPGMaker projects

class rpgmaker_mv_decoder.project.Project(source_path: typing.Optional[pathlib.PurePath] = None, destination_path: typing.Optional[pathlib.PurePath] = None, key: typing.Optional[str] = None, callbacks: rpgmaker_mv_decoder.callback.Callback = <rpgmaker_mv_decoder.callback.Callback object>)[source]

Bases: object

Handles a project and runs operations

property key: str

Gets the key or returns None if the key is not valid

warning(text: str) bool[source]

Warning Runs the warning callback

Args:

  • self (_T): Project object

  • text (str): Text for warning

Returns:

  • bool: True if the operation should continue

rpgmaker_mv_decoder.projectdecoder module

Class for decoding a project

class rpgmaker_mv_decoder.projectdecoder.ProjectDecoder(source: pathlib.PurePath, destination: pathlib.PurePath, key: str, callbacks: rpgmaker_mv_decoder.callback.Callback = <rpgmaker_mv_decoder.callback.Callback object>)[source]

Bases: rpgmaker_mv_decoder.project.Project

Handles a project and runs operations

decode(detect_type: bool)[source]

Not ready yet

decode_file(input_file: pathlib.PurePath, detect_type: bool) bool[source]

encode_file Takes a path and decodes a file

Args:

  • self (Project): Project object

  • input_file (PurePath): File to read and modify

Returns:

  • bool: True if the operation should continue

decode_header(file_header: bytes) bytes[source]

decode_header take a RPGMaker header and return the key or the actual file header

Check’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 header

Raises:

  • RPGMakerHeaderError: The header doesn’t match RPGMaker’s header

Returns:

  • bytes: If key was None, the key needed for a PNG image header, otherwise the decoded file header.

rpgmaker_mv_decoder.projectencoder module

Class for encoding a project

class rpgmaker_mv_decoder.projectencoder.ProjectEncoder(encoding_source: pathlib.PurePath, destination: pathlib.PurePath, key: str, encoding_callbacks: rpgmaker_mv_decoder.callback.Callback = <rpgmaker_mv_decoder.callback.Callback object>)[source]

Bases: rpgmaker_mv_decoder.project.Project

Class for encoding a project

encode()[source]

Not ready yet

encode_file(input_file: pathlib.PurePath) bool[source]

encode_file Takes a path and encodes a file

Args:

  • self (Project): Project object

  • input_file (PurePath): File to read and modify

Returns:

  • bool: True if the operation should continue

encode_header(file_header: bytes) bytes[source]

encode_header Encode a file with a key

Takes first 16 bytes and encodes per RPGMaker MV standard

Args:

  • file_header (bytes): 16 bytes

  • key (str): Key to encode with

Returns:

  • bytes: First 32 bytes of the encoded file

rpgmaker_mv_decoder.projectkeyfinder module

Class for decoding a project

class rpgmaker_mv_decoder.projectkeyfinder.ProjectKeyFinder(source: pathlib.PurePath, callbacks: rpgmaker_mv_decoder.callback.Callback = <rpgmaker_mv_decoder.callback.Callback object>)[source]

Bases: rpgmaker_mv_decoder.project.Project

Handles finding a project key

find_key() str[source]

find_key Check the path for PNG images and return the decoding key

Finds 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.

Raises:

  • NoValidFilesFound: If no valid PNG images are found

Returns:

  • str: Decoding key

property keys: Dict[str, int]

keys sorted dictionary of possible keys for this project

rpgmaker_mv_decoder.projectpaths module

project.py

Module for dealing with RPGMaker projects

class rpgmaker_mv_decoder.projectpaths.ProjectPaths(source: Optional[pathlib.PurePath] = None, destination: Optional[pathlib.PurePath] = None)[source]

Bases: object

Object that holds/validates project paths

property all_files: List[pathlib.Path]

all_files list of all files under the source path

Creates a sorted list of Path objects that are files under the source path, or None if the source path is unset

property destination: pathlib.PurePath

Gets the destination path to use or returns None if the destination path is not valid

property encoded_files: List[pathlib.Path]

encoded_files list of encoded files under the source path

Creates a sorted list of Path objects ending with “.rpgmvp” or “.rpgmvo under the source path, or None if the source path is unset

property encoded_images: List[pathlib.Path]

encoded_images list of encoded images under the source path

Creates a sorted list of Path objects ending with “.rpgmvp” under the source path, or None if the source path is unset

property output_directory: pathlib.PurePath

output_directory returns the name of the output directory including the project name

property source: pathlib.PurePath

Gets the source path to use or returns None if the source path is not valid

rpgmaker_mv_decoder.utils module

Utility functions

rpgmaker_mv_decoder.utils.int_xor(var: bytes, key: bytes) bytes[source]

int_xor integer xor

Runs XOR on 2 bytes streams (must be less than 64 bytes)

Args:

  • var (bytes): Input 1

  • key (bytes): Input 2

Returns:

  • bytes: XOR of input 1 and input 2

Module contents

Package for decoding RPGMaker MV/MZ encoded files