MSBT editing in Python using MSYT
Reason this release was yanked:
problems
Project description
PyMsyt
MSBT editing in Python using MSYT
PyMsyt is a Python library wrapping the MSYT project in Rust. It uses a custom fork built as both a library and application. PyMsyt supports reading and writing MSBT files in binary, YAML, and JSON formats. Basic documentation:
API
Class pymsyt.Msbt
Class representing an MSBT file. This is just a thin wrapper over the Msyt
type from
the Rust MSYT project providing a few convenient methods for Python use. Note that
manipulating the contents of an MSBT in code can only be done staightforwardly by converting
with to_dict()
and from_dict()
. This class cannot be directly instantiated. Instead,
create it through static parsing methods. Example use:
from pymsyt import Msbt
data = open("ArmorHead.msbt", "rb").read()
msbt = Msbt.from_binary(data)
msyt_text = msbt.to_yaml() # Convert MSBT to MSYT YAML
json_text = msbt.to_json() # Convert MSBT to JSON
msbt_dict = msbt.to_dict() # Convert to an editable Python dictionary
for entry, contents in msbt_dict["entries"].items() # Iterate MSBT text entries
print(f"{entry} = {contents}")
msbt_dict["entries"]["Armor_999_Head"] = { # Adding a new text entry
"contents": [{"text":"Some new helmet"}]
}
open("ArmorHead.msbt", "wb").write( # Saving modified file
Msbt.from_dict(msbt_dict).to_binary(big_endian=True)
)
Methods defined here:
to_binary(big_endian: bool) -> bytes
Serializes this MSBT file to bytes.
to_dict() -> dict
Converts the MSBT contents to a Python dict.
to_json() -> str
Generates a JSON representation of this MSBT file.
to_yaml() -> str
Generates a YAML representation of this MSBT file.
from_binary(data: BytesLike) -> Msbt
Parses an MSBT file from a byteslike object
from_dict(dict: dict) -> Msbt
Parses an MSBT file from a Python dictionary.
from_json(json: str) -> Msbt
Parses an MSBT file from a JSON representation.
from_yaml(yaml: str) -> Msbt
Parses an MSBT file from a YAML representation.
Class pymsyt.MsytError
Generic exception thrown for all errors with this library.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for pymsyt-0.3.1-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfb18b6ce900ad030da83259eeaacb3df5e11c1c7709116202c1f6ab7a909403 |
|
MD5 | 3d1d458f30075b89c28d67db7d80838a |
|
BLAKE2b-256 | 92f98a8870e095a18d19ee781fba74dd11ed034c7a08c50807439e1007d2a069 |
Hashes for pymsyt-0.3.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8af453333e00b6c9385681906e659e08340e798ed269f2adc0ae96a52a967dd |
|
MD5 | e57c5da345c72885fd2a53fe1a333e01 |
|
BLAKE2b-256 | c86786619499a705cdba42e23b44389eaf21adb4d195f5ff35e5cb58d49d887e |
Hashes for pymsyt-0.3.1-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c839db3f6fbb55922b0a51f0ed021aed19bf1065d702fc549c321077e3191eb8 |
|
MD5 | 3da88a574a1e634a1f7cb648ed4c8a81 |
|
BLAKE2b-256 | de118f91502d721438ae469e249aa81abf58641ca6edf1304b75489dd8300db5 |
Hashes for pymsyt-0.3.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d15927566ffe504d1c8592a230fb0bcf3e15226e6052d3bfcf3c954cd8be172 |
|
MD5 | 033fa4fc374a35696edcc9b2ff1c6e52 |
|
BLAKE2b-256 | 5e13c54558bc7700989b87be97c44e98422dffb380dd534296bbb0e6a216c3fb |