BYML (Python)

Note

Because of the similarities between the C++ APIs and the Python APIs, only the former will be documented in detail. Please refer to the C++ documentation for more information.

  • v2, v3 and v4 binary documents are supported. Those versions are used by The Legend of Zelda: Breath of the Wild, Super Mario Odyssey and other recent games.

  • All parameter types are supported. This includes 64-bit node types that are used in Super Mario Odyssey.

  • Both little endian and big endian are supported. Switch assets are little-endian.

  • The YAML output is fully compatible with the pure Python byml-v2 library.

Quick usage

import oead
with open("ActorInfo.product.byml", "rb") as f:
   info = oead.Byml.from_binary(f.read())
# info is a dict-like
info["Actors"]
# Array(...)
info["Actors"][0]
# Hash({'bugMask': Byml(S32(1)), ..., 'name': Byml('EnemyFortressMgrTag'), ...})
info["Actors"][0]["name"]
# 'EnemyFortressMgrTag'

Reference

class oead.byml.Array

Lightweight list-like object. Can be cast to a list.

class oead.byml.Hash

Lightweight dict-like object. Can be cast to a dict.

oead.byml.from_binary(buffer: BytesLike) → Union[None, str, oead.Bytes, Array, Hash, bool, oead.S32, oead.F32, oead.U32, oead.S64, oead.U64, oead.F64]
Returns

An Array or a Hash.

See also oead::Byml::FromBinary

oead.byml.to_binary(data: handle, big_endian: bool, version: int = 2) → oead.Bytes

See also oead::Byml::ToBinary

oead.byml.from_text(yml_text: str) → Union[None, str, oead.Bytes, Array, Hash, bool, oead.S32, oead.F32, oead.U32, oead.S64, oead.U64, oead.F64]
Returns

An Array or a Hash.

See also oead::Byml::FromText

oead.byml.to_text(data: handle) → str

See also oead::Byml::ToText

Note

The following getters mirror the behaviour of Nintendo’s BYML library. Some of them will perform type conversions automatically. If value types are incorrect, a TypeError exception is thrown.

oead.byml.get_bool(data: handle) → bool
oead.byml.get_double(data: handle) → float
oead.byml.get_float(data: handle) → float
oead.byml.get_int(data: handle) → int
oead.byml.get_int64(data: handle) → int
oead.byml.get_string(data: handle) → str
oead.byml.get_uint(data: handle) → int
oead.byml.get_uint64(data: handle) → int