koro 2.0.1__py3-none-any.whl → 2.0.3__py3-none-any.whl
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.
- koro/py.typed +0 -0
- koro/slot/bin.py +0 -1
- koro/slot/save.py +37 -25
- koro/slot/xml.py +1 -1
- koro/stage/model.py +0 -1
- koro/stage/part.py +1 -2
- {koro-2.0.1.dist-info → koro-2.0.3.dist-info}/METADATA +3 -2
- koro-2.0.3.dist-info/RECORD +15 -0
- {koro-2.0.1.dist-info → koro-2.0.3.dist-info}/WHEEL +1 -1
- koro-2.0.1.dist-info/RECORD +0 -14
- {koro-2.0.1.dist-info → koro-2.0.3.dist-info}/LICENSE +0 -0
- {koro-2.0.1.dist-info → koro-2.0.3.dist-info}/top_level.txt +0 -0
koro/py.typed
ADDED
File without changes
|
koro/slot/bin.py
CHANGED
koro/slot/save.py
CHANGED
@@ -1,12 +1,20 @@
|
|
1
|
+
from collections.abc import Mapping, Sequence
|
1
2
|
from enum import Enum, unique
|
2
3
|
from io import BytesIO
|
3
4
|
from operator import index as ix
|
4
5
|
from os.path import basename, dirname, join
|
5
|
-
from typing import
|
6
|
-
|
6
|
+
from typing import (
|
7
|
+
TYPE_CHECKING,
|
8
|
+
Annotated,
|
9
|
+
Any,
|
10
|
+
Final,
|
11
|
+
Literal,
|
12
|
+
SupportsIndex,
|
13
|
+
TypeAlias,
|
14
|
+
)
|
15
|
+
from warnings import warn
|
7
16
|
|
8
17
|
from ..stage import Stage
|
9
|
-
|
10
18
|
from . import Slot
|
11
19
|
from .xml import XmlSlot
|
12
20
|
|
@@ -16,7 +24,13 @@ else:
|
|
16
24
|
StrOrBytesPath = Any
|
17
25
|
|
18
26
|
|
19
|
-
__all__ = ["EditorPage", "
|
27
|
+
__all__ = ["EditorPage", "SaveSlot"]
|
28
|
+
|
29
|
+
_SIZE_LIMIT: Final[int] = 156864
|
30
|
+
|
31
|
+
SlotNumber: TypeAlias = Literal[
|
32
|
+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
|
33
|
+
]
|
20
34
|
|
21
35
|
|
22
36
|
@unique
|
@@ -30,23 +44,23 @@ class SaveSlot(Slot):
|
|
30
44
|
__match_args__ = ("path", "page", "index")
|
31
45
|
__slots__ = ("_offset", "_path")
|
32
46
|
|
33
|
-
_offset: Literal[8,
|
47
|
+
_offset: Literal[8, 156872, 313736, 470600]
|
34
48
|
_path: str | bytes
|
35
49
|
|
36
50
|
def __init__(
|
37
51
|
self,
|
38
52
|
path: StrOrBytesPath,
|
39
53
|
page: EditorPage,
|
40
|
-
index: Annotated[
|
41
|
-
SupportsIndex,
|
42
|
-
Literal[
|
43
|
-
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
|
44
|
-
],
|
45
|
-
],
|
54
|
+
index: Annotated[SupportsIndex, SlotNumber],
|
46
55
|
) -> None:
|
47
56
|
index = ix(index) - 1
|
48
|
-
if index in range(
|
49
|
-
|
57
|
+
if index in range(20):
|
58
|
+
if page == EditorPage.HUDSON and index in range(5):
|
59
|
+
warn(
|
60
|
+
"Modifications to Hudson 01-05 are ignored by the game. These stages are read from disc (/data/A19S00X.bin) and are empty by default when inspected with this library; writes made by this library will have no effect in-game.",
|
61
|
+
RuntimeWarning,
|
62
|
+
)
|
63
|
+
self._offset = 8 + _SIZE_LIMIT * (index & 3) # type: ignore[assignment]
|
50
64
|
self._path = join(path, f"ed{(index >> 2) + 5 * page.value:02}.dat") # type: ignore[arg-type]
|
51
65
|
else:
|
52
66
|
raise ValueError("index must be between 1 and 20")
|
@@ -69,10 +83,8 @@ class SaveSlot(Slot):
|
|
69
83
|
return hash((self._offset, self._path))
|
70
84
|
|
71
85
|
@property
|
72
|
-
def index(
|
73
|
-
self
|
74
|
-
) -> Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]:
|
75
|
-
return (int(basename(self._path)[2:4]) % 5 >> 2 | self._offset // 156864) + 1 # type: ignore[return-value]
|
86
|
+
def index(self) -> SlotNumber:
|
87
|
+
return (int(basename(self._path)[2:4]) % 5 >> 2 | self._offset // _SIZE_LIMIT) + 1 # type: ignore[return-value]
|
76
88
|
|
77
89
|
def load(self) -> Stage | None:
|
78
90
|
try:
|
@@ -82,11 +94,8 @@ class SaveSlot(Slot):
|
|
82
94
|
block: bytearray = bytearray()
|
83
95
|
while True:
|
84
96
|
block.clear()
|
85
|
-
block.extend(f.read1())
|
86
|
-
|
87
|
-
if len(b.getbuffer()) + len(block) > 156864:
|
88
|
-
del block[156864 - len(b.getbuffer()) :]
|
89
|
-
if block[-1]:
|
97
|
+
block.extend(f.read1(_SIZE_LIMIT - len(b.getbuffer())))
|
98
|
+
if block and block[-1]:
|
90
99
|
b.write(block)
|
91
100
|
else:
|
92
101
|
while block:
|
@@ -116,11 +125,13 @@ class SaveSlot(Slot):
|
|
116
125
|
|
117
126
|
def save(self, data: Stage | None) -> None:
|
118
127
|
binary: bytes = b"" if data is None else XmlSlot.serialize(data)
|
119
|
-
if len(binary) >
|
128
|
+
if len(binary) > _SIZE_LIMIT:
|
120
129
|
raise ValueError("serialized stage data is too large to save")
|
121
130
|
try:
|
122
131
|
with open(self._path, "xb") as f:
|
123
|
-
f.write(
|
132
|
+
f.write(
|
133
|
+
bytes(638976)
|
134
|
+
) # Weird. Would expect this to be 627464 (8 + 4 * (_SIZE_LIMIT))
|
124
135
|
if data is None:
|
125
136
|
return
|
126
137
|
except FileExistsError:
|
@@ -128,10 +139,11 @@ class SaveSlot(Slot):
|
|
128
139
|
with open(self._path, "r+b") as f:
|
129
140
|
f.seek(self._offset)
|
130
141
|
f.write(binary)
|
131
|
-
f.write(bytes(
|
142
|
+
f.write(bytes(_SIZE_LIMIT - len(binary)))
|
132
143
|
|
133
144
|
|
134
145
|
def get_slots(save: StrOrBytesPath, /) -> Mapping[EditorPage, Sequence[SaveSlot]]:
|
146
|
+
warn("function get_slots is deprecated", DeprecationWarning)
|
135
147
|
return {
|
136
148
|
page: tuple(SaveSlot(save, page, i) for i in range(1, 21))
|
137
149
|
for page in EditorPage
|
koro/slot/xml.py
CHANGED
@@ -12,7 +12,6 @@ from ..stage.part import (
|
|
12
12
|
BasePart,
|
13
13
|
BlinkingTile,
|
14
14
|
Bumper,
|
15
|
-
TextBox,
|
16
15
|
Cannon,
|
17
16
|
ConveyorBelt,
|
18
17
|
DashTunnel,
|
@@ -41,6 +40,7 @@ from ..stage.part import (
|
|
41
40
|
Speed,
|
42
41
|
Spring,
|
43
42
|
Start,
|
43
|
+
TextBox,
|
44
44
|
Thorn,
|
45
45
|
TimedDevice,
|
46
46
|
ToyTrain,
|
koro/stage/model.py
CHANGED
koro/stage/part.py
CHANGED
@@ -2,14 +2,13 @@ from __future__ import annotations
|
|
2
2
|
|
3
3
|
from abc import ABC, abstractmethod
|
4
4
|
from collections.abc import Iterable, MutableSequence
|
5
|
-
from enum import Enum,
|
5
|
+
from enum import Enum, Flag, unique
|
6
6
|
from operator import index
|
7
7
|
from sys import maxsize
|
8
8
|
from typing import Any, Final, Iterator, Literal, Self, SupportsIndex, overload
|
9
9
|
|
10
10
|
from .model import DecorationModel, DeviceModel, PartModel
|
11
11
|
|
12
|
-
|
13
12
|
__all__ = [
|
14
13
|
"Ant",
|
15
14
|
"BasePart",
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: koro
|
3
|
-
Version: 2.0.
|
3
|
+
Version: 2.0.3
|
4
4
|
Summary: Tools for manipulating levels made in Marble Saga: Kororinpa
|
5
5
|
Home-page: https://github.com/DigitalDetective47/koro
|
6
6
|
Author: DigitalDetective47
|
@@ -14,6 +14,7 @@ Classifier: Programming Language :: Python :: 3
|
|
14
14
|
Classifier: Programming Language :: Python :: 3 :: Only
|
15
15
|
Classifier: Programming Language :: Python :: 3.11
|
16
16
|
Classifier: Programming Language :: Python :: 3.12
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
17
18
|
Classifier: Topic :: File Formats
|
18
19
|
Classifier: Topic :: Games/Entertainment
|
19
20
|
Classifier: Typing :: Typed
|
@@ -0,0 +1,15 @@
|
|
1
|
+
koro/__init__.py,sha256=5_P8Q_L1Jo-bqMmzAK9tPKkmaSffbuid16voHwj8vys,192
|
2
|
+
koro/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
koro/slot/__init__.py,sha256=YJ3FjOF4o1Vo8joMpLTw27-Dwaoxq5YfQSER-ymJjFE,398
|
4
|
+
koro/slot/bin.py,sha256=Q0vKE5hTzGIGER-kpZnRykA3oAkXaK6uSAibS5Y1gBM,6527
|
5
|
+
koro/slot/file.py,sha256=QxBIXzFqzT6mzVZ5bq8xeR8vWfcNFpjHzsEEEqSzlz4,1656
|
6
|
+
koro/slot/save.py,sha256=bX9XW8qcNbd2qelwmHRoPMkQsQkL-ZAFx_F5sW-xWRE,4916
|
7
|
+
koro/slot/xml.py,sha256=TXogt9AlR93_jG63j2fv3AeEbkB4D8xp3CE1OI_2OjA,42147
|
8
|
+
koro/stage/__init__.py,sha256=xdMGSuI4fNDVSSHnuSwMyzFVyRxpcsSDxCl0EQWGJJM,2448
|
9
|
+
koro/stage/model.py,sha256=ZxmuKceendBqtVgmkJUYwbVzb7lGGhSoeCumgx3zwuQ,8428
|
10
|
+
koro/stage/part.py,sha256=QE7BFltmhm2pTQKjMrH0bxMj5h5Z8neOxxQEMd6RDGw,46885
|
11
|
+
koro-2.0.3.dist-info/LICENSE,sha256=awOCsWJ58m_2kBQwBUGWejVqZm6wuRtCL2hi9rfa0X4,1211
|
12
|
+
koro-2.0.3.dist-info/METADATA,sha256=ErAsRu5QewfmllvUwcsbuD-RUB2f6zJhNxzwiWdoZJA,4405
|
13
|
+
koro-2.0.3.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
14
|
+
koro-2.0.3.dist-info/top_level.txt,sha256=Msq6ssMwv56hnBQqwaTdJJkxM7x7BZ-3JfQbkepQAEY,5
|
15
|
+
koro-2.0.3.dist-info/RECORD,,
|
koro-2.0.1.dist-info/RECORD
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
koro/__init__.py,sha256=5_P8Q_L1Jo-bqMmzAK9tPKkmaSffbuid16voHwj8vys,192
|
2
|
-
koro/slot/__init__.py,sha256=YJ3FjOF4o1Vo8joMpLTw27-Dwaoxq5YfQSER-ymJjFE,398
|
3
|
-
koro/slot/bin.py,sha256=KaspkI3MZAoUTkVD8cSNP8sjn_ZI9U7qLt885zEK5C0,6528
|
4
|
-
koro/slot/file.py,sha256=QxBIXzFqzT6mzVZ5bq8xeR8vWfcNFpjHzsEEEqSzlz4,1656
|
5
|
-
koro/slot/save.py,sha256=qsY3_HGud0lFYWm3bOPWkq_LMEwj7DT_Z5pwVsnFfCA,4487
|
6
|
-
koro/slot/xml.py,sha256=evjIx-egPC43HqMCtBmmrjggyZ3xjERquqhaSIFQz0I,42147
|
7
|
-
koro/stage/__init__.py,sha256=xdMGSuI4fNDVSSHnuSwMyzFVyRxpcsSDxCl0EQWGJJM,2448
|
8
|
-
koro/stage/model.py,sha256=JNN6xT9o-47oTETu0_bWZpVBPOm2xkRgItKnREExbHo,8429
|
9
|
-
koro/stage/part.py,sha256=zo2uxQ6QccG3Ja7sos6IUiwnjvXJDFoWRcTbUVXeQ5E,46886
|
10
|
-
koro-2.0.1.dist-info/LICENSE,sha256=awOCsWJ58m_2kBQwBUGWejVqZm6wuRtCL2hi9rfa0X4,1211
|
11
|
-
koro-2.0.1.dist-info/METADATA,sha256=0hi9LZ1ReMnZQHdGe7MJXqYG5l-1UvF_-dAPKz79mGc,4354
|
12
|
-
koro-2.0.1.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
|
13
|
-
koro-2.0.1.dist-info/top_level.txt,sha256=Msq6ssMwv56hnBQqwaTdJJkxM7x7BZ-3JfQbkepQAEY,5
|
14
|
-
koro-2.0.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|