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 userArgs:
ctx
(click.Context
): context for options parsing_
(_type_
): ignoredvalue
(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 messagesArgs:
level
(MessageType
): What kind of message this istext
(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 promptArgs:
message_type
(MessageType
, optional): What type of message is this. Defaults toMessageType.DEBUG
.message
(str
, optional): What to display to the user. Defaults to""
.responses
(PromptResponse
, optional): What kind of repsones can the user give. Defaults toPromptResponse.OK
.
Returns:
bool
:True
if the operation should run the action,False
if the action should be skipped andNone
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 operationReturns:
Callable[[ProgressBar], bool]
: Function to call. Progress data should be specified via the parameter. If the user cancels the operation, this should returnTrue
- property prompt: Callable[[rpgmaker_mv_decoder.messagetypes.MessageType, str, rpgmaker_mv_decoder.promptresponse.PromptResponse], bool]
prompt
callback for asking the user a questionReturns:
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 userReturns:
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 messageArgs:
self
(Callbacks
): callbacks objecttext
(str
): text to display
- info(text: str) None [source]
info
helper function for printing a info messageArgs:
self
(Callbacks
): callbacks objecttext
(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 overrideUsed to customize click help
- 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 overrideUsed to customize click help
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
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
classAttributes:
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
classAttributes:
expression
: Input expression in which the error occurredmessage
: 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 occurredmessage
– 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 occurredmessage
– 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
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 returnsNone
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 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 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 fileArgs:
input_file
(PurePath
): File to read and modifydetect_type
(bool
): True means generate file extensions based on file contents
Returns:
bool
: True if the operation should continue
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 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.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 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.
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 returnsNone
if thedestination
path is not valid
- property source: pathlib.PurePath
Gets the
source
path to use or returnsNone
if thesource
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 pathCreates a sorted list of
Path
objects ending with “.rpgmvp” under the source path, orNone
if the source path is unset
- property encoded_files: List[pathlib.Path]
encoded_files
list of encoded files under the source pathCreates a sorted list of
Path
objects ending with “.rpgmvp” or “.rpgmvo under the source path, orNone
if the source path is unset
- property all_files: List[pathlib.Path]
all_files
list of all files under the source pathCreates a sorted list of
Path
objects that are files under the source path, orNone
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 giveShow
OK
unlessNO
is also specified, which thenOK
should beYES
- 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
rpgmaker_mv_decoder.utils module
Utility functions
Module contents
Package for decoding RPGMaker MV/MZ encoded files