moat-lib-codec 0.4.18__tar.gz → 0.4.21__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.21/PKG-INFO +95 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/debian/changelog +42 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/debian/control +1 -2
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/pyproject.toml +6 -6
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/_base.py +8 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/_cbor.py +3 -1
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/_moat_msgpack.py +5 -3
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/msgpack.py +2 -1
- moat_lib_codec-0.4.21/src/moat/lib/codec/null.py +32 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/yaml.py +18 -4
- moat_lib_codec-0.4.21/src/moat_lib_codec.egg-info/PKG-INFO +95 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat_lib_codec.egg-info/SOURCES.txt +1 -0
- moat_lib_codec-0.4.21/src/moat_lib_codec.egg-info/requires.txt +5 -0
- moat_lib_codec-0.4.18/PKG-INFO +0 -24
- moat_lib_codec-0.4.18/src/moat_lib_codec.egg-info/PKG-INFO +0 -24
- moat_lib_codec-0.4.18/src/moat_lib_codec.egg-info/requires.txt +0 -5
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/LICENSE.txt +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/Makefile +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/README.md +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/debian/.gitignore +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/debian/py3dist-overrides +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/debian/rules +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/setup.cfg +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/__init__.py +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/_moat_cbor.py +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/binary.py +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/bool.py +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/cbor.py +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/errors.py +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/json.py +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/jsonvalstr.py +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/jsonvalue.py +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/moat_cbor.py +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/moat_kv.py +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/moat_msgpack.py +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/noop.py +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat/lib/codec/utf8.py +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat_lib_codec.egg-info/dependency_links.txt +0 -0
- {moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat_lib_codec.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: moat-lib-codec
|
|
3
|
+
Version: 0.4.21
|
|
4
|
+
Summary: A simple command/stream multiplexer
|
|
5
|
+
Author-email: Matthias Urlichs <matthias@urlichs.de>
|
|
6
|
+
Maintainer-email: Matthias Urlichs <matthias@urlichs.de>
|
|
7
|
+
Project-URL: homepage, https://m-o-a-t.org
|
|
8
|
+
Project-URL: repository, https://github.com/M-o-a-T/moat
|
|
9
|
+
Keywords: MoaT
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Framework :: AnyIO
|
|
12
|
+
Classifier: Framework :: Trio
|
|
13
|
+
Classifier: Framework :: AsyncIO
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE.txt
|
|
19
|
+
Requires-Dist: anyio~=4.2
|
|
20
|
+
Requires-Dist: moat-lib-rpc~=0.7.6
|
|
21
|
+
Requires-Dist: moat-lib-micro~=0.3.4
|
|
22
|
+
Requires-Dist: moat-lib-proxy~=0.1.3
|
|
23
|
+
Requires-Dist: moat-util~=0.64.0
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# The MoaT-Codec library
|
|
27
|
+
|
|
28
|
+
% start synopsis
|
|
29
|
+
% start main
|
|
30
|
+
|
|
31
|
+
This library packages various codecs used for MoaT protocols
|
|
32
|
+
in a way that's reason- and stream-able.
|
|
33
|
+
|
|
34
|
+
% end synopsis
|
|
35
|
+
|
|
36
|
+
## Supplied codecs
|
|
37
|
+
|
|
38
|
+
- CBOR
|
|
39
|
+
- msgpack
|
|
40
|
+
- no-op
|
|
41
|
+
- UTF-8
|
|
42
|
+
- JSON
|
|
43
|
+
- YAML
|
|
44
|
+
|
|
45
|
+
% end main
|
|
46
|
+
|
|
47
|
+
## Interface
|
|
48
|
+
|
|
49
|
+
### Codec
|
|
50
|
+
|
|
51
|
+
- encode(obj)
|
|
52
|
+
|
|
53
|
+
Encode the object to a bytestream.
|
|
54
|
+
|
|
55
|
+
- decode(bytes)
|
|
56
|
+
|
|
57
|
+
Decode the given bytes to a single object.
|
|
58
|
+
|
|
59
|
+
- feed(bytes, final=False)
|
|
60
|
+
|
|
61
|
+
Data stream. Returns an array of objects.
|
|
62
|
+
|
|
63
|
+
This method only exists when a sequence of encoded objects can be streamed,
|
|
64
|
+
i.e. contains built-in message boundaries.
|
|
65
|
+
|
|
66
|
+
if @final is `True`, raise an exception if there is an incomplete
|
|
67
|
+
object in the buffer after this call.
|
|
68
|
+
|
|
69
|
+
- getstate(), setstate(\*args)
|
|
70
|
+
|
|
71
|
+
A streaming decoder may store partially-decoded state (unprocessed
|
|
72
|
+
buffer) here.
|
|
73
|
+
|
|
74
|
+
The list of accepted objects is implementation dependent.
|
|
75
|
+
|
|
76
|
+
### Extension
|
|
77
|
+
|
|
78
|
+
Extension types vary by whether they carry binary data as in (msgpack), or
|
|
79
|
+
objects (as in cbor).
|
|
80
|
+
|
|
81
|
+
- binary (classvar): True if msgpack-style, False if cbor-style
|
|
82
|
+
|
|
83
|
+
- encoder(cls, key, fn)
|
|
84
|
+
|
|
85
|
+
Encode an object `obj` of type `type`. `fn(codec, obj)` must return
|
|
86
|
+
a bytestring / an encodeable object. If the registration key is `None`
|
|
87
|
+
the function must return a tuple with the key as first element.
|
|
88
|
+
|
|
89
|
+
- decoder(key, fn)
|
|
90
|
+
|
|
91
|
+
Add a decoder (key, data) to an object. `fn(codec, data)` is called with a
|
|
92
|
+
bytestring / a decoded object, and returns whatever has been encoded.
|
|
93
|
+
|
|
94
|
+
Extensions get the codec as their first argument. They can use it to store
|
|
95
|
+
data, e.g. references. The extension object is available as `codec.ext`.
|
|
@@ -1,3 +1,45 @@
|
|
|
1
|
+
moat-lib-codec (0.4.21-2) unstable; urgency=medium
|
|
2
|
+
|
|
3
|
+
* New release for 26.4.8
|
|
4
|
+
|
|
5
|
+
-- Matthias Urlichs <matthias@urlichs.de> Thu, 01 Oct 2026 11:15:17 +0200
|
|
6
|
+
|
|
7
|
+
moat-lib-codec (0.4.21-1) unstable; urgency=medium
|
|
8
|
+
|
|
9
|
+
* New release for 26.4.0
|
|
10
|
+
|
|
11
|
+
-- Matthias Urlichs <matthias@urlichs.de> Tue, 29 Sep 2026 16:47:21 +0200
|
|
12
|
+
|
|
13
|
+
moat-lib-codec (0.4.20-1) unstable; urgency=medium
|
|
14
|
+
|
|
15
|
+
* New release for 26.2.13
|
|
16
|
+
|
|
17
|
+
-- Matthias Urlichs <matthias@urlichs.de> Wed, 23 Sep 2026 15:11:05 +0200
|
|
18
|
+
|
|
19
|
+
moat-lib-codec (0.4.19-3) unstable; urgency=medium
|
|
20
|
+
|
|
21
|
+
* New release for 26.2.3
|
|
22
|
+
|
|
23
|
+
-- Matthias Urlichs <matthias@urlichs.de> Mon, 15 Jun 2026 17:44:22 +0200
|
|
24
|
+
|
|
25
|
+
moat-lib-codec (0.4.19-2) unstable; urgency=medium
|
|
26
|
+
|
|
27
|
+
* New release for 26.1.19
|
|
28
|
+
|
|
29
|
+
-- Matthias Urlichs <matthias@urlichs.de> Wed, 03 Jun 2026 20:27:16 +0200
|
|
30
|
+
|
|
31
|
+
moat-lib-codec (0.4.19-1) unstable; urgency=medium
|
|
32
|
+
|
|
33
|
+
* New release for 26.1.18
|
|
34
|
+
|
|
35
|
+
-- Matthias Urlichs <matthias@urlichs.de> Wed, 03 Jun 2026 18:49:14 +0200
|
|
36
|
+
|
|
37
|
+
moat-lib-codec (0.4.18-2) unstable; urgency=medium
|
|
38
|
+
|
|
39
|
+
* New release for 26.1.12
|
|
40
|
+
|
|
41
|
+
-- Matthias Urlichs <matthias@urlichs.de> Fri, 24 Apr 2026 15:33:49 +0200
|
|
42
|
+
|
|
1
43
|
moat-lib-codec (0.4.18-1) unstable; urgency=medium
|
|
2
44
|
|
|
3
45
|
* New release for 26.1.10
|
|
@@ -2,13 +2,12 @@ Source: moat-lib-codec
|
|
|
2
2
|
Maintainer: "Matthias Urlichs" <matthias@urlichs.de>
|
|
3
3
|
Section: python
|
|
4
4
|
Priority: optional
|
|
5
|
-
Build-Depends: dh-python, python3-all, debhelper (>= 13),
|
|
5
|
+
Build-Depends: dh-python, python3-all, debhelper (>= 13), debhelper-compat (= 13),
|
|
6
6
|
python3-setuptools,
|
|
7
7
|
python3-wheel,
|
|
8
8
|
Standards-Version: 3.9.6
|
|
9
9
|
Homepage: https://m-o-a-t.org
|
|
10
10
|
Testsuite: autopkgtest-pkg-pybuild
|
|
11
|
-
X-DH-Compat: 13
|
|
12
11
|
|
|
13
12
|
Package: python3-moat-lib-codec
|
|
14
13
|
Architecture: all
|
|
@@ -13,19 +13,19 @@ classifiers = [
|
|
|
13
13
|
]
|
|
14
14
|
dependencies = [
|
|
15
15
|
"anyio ~= 4.2",
|
|
16
|
-
"moat-lib-rpc ~= 0.7.
|
|
17
|
-
"moat-lib-micro ~= 0.3.
|
|
18
|
-
"moat-lib-proxy ~= 0.1.
|
|
19
|
-
"moat-util ~= 0.
|
|
16
|
+
"moat-lib-rpc ~= 0.7.6",
|
|
17
|
+
"moat-lib-micro ~= 0.3.4",
|
|
18
|
+
"moat-lib-proxy ~= 0.1.3",
|
|
19
|
+
"moat-util ~= 0.64.0",
|
|
20
20
|
]
|
|
21
21
|
keywords = ["MoaT"]
|
|
22
22
|
requires-python = ">=3.8"
|
|
23
23
|
name = "moat-lib-codec"
|
|
24
24
|
maintainers = [{email = "matthias@urlichs.de",name = "Matthias Urlichs"}]
|
|
25
25
|
description='A simple command/stream multiplexer'
|
|
26
|
-
readme = "README.
|
|
26
|
+
readme = "README.md"
|
|
27
27
|
authors = [{email = "matthias@urlichs.de",name = "Matthias Urlichs"}]
|
|
28
|
-
version = "0.4.
|
|
28
|
+
version = "0.4.21"
|
|
29
29
|
|
|
30
30
|
[project.urls]
|
|
31
31
|
homepage = "https://m-o-a-t.org"
|
|
@@ -90,6 +90,14 @@ class Codec:
|
|
|
90
90
|
"""
|
|
91
91
|
raise NotImplementedError
|
|
92
92
|
|
|
93
|
+
def eof(self) -> None:
|
|
94
|
+
"""
|
|
95
|
+
Signal that no more data will be fed.
|
|
96
|
+
|
|
97
|
+
Afterwards, iterating returns any objects still in the buffer
|
|
98
|
+
that are not terminated explicitly. The default does nothing.
|
|
99
|
+
"""
|
|
100
|
+
|
|
93
101
|
def unfeed(self, buf: VarByteType) -> int:
|
|
94
102
|
"""
|
|
95
103
|
Take from the front of the decoder's buffer.
|
|
@@ -13,6 +13,8 @@ from moat.util import OutOfData
|
|
|
13
13
|
from ._base import Codec as _Codec
|
|
14
14
|
from ._base import NoCodecError
|
|
15
15
|
|
|
16
|
+
from collections.abc import Mapping
|
|
17
|
+
|
|
16
18
|
# Typing
|
|
17
19
|
from typing import TYPE_CHECKING, cast # isort:skip
|
|
18
20
|
|
|
@@ -297,7 +299,7 @@ class Codec(_Codec):
|
|
|
297
299
|
elif isinstance(ob, (list, tuple)):
|
|
298
300
|
self._enc_array(ob)
|
|
299
301
|
# TODO: accept other enumerables and emit a variable length array
|
|
300
|
-
elif isinstance(ob,
|
|
302
|
+
elif isinstance(ob, Mapping):
|
|
301
303
|
self._enc_dict(ob)
|
|
302
304
|
elif isinstance(ob, float):
|
|
303
305
|
self._enc_float(ob)
|
|
@@ -12,11 +12,13 @@ Extension types defined here:
|
|
|
12
12
|
from __future__ import annotations
|
|
13
13
|
|
|
14
14
|
from moat.lib.path import Path
|
|
15
|
-
from moat.lib.proxy import DProxy, Proxy,
|
|
15
|
+
from moat.lib.proxy import DProxy, Proxy, _lookup_proxy, get_proxy, obj2name, unwrap_obj, wrap_obj
|
|
16
16
|
|
|
17
17
|
from . import Extension
|
|
18
18
|
from . import msgpack as _msgpack
|
|
19
19
|
|
|
20
|
+
from collections.abc import Mapping
|
|
21
|
+
|
|
20
22
|
__all__ = ["Codec", "std_ext"]
|
|
21
23
|
|
|
22
24
|
|
|
@@ -34,7 +36,7 @@ class Codec(_msgpack.Codec):
|
|
|
34
36
|
@std_ext.encoder(5, DProxy)
|
|
35
37
|
def _enc_dproxy(codec, obj):
|
|
36
38
|
a = obj.a[:]
|
|
37
|
-
if obj.k or (a and isinstance(a[-1],
|
|
39
|
+
if obj.k or (a and isinstance(a[-1], Mapping)):
|
|
38
40
|
a.append(obj.k)
|
|
39
41
|
return codec.encode(obj.name) + b"".join(codec.encode(x) for x in a)
|
|
40
42
|
|
|
@@ -103,7 +105,7 @@ def _dec_proxy(codec, data):
|
|
|
103
105
|
except UnicodeError:
|
|
104
106
|
n = str(data)
|
|
105
107
|
try:
|
|
106
|
-
return
|
|
108
|
+
return _lookup_proxy(n)
|
|
107
109
|
except KeyError:
|
|
108
110
|
return Proxy(n)
|
|
109
111
|
|
|
@@ -27,6 +27,7 @@ from moat.lib.micro import byte2utf8, const
|
|
|
27
27
|
from ._base import Codec as _Codec
|
|
28
28
|
from ._base import NoCodecError
|
|
29
29
|
|
|
30
|
+
from collections.abc import Mapping
|
|
30
31
|
from typing import TYPE_CHECKING, cast
|
|
31
32
|
|
|
32
33
|
if TYPE_CHECKING:
|
|
@@ -524,7 +525,7 @@ class Packer:
|
|
|
524
525
|
n -= 1
|
|
525
526
|
todo.append(obj[n])
|
|
526
527
|
continue
|
|
527
|
-
if is_(obj,
|
|
528
|
+
if is_(obj, Mapping):
|
|
528
529
|
n = len(obj)
|
|
529
530
|
if n <= 0x0F:
|
|
530
531
|
wb(struct.pack("B", 0x80 + n))
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Null codec — accepts only ``None``.
|
|
2
|
+
|
|
3
|
+
This codec exists as a placeholder, e.g. for use in conversion-vector
|
|
4
|
+
trees to mark paths whose payload should be silently dropped by gateways.
|
|
5
|
+
It encodes ``None`` to an empty byte string and refuses any other value.
|
|
6
|
+
Decoding ignores the input and returns ``None``.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from ._base import Codec as _Codec
|
|
12
|
+
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Codec(_Codec):
|
|
17
|
+
"""Codec that only accepts :data:`None` as a value."""
|
|
18
|
+
|
|
19
|
+
def __init__(self, ext: Any | None = None) -> None:
|
|
20
|
+
if ext is not None:
|
|
21
|
+
raise ValueError("You can't extend the null codec")
|
|
22
|
+
super().__init__()
|
|
23
|
+
|
|
24
|
+
def encode(self, obj: Any) -> bytes:
|
|
25
|
+
"""Encode :data:`None` to empty bytes; raise otherwise."""
|
|
26
|
+
if obj is None:
|
|
27
|
+
return b""
|
|
28
|
+
raise ValueError(f"The null codec only accepts None, not {obj!r}")
|
|
29
|
+
|
|
30
|
+
def decode(self, data: bytes | bytearray | memoryview) -> None: # noqa: ARG002
|
|
31
|
+
"""Discard ``data`` and return :data:`None`."""
|
|
32
|
+
return None
|
|
@@ -20,6 +20,7 @@ class Codec(_Codec):
|
|
|
20
20
|
raise ValueError("You can't extend the JSON codec")
|
|
21
21
|
super().__init__()
|
|
22
22
|
self._buf = bytearray()
|
|
23
|
+
self._eof = False
|
|
23
24
|
|
|
24
25
|
def encode(self, obj):
|
|
25
26
|
"basic encoder"
|
|
@@ -32,10 +33,23 @@ class Codec(_Codec):
|
|
|
32
33
|
def feed(self, data: ByteType) -> None: # noqa: D102
|
|
33
34
|
self._buf.extend(data)
|
|
34
35
|
|
|
36
|
+
def eof(self) -> None: # noqa: D102
|
|
37
|
+
self._eof = True
|
|
38
|
+
|
|
35
39
|
def __next__(self):
|
|
36
40
|
i = self._buf.find(b"\n---\n")
|
|
37
|
-
if i
|
|
41
|
+
if i >= 0:
|
|
42
|
+
res = yload(self._buf[0 : i + 1].decode("utf-8", "surrogateescape"))
|
|
43
|
+
self._buf[0 : i + 5] = b""
|
|
44
|
+
return res
|
|
45
|
+
if not self._eof:
|
|
46
|
+
raise StopIteration
|
|
47
|
+
|
|
48
|
+
# last document, not terminated by "---"
|
|
49
|
+
rest = bytes(self._buf).strip()
|
|
50
|
+
self._buf.clear()
|
|
51
|
+
if rest.endswith(b"\n---"):
|
|
52
|
+
rest = rest[:-4]
|
|
53
|
+
if not rest or rest == b"---":
|
|
38
54
|
raise StopIteration
|
|
39
|
-
|
|
40
|
-
self._buf[0 : i + 5] = b""
|
|
41
|
-
return res
|
|
55
|
+
return yload(rest.decode("utf-8", "surrogateescape"))
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: moat-lib-codec
|
|
3
|
+
Version: 0.4.21
|
|
4
|
+
Summary: A simple command/stream multiplexer
|
|
5
|
+
Author-email: Matthias Urlichs <matthias@urlichs.de>
|
|
6
|
+
Maintainer-email: Matthias Urlichs <matthias@urlichs.de>
|
|
7
|
+
Project-URL: homepage, https://m-o-a-t.org
|
|
8
|
+
Project-URL: repository, https://github.com/M-o-a-T/moat
|
|
9
|
+
Keywords: MoaT
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Framework :: AnyIO
|
|
12
|
+
Classifier: Framework :: Trio
|
|
13
|
+
Classifier: Framework :: AsyncIO
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE.txt
|
|
19
|
+
Requires-Dist: anyio~=4.2
|
|
20
|
+
Requires-Dist: moat-lib-rpc~=0.7.6
|
|
21
|
+
Requires-Dist: moat-lib-micro~=0.3.4
|
|
22
|
+
Requires-Dist: moat-lib-proxy~=0.1.3
|
|
23
|
+
Requires-Dist: moat-util~=0.64.0
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# The MoaT-Codec library
|
|
27
|
+
|
|
28
|
+
% start synopsis
|
|
29
|
+
% start main
|
|
30
|
+
|
|
31
|
+
This library packages various codecs used for MoaT protocols
|
|
32
|
+
in a way that's reason- and stream-able.
|
|
33
|
+
|
|
34
|
+
% end synopsis
|
|
35
|
+
|
|
36
|
+
## Supplied codecs
|
|
37
|
+
|
|
38
|
+
- CBOR
|
|
39
|
+
- msgpack
|
|
40
|
+
- no-op
|
|
41
|
+
- UTF-8
|
|
42
|
+
- JSON
|
|
43
|
+
- YAML
|
|
44
|
+
|
|
45
|
+
% end main
|
|
46
|
+
|
|
47
|
+
## Interface
|
|
48
|
+
|
|
49
|
+
### Codec
|
|
50
|
+
|
|
51
|
+
- encode(obj)
|
|
52
|
+
|
|
53
|
+
Encode the object to a bytestream.
|
|
54
|
+
|
|
55
|
+
- decode(bytes)
|
|
56
|
+
|
|
57
|
+
Decode the given bytes to a single object.
|
|
58
|
+
|
|
59
|
+
- feed(bytes, final=False)
|
|
60
|
+
|
|
61
|
+
Data stream. Returns an array of objects.
|
|
62
|
+
|
|
63
|
+
This method only exists when a sequence of encoded objects can be streamed,
|
|
64
|
+
i.e. contains built-in message boundaries.
|
|
65
|
+
|
|
66
|
+
if @final is `True`, raise an exception if there is an incomplete
|
|
67
|
+
object in the buffer after this call.
|
|
68
|
+
|
|
69
|
+
- getstate(), setstate(\*args)
|
|
70
|
+
|
|
71
|
+
A streaming decoder may store partially-decoded state (unprocessed
|
|
72
|
+
buffer) here.
|
|
73
|
+
|
|
74
|
+
The list of accepted objects is implementation dependent.
|
|
75
|
+
|
|
76
|
+
### Extension
|
|
77
|
+
|
|
78
|
+
Extension types vary by whether they carry binary data as in (msgpack), or
|
|
79
|
+
objects (as in cbor).
|
|
80
|
+
|
|
81
|
+
- binary (classvar): True if msgpack-style, False if cbor-style
|
|
82
|
+
|
|
83
|
+
- encoder(cls, key, fn)
|
|
84
|
+
|
|
85
|
+
Encode an object `obj` of type `type`. `fn(codec, obj)` must return
|
|
86
|
+
a bytestring / an encodeable object. If the registration key is `None`
|
|
87
|
+
the function must return a tuple with the key as first element.
|
|
88
|
+
|
|
89
|
+
- decoder(key, fn)
|
|
90
|
+
|
|
91
|
+
Add a decoder (key, data) to an object. `fn(codec, data)` is called with a
|
|
92
|
+
bytestring / a decoded object, and returns whatever has been encoded.
|
|
93
|
+
|
|
94
|
+
Extensions get the codec as their first argument. They can use it to store
|
|
95
|
+
data, e.g. references. The extension object is available as `codec.ext`.
|
moat_lib_codec-0.4.18/PKG-INFO
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: moat-lib-codec
|
|
3
|
-
Version: 0.4.18
|
|
4
|
-
Summary: A simple command/stream multiplexer
|
|
5
|
-
Author-email: Matthias Urlichs <matthias@urlichs.de>
|
|
6
|
-
Maintainer-email: Matthias Urlichs <matthias@urlichs.de>
|
|
7
|
-
Project-URL: homepage, https://m-o-a-t.org
|
|
8
|
-
Project-URL: repository, https://github.com/M-o-a-T/moat
|
|
9
|
-
Keywords: MoaT
|
|
10
|
-
Classifier: Development Status :: 4 - Beta
|
|
11
|
-
Classifier: Framework :: AnyIO
|
|
12
|
-
Classifier: Framework :: Trio
|
|
13
|
-
Classifier: Framework :: AsyncIO
|
|
14
|
-
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Intended Audience :: Developers
|
|
16
|
-
Requires-Python: >=3.8
|
|
17
|
-
Description-Content-Type: text/x-rst
|
|
18
|
-
License-File: LICENSE.txt
|
|
19
|
-
Requires-Dist: anyio~=4.2
|
|
20
|
-
Requires-Dist: moat-lib-rpc~=0.7.0
|
|
21
|
-
Requires-Dist: moat-lib-micro~=0.3.0
|
|
22
|
-
Requires-Dist: moat-lib-proxy~=0.1.1
|
|
23
|
-
Requires-Dist: moat-util~=0.63.0
|
|
24
|
-
Dynamic: license-file
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: moat-lib-codec
|
|
3
|
-
Version: 0.4.18
|
|
4
|
-
Summary: A simple command/stream multiplexer
|
|
5
|
-
Author-email: Matthias Urlichs <matthias@urlichs.de>
|
|
6
|
-
Maintainer-email: Matthias Urlichs <matthias@urlichs.de>
|
|
7
|
-
Project-URL: homepage, https://m-o-a-t.org
|
|
8
|
-
Project-URL: repository, https://github.com/M-o-a-T/moat
|
|
9
|
-
Keywords: MoaT
|
|
10
|
-
Classifier: Development Status :: 4 - Beta
|
|
11
|
-
Classifier: Framework :: AnyIO
|
|
12
|
-
Classifier: Framework :: Trio
|
|
13
|
-
Classifier: Framework :: AsyncIO
|
|
14
|
-
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Intended Audience :: Developers
|
|
16
|
-
Requires-Python: >=3.8
|
|
17
|
-
Description-Content-Type: text/x-rst
|
|
18
|
-
License-File: LICENSE.txt
|
|
19
|
-
Requires-Dist: anyio~=4.2
|
|
20
|
-
Requires-Dist: moat-lib-rpc~=0.7.0
|
|
21
|
-
Requires-Dist: moat-lib-micro~=0.3.0
|
|
22
|
-
Requires-Dist: moat-lib-proxy~=0.1.1
|
|
23
|
-
Requires-Dist: moat-util~=0.63.0
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{moat_lib_codec-0.4.18 → moat_lib_codec-0.4.21}/src/moat_lib_codec.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|