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.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 201eaf441f642a3b214aca76ec869dda6c9a49c851db2eb8d7d88dd7199f4376 |
|
MD5 | 549413d03c1c46037bbbe45552949512 |
|
BLAKE2b-256 | 52db33c32debac3968781b5add171183fca82d185cb20330ebbe4fde49ca4599 |
Hashes for pymsyt-0.3.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 074723847a9bdc96e58dbb9c13b8cff1c27e55602888e7243e85b2bb6abcba95 |
|
MD5 | 1d999fcb42490a3598a770632fbc14c2 |
|
BLAKE2b-256 | 4efce96314ddcf3897b1728ee1aba5b27ba91020846b8356bf79605d4fc4590e |
Hashes for pymsyt-0.3.0-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5befbcba4b08786e824ab1781910db254c45145d1712b2d4e3beec95aaa65b19 |
|
MD5 | 722f26090dc5462bbd51504f9492bc77 |
|
BLAKE2b-256 | a5551186e4cd4a8488481464d098801783ee8b4fac6a3e9d20def1fed85822bf |
Hashes for pymsyt-0.3.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c09bc1820908696f4780cac010a3d216e48bc85cd9a015282c929b7cb98217bb |
|
MD5 | 9978194f01eea434969d5fd658e06223 |
|
BLAKE2b-256 | cfdefedea5cd93c364b88a989e25844735e8fa4023f0427aec1233127211ac67 |