koro 2.0.1__tar.gz → 2.0.3rc1__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: koro
3
- Version: 2.0.1
3
+ Version: 2.0.3rc1
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
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = koro
3
- version = 2.0.1
3
+ version = 2.0.3rc1
4
4
  author = DigitalDetective47
5
5
  author_email = ninji2701@gmail.com
6
6
  description = Tools for manipulating levels made in Marble Saga: Kororinpa
@@ -18,6 +18,7 @@ classifiers =
18
18
  Programming Language :: Python :: 3 :: Only
19
19
  Programming Language :: Python :: 3.11
20
20
  Programming Language :: Python :: 3.12
21
+ Programming Language :: Python :: 3.13
21
22
  Topic :: File Formats
22
23
  Topic :: Games/Entertainment
23
24
  Typing :: Typed
@@ -31,6 +32,10 @@ python_requires = >=3.11
31
32
  [options.packages.find]
32
33
  where = src
33
34
 
35
+ [options.package_data]
36
+ koro =
37
+ py.typed
38
+
34
39
  [egg_info]
35
40
  tag_build =
36
41
  tag_date = 0
File without changes
@@ -5,7 +5,6 @@ from ..stage import Stage
5
5
  from .file import FileSlot
6
6
  from .xml import XmlSlot
7
7
 
8
-
9
8
  __all__ = ["BinSlot"]
10
9
 
11
10
 
@@ -1,12 +1,11 @@
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 TYPE_CHECKING, Annotated, Any, Literal, SupportsIndex
6
- from collections.abc import Mapping, Sequence
6
+ from typing import TYPE_CHECKING, Annotated, Any, Final, Literal, SupportsIndex
7
7
 
8
8
  from ..stage import Stage
9
-
10
9
  from . import Slot
11
10
  from .xml import XmlSlot
12
11
 
@@ -18,6 +17,8 @@ else:
18
17
 
19
18
  __all__ = ["EditorPage", "get_slots", "SaveSlot"]
20
19
 
20
+ _SIZE_LIMIT: Final[int] = 156864
21
+
21
22
 
22
23
  @unique
23
24
  class EditorPage(Enum):
@@ -30,7 +31,7 @@ class SaveSlot(Slot):
30
31
  __match_args__ = ("path", "page", "index")
31
32
  __slots__ = ("_offset", "_path")
32
33
 
33
- _offset: Literal[8, 156392, 312776, 469160]
34
+ _offset: Literal[8, 156872, 313736, 470600]
34
35
  _path: str | bytes
35
36
 
36
37
  def __init__(
@@ -45,8 +46,8 @@ class SaveSlot(Slot):
45
46
  ],
46
47
  ) -> None:
47
48
  index = ix(index) - 1
48
- if index in range(0, 20):
49
- self._offset = 8 + 156864 * (index & 3) # type: ignore[assignment]
49
+ if index in range(20):
50
+ self._offset = 8 + _SIZE_LIMIT * (index & 3) # type: ignore[assignment]
50
51
  self._path = join(path, f"ed{(index >> 2) + 5 * page.value:02}.dat") # type: ignore[arg-type]
51
52
  else:
52
53
  raise ValueError("index must be between 1 and 20")
@@ -72,7 +73,7 @@ class SaveSlot(Slot):
72
73
  def index(
73
74
  self,
74
75
  ) -> 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]
76
+ return (int(basename(self._path)[2:4]) % 5 >> 2 | self._offset // _SIZE_LIMIT) + 1 # type: ignore[return-value]
76
77
 
77
78
  def load(self) -> Stage | None:
78
79
  try:
@@ -82,11 +83,8 @@ class SaveSlot(Slot):
82
83
  block: bytearray = bytearray()
83
84
  while True:
84
85
  block.clear()
85
- block.extend(f.read1())
86
- print(block)
87
- if len(b.getbuffer()) + len(block) > 156864:
88
- del block[156864 - len(b.getbuffer()) :]
89
- if block[-1]:
86
+ block.extend(f.read1(_SIZE_LIMIT - len(b.getbuffer())))
87
+ if block and block[-1]:
90
88
  b.write(block)
91
89
  else:
92
90
  while block:
@@ -116,11 +114,13 @@ class SaveSlot(Slot):
116
114
 
117
115
  def save(self, data: Stage | None) -> None:
118
116
  binary: bytes = b"" if data is None else XmlSlot.serialize(data)
119
- if len(binary) > 156864:
117
+ if len(binary) > _SIZE_LIMIT:
120
118
  raise ValueError("serialized stage data is too large to save")
121
119
  try:
122
120
  with open(self._path, "xb") as f:
123
- f.write(bytes(638976))
121
+ f.write(
122
+ bytes(638976)
123
+ ) # Weird. Would expect this to be 627464 (8 + 4 * (_SIZE_LIMIT))
124
124
  if data is None:
125
125
  return
126
126
  except FileExistsError:
@@ -128,7 +128,7 @@ class SaveSlot(Slot):
128
128
  with open(self._path, "r+b") as f:
129
129
  f.seek(self._offset)
130
130
  f.write(binary)
131
- f.write(bytes(156864 - len(binary)))
131
+ f.write(bytes(_SIZE_LIMIT - len(binary)))
132
132
 
133
133
 
134
134
  def get_slots(save: StrOrBytesPath, /) -> Mapping[EditorPage, Sequence[SaveSlot]]:
@@ -1,7 +1,6 @@
1
1
  from enum import Enum, unique
2
2
  from typing import TypeAlias
3
3
 
4
-
5
4
  __all__ = ["DecorationModel", "DeviceModel", "Model", "PartModel"]
6
5
 
7
6
 
@@ -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, unique, Flag
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
1
+ Metadata-Version: 2.2
2
2
  Name: koro
3
- Version: 2.0.1
3
+ Version: 2.0.3rc1
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
@@ -3,6 +3,7 @@ README.md
3
3
  pyproject.toml
4
4
  setup.cfg
5
5
  src/koro/__init__.py
6
+ src/koro/py.typed
6
7
  src/koro.egg-info/PKG-INFO
7
8
  src/koro.egg-info/SOURCES.txt
8
9
  src/koro.egg-info/dependency_links.txt
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -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,
File without changes