PyLibMS 3.0.5__tar.gz → 3.0.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pylibms-3.0.5 → pylibms-3.0.7}/PKG-INFO +1 -1
- {pylibms-3.0.5 → pylibms-3.0.7}/PyLibMS.egg-info/PKG-INFO +1 -1
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/common/lms_datatype.py +21 -4
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/common/stream/fileinfo.py +10 -9
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/common/stream/hashtable.py +0 -1
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/fileio/encoding.py +1 -3
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/fileio/io.py +4 -4
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/definitions/field/io.py +1 -1
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/tag/io/tag_io.py +5 -3
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/tag/lms_tag.py +2 -5
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/project/msbpread.py +4 -2
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/config.py +11 -10
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/definitions/tags.py +1 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/presets/Super Mario 3D World + Bowsers Fury.yaml +3 -12
- {pylibms-3.0.5 → pylibms-3.0.7}/pyproject.toml +1 -1
- {pylibms-3.0.5 → pylibms-3.0.7}/LICENSE +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/MANIFEST.in +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/PyLibMS.egg-info/SOURCES.txt +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/PyLibMS.egg-info/dependency_links.txt +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/PyLibMS.egg-info/requires.txt +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/PyLibMS.egg-info/top_level.txt +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/README.md +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/__init__.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/common/__init__.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/common/lms_exceptions.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/common/lms_fileinfo.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/common/stream/section.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/__init__.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/definitions/__init__.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/definitions/field/__init__.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/definitions/field/lms_field.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/definitions/lms_messagetext.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/msbt.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/msbtentry.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/msbtio.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/section/__init__.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/section/atr1.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/section/tsy1.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/section/txt2.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/tag/__init__.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/tag/io/param_io.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/message/tag/lms_tagexceptions.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/project/__init__.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/project/definitions/__init__.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/project/definitions/attribute.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/project/definitions/color.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/project/definitions/style.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/project/definitions/tag.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/project/msbp.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/project/section/ali2.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/project/section/ati2.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/project/section/clr1.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/project/section/string.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/project/section/syl3.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/project/section/tag2.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/project/section/tgg2.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/project/section/tgp2.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/__init__.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/definitions/__init__.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/definitions/attribute.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/definitions/value.py +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/presets/Badge Arcade.yaml +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/presets/Brain Age Concentration Training.yaml +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/presets/Kirby Planet Robobot.yaml +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/presets/Super Mario 3D Land.yaml +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/presets/Super Mario Odyssey.yaml +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/presets/The Legend of Zelda Echos of Wisdom.yaml +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/presets/The Legend of Zelda a Link Between Worlds.yaml +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/presets/Tomodachi Life.yaml +0 -0
- {pylibms-3.0.5 → pylibms-3.0.7}/setup.cfg +0 -0
|
@@ -64,7 +64,7 @@ class LMS_DataType(Enum):
|
|
|
64
64
|
}[self]
|
|
65
65
|
|
|
66
66
|
@property
|
|
67
|
-
def stream_size(self):
|
|
67
|
+
def stream_size(self) -> int:
|
|
68
68
|
"""The size the datatype takes up in a stream."""
|
|
69
69
|
return {
|
|
70
70
|
LMS_DataType.UINT8: 1,
|
|
@@ -82,8 +82,25 @@ class LMS_DataType(Enum):
|
|
|
82
82
|
@classmethod
|
|
83
83
|
def from_string(cls, string: str):
|
|
84
84
|
"""Creates a LMS_Datatype enum value from it's string representation"""
|
|
85
|
-
|
|
86
|
-
if
|
|
87
|
-
return cls[
|
|
85
|
+
member = string.upper()
|
|
86
|
+
if member in cls.__members__:
|
|
87
|
+
return cls[member]
|
|
88
|
+
|
|
89
|
+
alias_map = {
|
|
90
|
+
"u8": "UINT8",
|
|
91
|
+
"u16": "UINT16",
|
|
92
|
+
"u32": "UINT32",
|
|
93
|
+
"i8": "INT8",
|
|
94
|
+
"i16": "INT16",
|
|
95
|
+
"i32": "INT32",
|
|
96
|
+
"f32": "FLOAT32",
|
|
97
|
+
"str": "STRING",
|
|
98
|
+
"bool": "BOOL",
|
|
99
|
+
"byte": "BYTES",
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
alias_member = alias_map.get(string.lower())
|
|
103
|
+
if alias_member is not None:
|
|
104
|
+
return cls[alias_member]
|
|
88
105
|
else:
|
|
89
106
|
raise ValueError(f"Unknown value of '{string}' was provided!")
|
|
@@ -3,6 +3,10 @@ from lms.common.lms_fileinfo import LMS_FileInfo
|
|
|
3
3
|
from lms.fileio.encoding import FileEncoding
|
|
4
4
|
from lms.fileio.io import FileReader, FileWriter
|
|
5
5
|
|
|
6
|
+
DATA_START = 0x20
|
|
7
|
+
LITTLE_ENDIAN_BOM = b"\xfe\xff"
|
|
8
|
+
BIG_ENDIAN_BOM = b"\xfe\xff"
|
|
9
|
+
|
|
6
10
|
|
|
7
11
|
def read_file_info(reader: FileReader, expected_magic: str) -> LMS_FileInfo:
|
|
8
12
|
magic = reader.read_string_len(8)
|
|
@@ -12,7 +16,7 @@ def read_file_info(reader: FileReader, expected_magic: str) -> LMS_FileInfo:
|
|
|
12
16
|
f"Invalid magic!' Expected {expected_magic}', got '{magic}'."
|
|
13
17
|
)
|
|
14
18
|
|
|
15
|
-
is_big_endian = reader.read_bytes(2) ==
|
|
19
|
+
is_big_endian = reader.read_bytes(2) == BIG_ENDIAN_BOM
|
|
16
20
|
reader.is_big_endian = is_big_endian
|
|
17
21
|
|
|
18
22
|
reader.skip(2)
|
|
@@ -30,8 +34,7 @@ def read_file_info(reader: FileReader, expected_magic: str) -> LMS_FileInfo:
|
|
|
30
34
|
if file_size != reader.tell():
|
|
31
35
|
raise lms_exceptions.LMS_MisalignedSizeError(f"Filesize is misaligned!")
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
reader.seek(0x20)
|
|
37
|
+
reader.seek(DATA_START)
|
|
35
38
|
|
|
36
39
|
return LMS_FileInfo(
|
|
37
40
|
is_big_endian,
|
|
@@ -42,15 +45,13 @@ def read_file_info(reader: FileReader, expected_magic: str) -> LMS_FileInfo:
|
|
|
42
45
|
|
|
43
46
|
|
|
44
47
|
def write_file_info(writer: FileWriter, magic: str, file_info: LMS_FileInfo) -> None:
|
|
45
|
-
"""Writes the file info to a stream.
|
|
46
|
-
|
|
47
|
-
:param writer: a Writer object.
|
|
48
|
-
:param file_info: the file_info object."""
|
|
49
48
|
writer.is_big_endian = file_info.is_big_endian
|
|
50
49
|
writer.encoding = file_info.encoding
|
|
51
50
|
|
|
52
51
|
writer.write_string(magic)
|
|
53
|
-
writer.write_bytes(
|
|
52
|
+
writer.write_bytes(
|
|
53
|
+
LITTLE_ENDIAN_BOM if not file_info.is_big_endian else BIG_ENDIAN_BOM
|
|
54
|
+
)
|
|
54
55
|
writer.write_bytes(b"\x00\x00")
|
|
55
56
|
|
|
56
57
|
writer.write_uint8(file_info.encoding.value)
|
|
@@ -60,4 +61,4 @@ def write_file_info(writer: FileWriter, magic: str, file_info: LMS_FileInfo) ->
|
|
|
60
61
|
writer.write_bytes(b"\x00\x00")
|
|
61
62
|
writer.write_bytes(b"\x00" * 4)
|
|
62
63
|
writer.write_bytes(b"\x00" * 10)
|
|
63
|
-
writer.seek(
|
|
64
|
+
writer.seek(DATA_START)
|
|
@@ -28,13 +28,13 @@ STRUCT_TYPES = {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
class FileReader:
|
|
31
|
+
class FileReader:
|
|
32
32
|
def __init__(self, data: BinaryIO | bytes, big_endian: bool = False):
|
|
33
33
|
if isinstance(data, bytes):
|
|
34
|
-
self._stream = BytesIO(data)
|
|
34
|
+
self._stream = BytesIO(data)
|
|
35
35
|
else:
|
|
36
36
|
data = cast(BinaryIO, data)
|
|
37
|
-
self._stream = BytesIO(data.read())
|
|
37
|
+
self._stream = BytesIO(data.read())
|
|
38
38
|
|
|
39
39
|
self.encoding = FileEncoding.UTF8
|
|
40
40
|
self.is_big_endian = big_endian
|
|
@@ -152,7 +152,7 @@ class FileWriter:
|
|
|
152
152
|
self.data.write(struct.pack(self._get_datatype("int16"), value))
|
|
153
153
|
|
|
154
154
|
def write_int32(self, value: int) -> None:
|
|
155
|
-
|
|
155
|
+
self.data.write(struct.pack(self._get_datatype("int32"), value))
|
|
156
156
|
|
|
157
157
|
def write_uint8(self, value: int) -> None:
|
|
158
158
|
self.data.write(struct.pack(self._get_datatype("uint8"), value))
|
|
@@ -34,7 +34,7 @@ def read_field(reader: FileReader, definition: ValueDefinition) -> LMS_Field:
|
|
|
34
34
|
return LMS_Field(value, definition)
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def write_field(writer: FileWriter, field: LMS_Field) -> None:
|
|
37
|
+
def write_field(writer: FileWriter, field: LMS_Field) -> None:
|
|
38
38
|
# All values are verifed before this point due to LMS_Field._verify_value
|
|
39
39
|
match field.datatype:
|
|
40
40
|
case LMS_DataType.UINT8:
|
|
@@ -38,7 +38,7 @@ def read_tag(
|
|
|
38
38
|
|
|
39
39
|
if is_closing:
|
|
40
40
|
return _read_decoded_tag(reader, definition, is_closing=True)
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
try:
|
|
43
43
|
tag = _read_decoded_tag(reader, definition)
|
|
44
44
|
except LMS_TagReadingError as e:
|
|
@@ -88,9 +88,11 @@ def _read_decoded_tag(
|
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
def write_tag(writer: FileWriter, tag: LMS_ControlTag) -> None:
|
|
91
|
-
start_indicator, close_indicator = get_tag_indicator(
|
|
91
|
+
start_indicator, close_indicator = get_tag_indicator(
|
|
92
|
+
writer.encoding, writer.is_big_endian
|
|
93
|
+
)
|
|
92
94
|
writer.write_bytes(start_indicator if not tag.is_closing else close_indicator)
|
|
93
|
-
|
|
95
|
+
|
|
94
96
|
writer.write_uint16(tag.group_id)
|
|
95
97
|
writer.write_uint16(tag.tag_index)
|
|
96
98
|
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import re
|
|
2
2
|
|
|
3
|
-
from lms.message.definitions.field.lms_field import (
|
|
4
|
-
|
|
5
|
-
LMS_FieldMap,
|
|
6
|
-
convert_string_to_type,
|
|
7
|
-
)
|
|
3
|
+
from lms.message.definitions.field.lms_field import (LMS_Field, LMS_FieldMap,
|
|
4
|
+
convert_string_to_type)
|
|
8
5
|
from lms.message.tag.lms_tagexceptions import LMS_InvalidTagFormatError
|
|
9
6
|
from lms.titleconfig.definitions.tags import TagConfig, TagDefinition
|
|
10
7
|
|
|
@@ -96,13 +96,15 @@ def read_msbp(stream: BinaryIO | None) -> MSBP:
|
|
|
96
96
|
definition.list_items = attribute_lists[definition.list_index]
|
|
97
97
|
|
|
98
98
|
if tag_groups is not None:
|
|
99
|
-
|
|
99
|
+
# There will always be parameter definitions alongside list items if there is any group definitions
|
|
100
100
|
tag_definitions = cast(list, tag_definitions)
|
|
101
101
|
tag_param_definitions = cast(list, tag_param_definitions)
|
|
102
102
|
list_items = cast(list, list_items)
|
|
103
103
|
|
|
104
104
|
for group in tag_groups:
|
|
105
|
-
group.set_all_definitions(
|
|
105
|
+
group.set_all_definitions(
|
|
106
|
+
tag_definitions, tag_param_definitions, list_items
|
|
107
|
+
)
|
|
106
108
|
|
|
107
109
|
file = MSBP(file_info, colors, attr_definitions, tag_groups, styles, source_list)
|
|
108
110
|
file.name = os.path.basename(stream.name).removesuffix(".msbp")
|
|
@@ -22,7 +22,9 @@ class TitleConfig:
|
|
|
22
22
|
]
|
|
23
23
|
|
|
24
24
|
def __init__(
|
|
25
|
-
self,
|
|
25
|
+
self,
|
|
26
|
+
attribute_configs: dict[str, AttributeConfig] | None = None,
|
|
27
|
+
tag_config: TagConfig | None = None,
|
|
26
28
|
):
|
|
27
29
|
self._attribute_configs = attribute_configs
|
|
28
30
|
self._tag_config = tag_config
|
|
@@ -112,33 +114,32 @@ class TitleConfig:
|
|
|
112
114
|
:param project: a MSBP object."""
|
|
113
115
|
config = {}
|
|
114
116
|
|
|
115
|
-
|
|
116
117
|
if project.tag_groups is not None:
|
|
117
118
|
config[TitleConfig.TAG_KEY] = {
|
|
118
119
|
"groups": {group.id: group.name for group in project.tag_groups},
|
|
119
120
|
"tags": [],
|
|
120
121
|
}
|
|
121
|
-
|
|
122
|
+
|
|
122
123
|
for group in project.tag_groups:
|
|
123
|
-
for tag_i,
|
|
124
|
+
for tag_i, tag_def in enumerate(group.tag_definitions):
|
|
124
125
|
|
|
125
126
|
definition = {
|
|
126
|
-
"name":
|
|
127
|
+
"name": tag_def.name,
|
|
127
128
|
"group_id": group.id,
|
|
128
129
|
"tag_index": tag_i,
|
|
129
130
|
"description": "",
|
|
130
131
|
"parameters": [],
|
|
131
132
|
}
|
|
132
133
|
|
|
133
|
-
for
|
|
134
|
+
for param_def in tag_def.param_info:
|
|
134
135
|
param_definition = {
|
|
135
|
-
"name":
|
|
136
|
+
"name": param_def.name,
|
|
136
137
|
"description": "",
|
|
137
|
-
"datatype":
|
|
138
|
+
"datatype": param_def.datatype.to_string(),
|
|
138
139
|
}
|
|
139
140
|
|
|
140
|
-
if
|
|
141
|
-
param_definition["list_items"] =
|
|
141
|
+
if param_def.datatype is LMS_DataType.LIST:
|
|
142
|
+
param_definition["list_items"] = param_def.list_items
|
|
142
143
|
|
|
143
144
|
definition["parameters"].append(param_definition)
|
|
144
145
|
|
{pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/presets/Super Mario 3D World + Bowsers Fury.yaml
RENAMED
|
@@ -35,18 +35,9 @@ tag_definitions:
|
|
|
35
35
|
tag_index: 3
|
|
36
36
|
description: 'Sets the color of the text'
|
|
37
37
|
parameters:
|
|
38
|
-
- name:
|
|
39
|
-
description: 'The
|
|
40
|
-
datatype:
|
|
41
|
-
- name: g
|
|
42
|
-
description: 'The green value.'
|
|
43
|
-
datatype: uint8
|
|
44
|
-
- name: b
|
|
45
|
-
description: 'the blue value.'
|
|
46
|
-
datatype: uint8
|
|
47
|
-
- name: a
|
|
48
|
-
description: 'The alpha value.'
|
|
49
|
-
datatype: uint8
|
|
38
|
+
- name: id
|
|
39
|
+
description: 'The color ID.'
|
|
40
|
+
datatype: int16
|
|
50
41
|
- name: PageBreak
|
|
51
42
|
group_id: 0
|
|
52
43
|
tag_index: 4
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "PyLibMS"
|
|
7
|
-
version = "3.0.
|
|
7
|
+
version = "3.0.7"
|
|
8
8
|
requires-python = ">=3.12"
|
|
9
9
|
description = "Python library built for the libMessageStudio (LMS) proprietary file formats from Nintendo. Supports MSBT, MSBP, and MSBF."
|
|
10
10
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/presets/Brain Age Concentration Training.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pylibms-3.0.5 → pylibms-3.0.7}/lms/titleconfig/presets/The Legend of Zelda Echos of Wisdom.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|