ndspy.codeCompression
: Code Compression¶
ndspy.codeCompression
provides functions for the compression format used
for executable code files.
This compression format is sometimes unofficially known as “BLZ” (“backwards LZ”). It’s essentially the same as LZ10 compression, except that the file is decompressed in reverse, beginning at the end of the file. This allows for in-place decompression on the console.
Note
If you’re using the ndspy.code
module, compression is handled
automatically for you, and you shouldn’t need to use this module
explicitly.
See also
This module also includes a command-line interface.
- ndspy.codeCompression.compress(data[, isArm9=False])¶
Compress code data. This is the inverse of
decompress()
.
- ndspy.codeCompression.compressFromFile(filePath[, isArm9=False])¶
Load a filesystem file, and compress its contents. This is the inverse of
decompressToFile()
, and is a convenience function.- Parameters:
filePath (
str
or other path-like object) – The path to the file to open.isArm9 (bool) – Equivalent to the same parameter in the
compress()
function.
- Returns:
The compressed data.
- Return type:
- ndspy.codeCompression.compressToFile(data, filePath[, isArm9=False])¶
Compress data in the code compression format, and save it to a filesystem file. This is the inverse of
decompressFromFile()
, and is a convenience function.- Parameters:
data (bytes) – The data to compress.
filePath (
str
or other path-like object) – The path to the compressed file to save to.isArm9 (bool) – Equivalent to the same parameter in the
compress()
function.
- ndspy.codeCompression.decompress(data)¶
Decompress data that was compressed using code compression. This is the inverse of
compress()
.If the data does not seem to be compressed, it will be returned unmodified.
- ndspy.codeCompression.decompressFromFile(filePath)¶
Load a filesystem file that is compressed using code compression, and decompress it. This is the inverse of
compressToFile()
, and is a convenience function.
- ndspy.codeCompression.decompressToFile(data, filePath)¶
Decompress data that was compressed using code compression, and save it to a filesystem file. This is the inverse of
compressFromFile()
, and is a convenience function.
- ndspy.codeCompression.main([args])¶
This is the main function for this module’s command-line interface. This allows you to invoke the CLI programmatically, if you would like.