jmux 0.0.4__py3-none-any.whl → 0.0.5__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.
- jmux/awaitable.py +10 -4
- jmux/demux.py +10 -3
- jmux/pda.py +8 -3
- {jmux-0.0.4.dist-info → jmux-0.0.5.dist-info}/METADATA +2 -2
- jmux-0.0.5.dist-info/RECORD +13 -0
- {jmux-0.0.4.dist-info → jmux-0.0.5.dist-info}/WHEEL +1 -1
- jmux-0.0.4.dist-info/RECORD +0 -13
- {jmux-0.0.4.dist-info → jmux-0.0.5.dist-info}/licenses/LICENSE +0 -0
- {jmux-0.0.4.dist-info → jmux-0.0.5.dist-info}/top_level.txt +0 -0
jmux/awaitable.py
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
from asyncio import Event, Queue
|
|
2
4
|
from enum import Enum
|
|
3
5
|
from types import NoneType
|
|
4
6
|
from typing import (
|
|
5
7
|
AsyncGenerator,
|
|
8
|
+
Generic,
|
|
6
9
|
Protocol,
|
|
7
10
|
Set,
|
|
8
11
|
Type,
|
|
12
|
+
TypeVar,
|
|
9
13
|
cast,
|
|
10
14
|
runtime_checkable,
|
|
11
15
|
)
|
|
@@ -13,13 +17,15 @@ from typing import (
|
|
|
13
17
|
from jmux.error import NothingEmittedError, SinkClosedError
|
|
14
18
|
from jmux.helpers import extract_types_from_generic_alias
|
|
15
19
|
|
|
20
|
+
T = TypeVar("T")
|
|
21
|
+
|
|
16
22
|
|
|
17
23
|
class SinkType(Enum):
|
|
18
24
|
STREAMABLE_VALUES = "StreamableValues"
|
|
19
25
|
AWAITABLE_VALUE = "AwaitableValue"
|
|
20
26
|
|
|
21
27
|
|
|
22
|
-
class UnderlyingGenericMixin[T]:
|
|
28
|
+
class UnderlyingGenericMixin(Generic[T]):
|
|
23
29
|
"""
|
|
24
30
|
A mixin class that provides methods for inspecting the generic types of a
|
|
25
31
|
class at runtime.
|
|
@@ -61,7 +67,7 @@ class UnderlyingGenericMixin[T]:
|
|
|
61
67
|
|
|
62
68
|
|
|
63
69
|
@runtime_checkable
|
|
64
|
-
class IAsyncSink[T]
|
|
70
|
+
class IAsyncSink(Protocol[T]):
|
|
65
71
|
"""
|
|
66
72
|
An asynchronous sink protocol that defines a common interface for putting, closing,
|
|
67
73
|
and retrieving values from a sink.
|
|
@@ -96,7 +102,7 @@ class IAsyncSink[T](Protocol):
|
|
|
96
102
|
...
|
|
97
103
|
|
|
98
104
|
|
|
99
|
-
class StreamableValues[T]
|
|
105
|
+
class StreamableValues(UnderlyingGenericMixin[T], Generic[T]):
|
|
100
106
|
"""
|
|
101
107
|
A class that represents a stream of values that can be asynchronously iterated over.
|
|
102
108
|
It uses an asyncio.Queue to store the items and allows for putting items into the
|
|
@@ -198,7 +204,7 @@ class StreamableValues[T](UnderlyingGenericMixin[T]):
|
|
|
198
204
|
yield item
|
|
199
205
|
|
|
200
206
|
|
|
201
|
-
class AwaitableValue[T]
|
|
207
|
+
class AwaitableValue(UnderlyingGenericMixin[T], Generic[T]):
|
|
202
208
|
"""
|
|
203
209
|
A class that represents a value that will be available in the future.
|
|
204
210
|
It can be awaited to get the value, and it can only be set once.
|
jmux/demux.py
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
from abc import ABC
|
|
2
4
|
from enum import Enum
|
|
3
5
|
from types import NoneType
|
|
4
6
|
from typing import (
|
|
7
|
+
Generic,
|
|
5
8
|
Optional,
|
|
6
9
|
Set,
|
|
7
10
|
Type,
|
|
11
|
+
TypeVar,
|
|
12
|
+
Union,
|
|
8
13
|
get_args,
|
|
9
14
|
get_origin,
|
|
10
15
|
get_type_hints,
|
|
@@ -59,11 +64,13 @@ from jmux.types import (
|
|
|
59
64
|
from jmux.types import Mode as M
|
|
60
65
|
from jmux.types import State as S
|
|
61
66
|
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
Primitive = Union[int, float, str, bool, None]
|
|
68
|
+
Emittable = Union[int, float, str, bool, None, "JMux", Enum]
|
|
69
|
+
|
|
70
|
+
T = TypeVar("T")
|
|
64
71
|
|
|
65
72
|
|
|
66
|
-
class Sink[T
|
|
73
|
+
class Sink(Generic[T]):
|
|
67
74
|
def __init__(self, delegate: "JMux"):
|
|
68
75
|
self._current_key: Optional[str] = None
|
|
69
76
|
self._current_sink: Optional[IAsyncSink[T]] = None
|
jmux/pda.py
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
from
|
|
1
|
+
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from typing import Generic, List, Optional, TypeVar
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
Context = TypeVar("Context")
|
|
6
|
+
State = TypeVar("State")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PushDownAutomata(Generic[Context, State]):
|
|
5
10
|
def __init__(self, start_state: State) -> None:
|
|
6
11
|
self._stack: List[Context] = []
|
|
7
12
|
self._state: State = start_state
|
|
@@ -15,7 +20,7 @@ class PushDownAutomata[Context, State]:
|
|
|
15
20
|
return self._stack
|
|
16
21
|
|
|
17
22
|
@property
|
|
18
|
-
def top(self) -> Context
|
|
23
|
+
def top(self) -> Optional[Context]:
|
|
19
24
|
if not self._stack:
|
|
20
25
|
return None
|
|
21
26
|
return self._stack[-1]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jmux
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
4
4
|
Summary: JMux: A Python package for demultiplexing a JSON string into multiple awaitable variables.
|
|
5
5
|
Author-email: "Johannes A.I. Unruh" <johannes@unruh.ai>
|
|
6
6
|
License: MIT License
|
|
@@ -32,7 +32,7 @@ Project-URL: Repository, https://github.com/jaunruh/jmux
|
|
|
32
32
|
Keywords: demultiplexer,python,package,json
|
|
33
33
|
Classifier: Programming Language :: Python :: 3
|
|
34
34
|
Classifier: Operating System :: OS Independent
|
|
35
|
-
Requires-Python: >=3.
|
|
35
|
+
Requires-Python: >=3.10
|
|
36
36
|
Description-Content-Type: text/markdown
|
|
37
37
|
License-File: LICENSE
|
|
38
38
|
Requires-Dist: anyio>=4.0.0
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
jmux/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
jmux/awaitable.py,sha256=otX4vbWzVmIwxvMDWOtaIvS9do8YJtbls9xFjwH9Yw0,8534
|
|
3
|
+
jmux/decoder.py,sha256=Y6KVryRDLvGV5nBsneXpTvC0WUGhR5Z89Dvqz4HMAgg,1562
|
|
4
|
+
jmux/demux.py,sha256=OuUaNwvKI6WJxdzBzbBgx0yPq1kn4jSttuB5lvwzztk,36422
|
|
5
|
+
jmux/error.py,sha256=VZJYivt8RPfjcF2bs-T7_UkH3dVA3xH-xGbZggQV14k,4665
|
|
6
|
+
jmux/helpers.py,sha256=zOlw1Yk7-sdKAeasswRRcuUOTEBAUbymoAGwBTMaOjg,2902
|
|
7
|
+
jmux/pda.py,sha256=19joQd0DD5OAmwRpp2jVVbtiFXnjv5P_1mZm87-QOeY,922
|
|
8
|
+
jmux/types.py,sha256=CJhFS9RVgR0cDBNJR8ROAFnxzG4YTYpNZ90hyD2SxsY,1389
|
|
9
|
+
jmux-0.0.5.dist-info/licenses/LICENSE,sha256=y0qnwaAe4bEqzNPyq4M_VZA2I2mQly8MawajyZhqw0k,1169
|
|
10
|
+
jmux-0.0.5.dist-info/METADATA,sha256=31D2JB7C5kqeislSLEg3WRkyGXO5cx3mY34SAJd1ntU,13330
|
|
11
|
+
jmux-0.0.5.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
12
|
+
jmux-0.0.5.dist-info/top_level.txt,sha256=TF2N6kHqLghfOkCiNlCueMDX4l5rPn_5MSPNtYrS1-o,5
|
|
13
|
+
jmux-0.0.5.dist-info/RECORD,,
|
jmux-0.0.4.dist-info/RECORD
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
jmux/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
jmux/awaitable.py,sha256=gceBygIf3fAIWLsN1lWxsz9ExWNasDuk1WaGz8d9FAc,8427
|
|
3
|
-
jmux/decoder.py,sha256=Y6KVryRDLvGV5nBsneXpTvC0WUGhR5Z89Dvqz4HMAgg,1562
|
|
4
|
-
jmux/demux.py,sha256=g9DkMc9sLs31nuVwb7jbGZAjs0KulsKDGfOIM87NuWQ,36317
|
|
5
|
-
jmux/error.py,sha256=VZJYivt8RPfjcF2bs-T7_UkH3dVA3xH-xGbZggQV14k,4665
|
|
6
|
-
jmux/helpers.py,sha256=zOlw1Yk7-sdKAeasswRRcuUOTEBAUbymoAGwBTMaOjg,2902
|
|
7
|
-
jmux/pda.py,sha256=81gnh0eWGsgd_SrHkqjRQy_KkOSlBf5nor7pqKGgYjw,791
|
|
8
|
-
jmux/types.py,sha256=CJhFS9RVgR0cDBNJR8ROAFnxzG4YTYpNZ90hyD2SxsY,1389
|
|
9
|
-
jmux-0.0.4.dist-info/licenses/LICENSE,sha256=y0qnwaAe4bEqzNPyq4M_VZA2I2mQly8MawajyZhqw0k,1169
|
|
10
|
-
jmux-0.0.4.dist-info/METADATA,sha256=vVREVDZvfTC0KadGCOrw7RrSGxXdmZZNHJ8K-Zr3ZLM,13330
|
|
11
|
-
jmux-0.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
12
|
-
jmux-0.0.4.dist-info/top_level.txt,sha256=TF2N6kHqLghfOkCiNlCueMDX4l5rPn_5MSPNtYrS1-o,5
|
|
13
|
-
jmux-0.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|