moat-lib-codec 0.4.11__tar.gz → 0.4.14__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.
- {moat_lib_codec-0.4.11/src/moat_lib_codec.egg-info → moat_lib_codec-0.4.14}/PKG-INFO +3 -3
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/debian/changelog +12 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/pyproject.toml +3 -3
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat/lib/codec/_base.py +29 -10
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat/lib/codec/_cbor.py +9 -8
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat/lib/codec/_moat_msgpack.py +1 -2
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat/lib/codec/cbor.py +5 -2
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat/lib/codec/errors.py +1 -1
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat/lib/codec/json.py +1 -1
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat/lib/codec/msgpack.py +8 -8
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat/lib/codec/yaml.py +7 -2
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14/src/moat_lib_codec.egg-info}/PKG-INFO +3 -3
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat_lib_codec.egg-info/requires.txt +2 -2
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/LICENSE.txt +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/Makefile +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/README.md +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/debian/.gitignore +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/debian/control +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/debian/py3dist-overrides +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/debian/rules +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/setup.cfg +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat/lib/codec/__init__.py +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat/lib/codec/_moat_cbor.py +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat/lib/codec/binary.py +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat/lib/codec/bool.py +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat/lib/codec/moat_cbor.py +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat/lib/codec/moat_kv.py +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat/lib/codec/moat_msgpack.py +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat/lib/codec/noop.py +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat/lib/codec/utf8.py +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat_lib_codec.egg-info/SOURCES.txt +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat_lib_codec.egg-info/dependency_links.txt +0 -0
- {moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat_lib_codec.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: moat-lib-codec
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.14
|
|
4
4
|
Summary: A simple command/stream multiplexer
|
|
5
5
|
Author-email: Matthias Urlichs <matthias@urlichs.de>
|
|
6
6
|
Maintainer-email: Matthias Urlichs <matthias@urlichs.de>
|
|
@@ -17,8 +17,8 @@ Requires-Python: >=3.8
|
|
|
17
17
|
Description-Content-Type: text/x-rst
|
|
18
18
|
License-File: LICENSE.txt
|
|
19
19
|
Requires-Dist: anyio~=4.2
|
|
20
|
-
Requires-Dist: moat-lib-rpc~=0.6.
|
|
20
|
+
Requires-Dist: moat-lib-rpc~=0.6.1
|
|
21
21
|
Requires-Dist: moat-lib-micro~=0.2.2
|
|
22
22
|
Requires-Dist: moat-lib-proxy~=0.1.1
|
|
23
|
-
Requires-Dist: moat-util~=0.62.
|
|
23
|
+
Requires-Dist: moat-util~=0.62.6
|
|
24
24
|
Dynamic: license-file
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
moat-lib-codec (0.4.14-1) unstable; urgency=medium
|
|
2
|
+
|
|
3
|
+
* New release for 26.0.1
|
|
4
|
+
|
|
5
|
+
-- Matthias Urlichs <matthias@urlichs.de> Wed, 18 Feb 2026 18:28:41 +0100
|
|
6
|
+
|
|
7
|
+
moat-lib-codec (0.4.14-1) unstable; urgency=medium
|
|
8
|
+
|
|
9
|
+
* New release for 26.0.1
|
|
10
|
+
|
|
11
|
+
-- Matthias Urlichs <matthias@urlichs.de> Wed, 18 Feb 2026 18:06:02 +0100
|
|
12
|
+
|
|
1
13
|
moat-lib-codec (0.4.11-2) unstable; urgency=medium
|
|
2
14
|
|
|
3
15
|
* New release for 26.0.0
|
|
@@ -13,10 +13,10 @@ classifiers = [
|
|
|
13
13
|
]
|
|
14
14
|
dependencies = [
|
|
15
15
|
"anyio ~= 4.2",
|
|
16
|
-
"moat-lib-rpc ~= 0.6.
|
|
16
|
+
"moat-lib-rpc ~= 0.6.1",
|
|
17
17
|
"moat-lib-micro ~= 0.2.2",
|
|
18
18
|
"moat-lib-proxy ~= 0.1.1",
|
|
19
|
-
"moat-util ~= 0.62.
|
|
19
|
+
"moat-util ~= 0.62.6",
|
|
20
20
|
]
|
|
21
21
|
keywords = ["MoaT"]
|
|
22
22
|
requires-python = ">=3.8"
|
|
@@ -25,7 +25,7 @@ maintainers = [{email = "matthias@urlichs.de",name = "Matthias Urlichs"}]
|
|
|
25
25
|
description='A simple command/stream multiplexer'
|
|
26
26
|
readme = "README.rst"
|
|
27
27
|
authors = [{email = "matthias@urlichs.de",name = "Matthias Urlichs"}]
|
|
28
|
-
version = "0.4.
|
|
28
|
+
version = "0.4.14"
|
|
29
29
|
|
|
30
30
|
[project.urls]
|
|
31
31
|
homepage = "https://m-o-a-t.org"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import TYPE_CHECKING
|
|
3
|
+
from typing import TYPE_CHECKING, overload
|
|
4
4
|
|
|
5
5
|
if TYPE_CHECKING:
|
|
6
6
|
from collections.abc import Callable
|
|
@@ -99,6 +99,11 @@ class Codec:
|
|
|
99
99
|
raise NotImplementedError
|
|
100
100
|
|
|
101
101
|
|
|
102
|
+
if TYPE_CHECKING:
|
|
103
|
+
EncoderFunc = Callable[[Codec, Any], ByteType | tuple[int, ByteType]]
|
|
104
|
+
DecoderFunc = Callable[[Codec, ByteType], Any]
|
|
105
|
+
|
|
106
|
+
|
|
102
107
|
class Extension:
|
|
103
108
|
def __init__(self):
|
|
104
109
|
self.enc: dict[type, tuple[int | None, Callable]] = {}
|
|
@@ -110,25 +115,39 @@ class Extension:
|
|
|
110
115
|
res.dec.update(self.dec)
|
|
111
116
|
return res
|
|
112
117
|
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
@overload
|
|
119
|
+
def encoder(self, key: int | None, cls: type) -> Callable[[EncoderFunc], EncoderFunc]: ...
|
|
120
|
+
|
|
121
|
+
@overload
|
|
122
|
+
def encoder(self, key: int | None, cls: type, fn: EncoderFunc) -> EncoderFunc: ...
|
|
123
|
+
|
|
124
|
+
def encoder(
|
|
125
|
+
self, key: int | None, cls: type, fn: EncoderFunc | None = None
|
|
126
|
+
) -> EncoderFunc | Callable[[EncoderFunc], EncoderFunc]:
|
|
127
|
+
def _enc(fn: EncoderFunc) -> EncoderFunc:
|
|
115
128
|
self.enc[cls] = (key, fn)
|
|
116
129
|
return fn
|
|
117
130
|
|
|
118
131
|
if fn is None:
|
|
119
132
|
return _enc
|
|
120
|
-
|
|
121
|
-
|
|
133
|
+
return _enc(fn)
|
|
134
|
+
|
|
135
|
+
@overload
|
|
136
|
+
def decoder(self, key: int | None) -> Callable[[DecoderFunc], DecoderFunc]: ...
|
|
137
|
+
|
|
138
|
+
@overload
|
|
139
|
+
def decoder(self, key: int | None, fn: DecoderFunc) -> DecoderFunc: ...
|
|
122
140
|
|
|
123
|
-
def decoder(
|
|
124
|
-
|
|
125
|
-
|
|
141
|
+
def decoder(
|
|
142
|
+
self, key: int | None, fn: DecoderFunc | None = None
|
|
143
|
+
) -> DecoderFunc | Callable[[DecoderFunc], DecoderFunc]:
|
|
144
|
+
def _dec(fn: DecoderFunc) -> DecoderFunc:
|
|
145
|
+
self.dec[key] = fn # type: ignore[index] # key can be None for catch-all
|
|
126
146
|
return fn
|
|
127
147
|
|
|
128
148
|
if fn is None:
|
|
129
149
|
return _dec
|
|
130
|
-
|
|
131
|
-
_dec(fn)
|
|
150
|
+
return _dec(fn)
|
|
132
151
|
|
|
133
152
|
def encode(self, codec: Codec, obj) -> tuple[int, ByteType]:
|
|
134
153
|
try:
|
|
@@ -13,10 +13,10 @@ from ._base import Codec as _Codec
|
|
|
13
13
|
from ._base import NoCodecError
|
|
14
14
|
|
|
15
15
|
# Typing
|
|
16
|
-
from typing import
|
|
16
|
+
from typing import TYPE_CHECKING, cast # isort:skip
|
|
17
17
|
|
|
18
18
|
try:
|
|
19
|
-
from micropython import const #
|
|
19
|
+
from micropython import const # type: ignore[import-not-found] # MicroPython only
|
|
20
20
|
except ImportError:
|
|
21
21
|
|
|
22
22
|
def const(x: int) -> int:
|
|
@@ -146,7 +146,7 @@ class Codec(_Codec):
|
|
|
146
146
|
if self._buffer:
|
|
147
147
|
raise RuntimeError("Codec is busy")
|
|
148
148
|
|
|
149
|
-
self._buffer = data
|
|
149
|
+
self._buffer = cast(bytes, data)
|
|
150
150
|
try:
|
|
151
151
|
res = self._dec_any()
|
|
152
152
|
# chop off the part we've read
|
|
@@ -161,12 +161,12 @@ class Codec(_Codec):
|
|
|
161
161
|
"Add additional input"
|
|
162
162
|
if self._buffer and self._buf_pos < len(self._buffer):
|
|
163
163
|
if self._buf_pos == 0:
|
|
164
|
-
self._buffer
|
|
164
|
+
self._buffer = cast(bytes, self._buffer + data)
|
|
165
165
|
return
|
|
166
|
-
data = self._buffer[self._buf_pos :] + data
|
|
167
|
-
|
|
166
|
+
data = cast(bytes, self._buffer[self._buf_pos :] + data)
|
|
167
|
+
if isinstance(data, memoryview):
|
|
168
168
|
data = bytearray(data)
|
|
169
|
-
self._buffer = data
|
|
169
|
+
self._buffer = cast(bytes, data)
|
|
170
170
|
self._buf_pos = 0
|
|
171
171
|
|
|
172
172
|
def unfeed(self, buf: VarByteType) -> int:
|
|
@@ -280,7 +280,8 @@ class Codec(_Codec):
|
|
|
280
280
|
self._enc_any(val)
|
|
281
281
|
|
|
282
282
|
def _w(self, d):
|
|
283
|
-
self._buf_out
|
|
283
|
+
assert self._buf_out is not None # set by encode() before calling _enc_any()
|
|
284
|
+
self._buf_out.extend(d)
|
|
284
285
|
|
|
285
286
|
def _enc_any(self, ob):
|
|
286
287
|
w = self._w
|
|
@@ -6,11 +6,14 @@ from __future__ import annotations
|
|
|
6
6
|
|
|
7
7
|
import struct
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
try:
|
|
10
|
+
from ruyaml import representer
|
|
11
|
+
except ImportError:
|
|
12
|
+
from ruamel.yaml import representer # fallback if ruyaml unavailable
|
|
10
13
|
|
|
11
14
|
from ._cbor import CBOR_TAG_CBOR_FILEHEADER, CBOR_TAG_CBOR_LEADER, Codec, Tag # noqa:F401
|
|
12
15
|
|
|
13
|
-
SafeRepresenter =
|
|
16
|
+
SafeRepresenter = representer.SafeRepresenter
|
|
14
17
|
|
|
15
18
|
|
|
16
19
|
def _tag_repr(dumper, data):
|
|
@@ -137,7 +137,7 @@ _TYPE_EXT = const(5)
|
|
|
137
137
|
DEFAULT_RECURSE_LIMIT = 20
|
|
138
138
|
|
|
139
139
|
|
|
140
|
-
_MSGPACK_HEADERS = {
|
|
140
|
+
_MSGPACK_HEADERS: dict[int, tuple[int, str] | tuple[int, str, int]] = {
|
|
141
141
|
0xC4: (1, "", _TYPE_BIN),
|
|
142
142
|
0xC5: (2, ">H", _TYPE_BIN),
|
|
143
143
|
0xC6: (4, ">I", _TYPE_BIN),
|
|
@@ -273,7 +273,7 @@ class Unpacker:
|
|
|
273
273
|
elif b == 0xC3:
|
|
274
274
|
obj = True
|
|
275
275
|
elif b <= 0xC6:
|
|
276
|
-
size, fmt, typ = _MSGPACK_HEADERS[b]
|
|
276
|
+
size, fmt, typ = _MSGPACK_HEADERS[b] # type: ignore[misc] # always 3-tuple for these keys
|
|
277
277
|
self._reserve(size)
|
|
278
278
|
if len(fmt) > 0:
|
|
279
279
|
n = struct.unpack_from(fmt, self._buffer, self._buf_pos)[0]
|
|
@@ -282,13 +282,13 @@ class Unpacker:
|
|
|
282
282
|
self._buf_pos += size
|
|
283
283
|
obj = self._read(n)
|
|
284
284
|
elif b <= 0xC9:
|
|
285
|
-
size, fmt, typ = _MSGPACK_HEADERS[b]
|
|
285
|
+
size, fmt, typ = _MSGPACK_HEADERS[b] # type: ignore[misc] # always 3-tuple for these keys
|
|
286
286
|
self._reserve(size)
|
|
287
287
|
L, n = struct.unpack_from(fmt, self._buffer, self._buf_pos)
|
|
288
288
|
self._buf_pos += size
|
|
289
289
|
obj = self._read(L)
|
|
290
290
|
elif b <= 0xD3:
|
|
291
|
-
size, fmt = _MSGPACK_HEADERS[b]
|
|
291
|
+
size, fmt = _MSGPACK_HEADERS[b] # type: ignore[misc] # always 2-tuple for these keys
|
|
292
292
|
self._reserve(size)
|
|
293
293
|
if len(fmt) > 0:
|
|
294
294
|
obj = struct.unpack_from(fmt, self._buffer, self._buf_pos)[0]
|
|
@@ -296,12 +296,12 @@ class Unpacker:
|
|
|
296
296
|
obj = self._buffer[self._buf_pos]
|
|
297
297
|
self._buf_pos += size
|
|
298
298
|
elif b <= 0xD8:
|
|
299
|
-
size, fmt, typ = _MSGPACK_HEADERS[b]
|
|
299
|
+
size, fmt, typ = _MSGPACK_HEADERS[b] # type: ignore[misc] # always 3-tuple for these keys
|
|
300
300
|
self._reserve(size + 1)
|
|
301
301
|
n, obj = struct.unpack_from(fmt, self._buffer, self._buf_pos)
|
|
302
302
|
self._buf_pos += size + 1
|
|
303
303
|
elif b <= 0xDB:
|
|
304
|
-
size, fmt, typ = _MSGPACK_HEADERS[b]
|
|
304
|
+
size, fmt, typ = _MSGPACK_HEADERS[b] # type: ignore[misc] # always 3-tuple for these keys
|
|
305
305
|
self._reserve(size)
|
|
306
306
|
if len(fmt) > 0:
|
|
307
307
|
(n,) = struct.unpack_from(fmt, self._buffer, self._buf_pos)
|
|
@@ -310,12 +310,12 @@ class Unpacker:
|
|
|
310
310
|
self._buf_pos += size
|
|
311
311
|
obj = self._read(n)
|
|
312
312
|
elif b <= 0xDD:
|
|
313
|
-
size, fmt, typ = _MSGPACK_HEADERS[b]
|
|
313
|
+
size, fmt, typ = _MSGPACK_HEADERS[b] # type: ignore[misc] # always 3-tuple for these keys
|
|
314
314
|
self._reserve(size)
|
|
315
315
|
(n,) = struct.unpack_from(fmt, self._buffer, self._buf_pos)
|
|
316
316
|
self._buf_pos += size
|
|
317
317
|
else: # if b <= 0xDF: # can't be anything else
|
|
318
|
-
size, fmt, typ = _MSGPACK_HEADERS[b]
|
|
318
|
+
size, fmt, typ = _MSGPACK_HEADERS[b] # type: ignore[misc] # always 3-tuple for these keys
|
|
319
319
|
self._reserve(size)
|
|
320
320
|
(n,) = struct.unpack_from(fmt, self._buffer, self._buf_pos)
|
|
321
321
|
self._buf_pos += size
|
|
@@ -6,6 +6,11 @@ from moat.util import yload, yprint
|
|
|
6
6
|
|
|
7
7
|
from ._base import Codec as _Codec
|
|
8
8
|
|
|
9
|
+
from typing import TYPE_CHECKING
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from ._base import ByteType
|
|
13
|
+
|
|
9
14
|
|
|
10
15
|
class Codec(_Codec):
|
|
11
16
|
"basic JSON codec"
|
|
@@ -24,8 +29,8 @@ class Codec(_Codec):
|
|
|
24
29
|
"basic decoder"
|
|
25
30
|
return yload(data.decode("utf-8"))
|
|
26
31
|
|
|
27
|
-
def feed(self,
|
|
28
|
-
self._buf.extend(
|
|
32
|
+
def feed(self, data: ByteType) -> None: # noqa: D102
|
|
33
|
+
self._buf.extend(data)
|
|
29
34
|
|
|
30
35
|
def __next__(self):
|
|
31
36
|
i = self._buf.find(b"\n---\n")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: moat-lib-codec
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.14
|
|
4
4
|
Summary: A simple command/stream multiplexer
|
|
5
5
|
Author-email: Matthias Urlichs <matthias@urlichs.de>
|
|
6
6
|
Maintainer-email: Matthias Urlichs <matthias@urlichs.de>
|
|
@@ -17,8 +17,8 @@ Requires-Python: >=3.8
|
|
|
17
17
|
Description-Content-Type: text/x-rst
|
|
18
18
|
License-File: LICENSE.txt
|
|
19
19
|
Requires-Dist: anyio~=4.2
|
|
20
|
-
Requires-Dist: moat-lib-rpc~=0.6.
|
|
20
|
+
Requires-Dist: moat-lib-rpc~=0.6.1
|
|
21
21
|
Requires-Dist: moat-lib-micro~=0.2.2
|
|
22
22
|
Requires-Dist: moat-lib-proxy~=0.1.1
|
|
23
|
-
Requires-Dist: moat-util~=0.62.
|
|
23
|
+
Requires-Dist: moat-util~=0.62.6
|
|
24
24
|
Dynamic: license-file
|
|
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
|
{moat_lib_codec-0.4.11 → moat_lib_codec-0.4.14}/src/moat_lib_codec.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|