rpgmaker_mv_decoder package

Submodules

rpgmaker_mv_decoder.callbacks module

callback module

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

rpgmaker_mv_decoder.callbacks.show_version(ctx: click.core.Context, _, value: bool)[source]

show_version Click callback that displays the version number to the user

Args:

  • ctx (click.Context): context for options parsing

  • _ (_type_): ignored

  • value (bool): if true, show the version number and exit

rpgmaker_mv_decoder.callbacks.default_message_callback(level: rpgmaker_mv_decoder.messagetypes.MessageType, text: str) None[source]

default_message_callback default handling of messages

Args:

  • level (MessageType): What kind of message this is

  • text (str): What to display

rpgmaker_mv_decoder.callbacks.default_prompt_callback(message_type: rpgmaker_mv_decoder.messagetypes.MessageType = MessageType.DEBUG, message: str = '', responses: rpgmaker_mv_decoder.promptresponse.PromptResponse = PromptResponse.OK) bool[source]

default_prompt_callback default prompt

Args:

  • message_type (MessageType, optional): What type of message is this. Defaults to MessageType.DEBUG.

  • message (str, optional): What to display to the user. Defaults to "".

  • responses (PromptResponse, optional): What kind of repsones can the user give. Defaults to PromptResponse.OK.

Returns:

  • bool: True if the operation should run the action, False if the action should be skipped and None if the operation should be canceled.

class rpgmaker_mv_decoder.callbacks.Callbacks(progressbar_callback: typing.Callable[[click._termui_impl.ProgressBar], bool] = <function _default_progressbar_callback>, prompt_callback: typing.Callable[[rpgmaker_mv_decoder.messagetypes.MessageType, str, rpgmaker_mv_decoder.promptresponse.PromptResponse, bool], bool] = <function default_prompt_callback>, message_callback: typing.Callable[[rpgmaker_mv_decoder.messagetypes.MessageType, str, bool], None] = <function default_message_callback>)[source]

Bases: object

Callbacks encapsulates all the callbacks that might be used during execution

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 prompt: Callable[[rpgmaker_mv_decoder.messagetypes.MessageType, str, rpgmaker_mv_decoder.promptresponse.PromptResponse], bool]

prompt callback for asking the user a question

Returns:

  • Callable[[MessageType, str, PromptResponse], bool]: Function to call. First argument is the type of message, second is the message, third is the responses a user can give.

property message: Callable[[rpgmaker_mv_decoder.messagetypes.MessageType, str], None]

message callback for displaying a message to the user

Returns:

  • Callable[[MessageType, str], None]: Function to call. First argument is the type of message, second is the message

debug(text: str) None[source]

debug helper function for printing a debug message

Args:

  • self (Callbacks): callbacks object

  • text (str): text to display

info(text: str) None[source]

info helper function for printing a info message

Args:

  • self (Callbacks): callbacks object

  • text (str): text to display

warning(text: str) None[source]

warning helper function for printing a warning message

Args:

  • self (Callbacks): callbacks object

  • text (str): text to display

error(text: str) None[source]

error helper function for printing a error message

Args:

  • self (Callbacks): callbacks object

  • text (str): text to display

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.clickdisplay module

clickdisplay.py Simple helper class for the click progress bar

class rpgmaker_mv_decoder.clickdisplay.ClickDisplay(items: Iterable[pathlib.Path])[source]

Bases: object

ClickDisplay class for handling item display in click progress bar

setup(items: Iterable[pathlib.Path]) None[source]

setup figures out the width of the display needed for filenames

Args:

  • items (Iterable[Path]): Items being passed to the click progress bar

show_item(item: pathlib.Path) str[source]

show_item Pads the item name so it is shown correctly

This is used as a callback in the click progress bar

Args:

  • item (Path): Item to display

Returns:

  • str: String to append to progress info. Trailing spaces will be removed.

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.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.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.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.messagetypes module

messagetypes.py Types of messages for the UI

class rpgmaker_mv_decoder.messagetypes.MessageType(value)[source]

Bases: enum.Enum

MessageType Is a message debug, informational, warning or error

DEBUG = 1
INFO = 2
WARNING = 3
ERROR = 4
get_message_header() str[source]

get_message_header Header for this message type

Returns:

  • str: Header to prepend to the message

get_icon() str[source]

get_icon Returns the TK icon for this message type

Returns:

  • str: The TK icon for this message type

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.callbacks.Callbacks = <rpgmaker_mv_decoder.callbacks.Callbacks object>)[source]

Bases: abc.ABC

Handles a project and runs operations

property overwrite: bool

if files should be overwritten. None will cause the system to prompt the user.

property key: str

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

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.callbacks.Callbacks = <rpgmaker_mv_decoder.callbacks.Callbacks object>)[source]

Bases: rpgmaker_mv_decoder.project.Project

Handles a project and runs operations

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.

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

decode_file Takes a path and decodes a file

Args:

  • input_file (PurePath): File to read and modify

  • detect_type (bool): True means generate file extensions based on file contents

Returns:

  • bool: True if the operation should continue

decode(detect_type: bool) None[source]

decode Decodes a project

Args:

  • detect_type (bool): True means generate file extensions based on file contents

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.callbacks.Callbacks = <rpgmaker_mv_decoder.callbacks.Callbacks object>)[source]

Bases: rpgmaker_mv_decoder.project.Project

Class for encoding a project

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

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

encode_file Takes a path and encodes a file

Args:

  • input_file (PurePath): File to read and modify

Returns:

  • bool: True if the operation should continue

encode()[source]

encode Encodes the project

rpgmaker_mv_decoder.projectkeyfinder module

Class for decoding a project

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

Bases: rpgmaker_mv_decoder.project.Project

Handles finding a project key

property keys: Dict[str, int]

keys sorted dictionary of possible keys for this project

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

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 destination: pathlib.PurePath

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

property source: pathlib.PurePath

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

property output_directory: pathlib.PurePath

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

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

rpgmaker_mv_decoder.promptresponse module

promptresponse.py How the user can respond to a prompt

class rpgmaker_mv_decoder.promptresponse.PromptResponse(value)[source]

Bases: enum.Flag

PromptResponse types of responses the user can give

Show OK unless NO is also specified, which then OK should be YES

NONE = 0
OK = 1
YES = 1
NO = 2
SKIP = 4
YES_NO = 3
YES_SKIP = 5
CANCEL = 8
OK_CANCEL = 9
YES_NO_CANCEL = 11
YES_SKIP_CANCEL = 13
get_responses() List[str][source]

get_responses List of response that this enum represents

Returns:

  • List[str]: Possible user response to this message

get_messagebox_response() str[source]

get_messagebox_response gets the TK messagebox button set for this response

Returns:

  • str: The TK messagebox button set for this response. None if nothing matches

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