soia-client 1.0.13__tar.gz → 1.0.15__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.
Potentially problematic release.
This version of soia-client might be problematic. Click here for more details.
- {soia_client-1.0.13 → soia_client-1.0.15}/PKG-INFO +1 -1
- {soia_client-1.0.13 → soia_client-1.0.15}/pyproject.toml +1 -1
- soia_client-1.0.15/soia/__init__.py +30 -0
- {soia_client-1.0.13/soialib/impl → soia_client-1.0.15/soia/_impl}/arrays.py +10 -10
- {soia_client-1.0.13/soialib/impl → soia_client-1.0.15/soia/_impl}/enums.py +10 -10
- {soia_client-1.0.13/soialib → soia_client-1.0.15/soia/_impl}/keyed_items.py +0 -1
- {soia_client-1.0.13/soialib → soia_client-1.0.15/soia/_impl}/method.py +1 -1
- {soia_client-1.0.13/soialib → soia_client-1.0.15/soia/_impl}/never.py +0 -1
- {soia_client-1.0.13/soialib/impl → soia_client-1.0.15/soia/_impl}/optionals.py +8 -8
- {soia_client-1.0.13/soialib/impl → soia_client-1.0.15/soia/_impl}/primitives.py +25 -25
- {soia_client-1.0.13/soialib → soia_client-1.0.15/soia/_impl}/serializer.py +8 -7
- {soia_client-1.0.13/soialib → soia_client-1.0.15/soia/_impl}/serializers.py +5 -5
- {soia_client-1.0.13/soialib → soia_client-1.0.15/soia/_impl}/service.py +26 -3
- {soia_client-1.0.13/soialib → soia_client-1.0.15/soia/_impl}/service_client.py +1 -2
- {soia_client-1.0.13/soialib/impl → soia_client-1.0.15/soia/_impl}/structs.py +10 -10
- {soia_client-1.0.13/soialib/impl → soia_client-1.0.15/soia/_impl}/type_adapter.py +6 -6
- soia_client-1.0.13/soialib/module_initializer.py → soia_client-1.0.15/soia/_module_initializer.py +23 -22
- {soia_client-1.0.13 → soia_client-1.0.15}/soia_client.egg-info/PKG-INFO +1 -1
- soia_client-1.0.15/soia_client.egg-info/SOURCES.txt +31 -0
- soia_client-1.0.15/soia_client.egg-info/top_level.txt +1 -0
- {soia_client-1.0.13 → soia_client-1.0.15}/tests/test_module_initializer.py +92 -94
- {soia_client-1.0.13 → soia_client-1.0.15}/tests/test_serializers.py +1 -6
- {soia_client-1.0.13 → soia_client-1.0.15}/tests/test_timestamp.py +1 -5
- soia_client-1.0.13/soia_client.egg-info/SOURCES.txt +0 -32
- soia_client-1.0.13/soia_client.egg-info/top_level.txt +0 -1
- soia_client-1.0.13/soialib/_.py +0 -3
- soia_client-1.0.13/soialib/__init__.py +0 -25
- {soia_client-1.0.13 → soia_client-1.0.15}/LICENSE +0 -0
- {soia_client-1.0.13 → soia_client-1.0.15}/README +0 -0
- {soia_client-1.0.13 → soia_client-1.0.15}/setup.cfg +0 -0
- {soia_client-1.0.13/soialib/impl → soia_client-1.0.15/soia/_impl}/__init__.py +0 -0
- {soia_client-1.0.13/soialib/impl → soia_client-1.0.15/soia/_impl}/function_maker.py +0 -0
- {soia_client-1.0.13/soialib/impl → soia_client-1.0.15/soia/_impl}/repr.py +0 -0
- {soia_client-1.0.13/soialib → soia_client-1.0.15/soia/_impl}/timestamp.py +0 -0
- /soia_client-1.0.13/soialib/spec.py → /soia_client-1.0.15/soia/_spec.py +0 -0
- {soia_client-1.0.13/soialib → soia_client-1.0.15/soia}/reflection.py +0 -0
- {soia_client-1.0.13 → soia_client-1.0.15}/soia_client.egg-info/dependency_links.txt +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import typing as _typing
|
|
2
|
+
|
|
3
|
+
from soia._impl.keyed_items import KeyedItems
|
|
4
|
+
from soia._impl.method import Method
|
|
5
|
+
from soia._impl.serializer import Serializer
|
|
6
|
+
from soia._impl.serializers import (
|
|
7
|
+
array_serializer,
|
|
8
|
+
optional_serializer,
|
|
9
|
+
primitive_serializer,
|
|
10
|
+
)
|
|
11
|
+
from soia._impl.service import RequestHeaders, ResponseHeaders, Service
|
|
12
|
+
from soia._impl.service_client import ServiceClient
|
|
13
|
+
from soia._impl.timestamp import Timestamp
|
|
14
|
+
|
|
15
|
+
_: _typing.Final[_typing.Any] = None
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"_",
|
|
19
|
+
"KeyedItems",
|
|
20
|
+
"Method",
|
|
21
|
+
"RequestHeaders",
|
|
22
|
+
"ResponseHeaders",
|
|
23
|
+
"Serializer",
|
|
24
|
+
"Service",
|
|
25
|
+
"ServiceClient",
|
|
26
|
+
"Timestamp",
|
|
27
|
+
"array_serializer",
|
|
28
|
+
"optional_serializer",
|
|
29
|
+
"primitive_serializer",
|
|
30
|
+
]
|
|
@@ -3,11 +3,11 @@ from dataclasses import FrozenInstanceError
|
|
|
3
3
|
from typing import Generic, Optional
|
|
4
4
|
from weakref import WeakValueDictionary
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
from
|
|
8
|
-
from
|
|
9
|
-
|
|
10
|
-
from
|
|
6
|
+
from soia._impl.function_maker import Any, Expr, ExprLike, Line, make_function
|
|
7
|
+
from soia._impl.keyed_items import Item, Key, KeyedItems
|
|
8
|
+
from soia._impl.type_adapter import TypeAdapter
|
|
9
|
+
|
|
10
|
+
from soia import _spec, reflection
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def get_array_adapter(
|
|
@@ -104,14 +104,14 @@ class _ArrayAdapter(TypeAdapter):
|
|
|
104
104
|
|
|
105
105
|
def finalize(
|
|
106
106
|
self,
|
|
107
|
-
resolve_type_fn: Callable[[
|
|
107
|
+
resolve_type_fn: Callable[[_spec.Type], "TypeAdapter"],
|
|
108
108
|
) -> None:
|
|
109
109
|
self.item_adapter.finalize(resolve_type_fn)
|
|
110
110
|
|
|
111
|
-
def get_type(self) ->
|
|
112
|
-
return
|
|
111
|
+
def get_type(self) -> reflection.Type:
|
|
112
|
+
return reflection.ArrayType(
|
|
113
113
|
kind="array",
|
|
114
|
-
value=
|
|
114
|
+
value=reflection.ArrayType.Array(
|
|
115
115
|
item=self.item_adapter.get_type(),
|
|
116
116
|
key_chain=self.key_attributes,
|
|
117
117
|
),
|
|
@@ -119,7 +119,7 @@ class _ArrayAdapter(TypeAdapter):
|
|
|
119
119
|
|
|
120
120
|
def register_records(
|
|
121
121
|
self,
|
|
122
|
-
registry: dict[str,
|
|
122
|
+
registry: dict[str, reflection.Record],
|
|
123
123
|
) -> None:
|
|
124
124
|
self.item_adapter.register_records(registry)
|
|
125
125
|
|
|
@@ -3,11 +3,11 @@ from collections.abc import Callable, Sequence
|
|
|
3
3
|
from dataclasses import FrozenInstanceError, dataclass
|
|
4
4
|
from typing import Any, Final, Union
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
from
|
|
8
|
-
from
|
|
9
|
-
|
|
10
|
-
from
|
|
6
|
+
from soia._impl.function_maker import BodyBuilder, Expr, ExprLike, Line, make_function
|
|
7
|
+
from soia._impl.repr import repr_impl
|
|
8
|
+
from soia._impl.type_adapter import TypeAdapter
|
|
9
|
+
|
|
10
|
+
from soia import _spec, reflection
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class EnumAdapter(TypeAdapter):
|
|
@@ -119,24 +119,24 @@ class EnumAdapter(TypeAdapter):
|
|
|
119
119
|
Expr.local("_cls?", self.gen_class), f".{fn_name}(", json_expr, ")"
|
|
120
120
|
)
|
|
121
121
|
|
|
122
|
-
def get_type(self) ->
|
|
123
|
-
return
|
|
122
|
+
def get_type(self) -> reflection.Type:
|
|
123
|
+
return reflection.RecordType(
|
|
124
124
|
kind="record",
|
|
125
125
|
value=self.spec.id,
|
|
126
126
|
)
|
|
127
127
|
|
|
128
128
|
def register_records(
|
|
129
129
|
self,
|
|
130
|
-
registry: dict[str,
|
|
130
|
+
registry: dict[str, reflection.Record],
|
|
131
131
|
) -> None:
|
|
132
132
|
record_id = self.spec.id
|
|
133
133
|
if record_id in registry:
|
|
134
134
|
return
|
|
135
|
-
registry[record_id] =
|
|
135
|
+
registry[record_id] = reflection.Record(
|
|
136
136
|
kind="enum",
|
|
137
137
|
id=record_id,
|
|
138
138
|
fields=tuple(
|
|
139
|
-
|
|
139
|
+
reflection.Field(
|
|
140
140
|
name=field.spec.name,
|
|
141
141
|
number=field.spec.number,
|
|
142
142
|
type=field.field_type.get_type(),
|
|
@@ -3,10 +3,10 @@ from dataclasses import dataclass
|
|
|
3
3
|
from typing import TypeVar
|
|
4
4
|
from weakref import WeakValueDictionary
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
from
|
|
8
|
-
|
|
9
|
-
from
|
|
6
|
+
from soia._impl.function_maker import Expr, ExprLike
|
|
7
|
+
from soia._impl.type_adapter import TypeAdapter
|
|
8
|
+
|
|
9
|
+
from soia import _spec, reflection
|
|
10
10
|
|
|
11
11
|
Other = TypeVar("Other")
|
|
12
12
|
|
|
@@ -64,19 +64,19 @@ class _OptionalAdapter(TypeAdapter):
|
|
|
64
64
|
|
|
65
65
|
def finalize(
|
|
66
66
|
self,
|
|
67
|
-
resolve_type_fn: Callable[[
|
|
67
|
+
resolve_type_fn: Callable[[_spec.Type], "TypeAdapter"],
|
|
68
68
|
) -> None:
|
|
69
69
|
self.other_adapter.finalize(resolve_type_fn)
|
|
70
70
|
|
|
71
|
-
def get_type(self) ->
|
|
72
|
-
return
|
|
71
|
+
def get_type(self) -> reflection.Type:
|
|
72
|
+
return reflection.OptionalType(
|
|
73
73
|
kind="optional",
|
|
74
74
|
value=self.other_adapter.get_type(),
|
|
75
75
|
)
|
|
76
76
|
|
|
77
77
|
def register_records(
|
|
78
78
|
self,
|
|
79
|
-
registry: dict[str,
|
|
79
|
+
registry: dict[str, reflection.Record],
|
|
80
80
|
) -> None:
|
|
81
81
|
self.other_adapter.register_records(registry)
|
|
82
82
|
|
|
@@ -2,25 +2,25 @@ from collections.abc import Callable
|
|
|
2
2
|
from dataclasses import dataclass
|
|
3
3
|
from typing import Any, Final, final
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
from
|
|
7
|
-
from
|
|
8
|
-
|
|
9
|
-
from
|
|
5
|
+
from soia._impl.function_maker import Expr, ExprLike
|
|
6
|
+
from soia._impl.timestamp import Timestamp
|
|
7
|
+
from soia._impl.type_adapter import TypeAdapter
|
|
8
|
+
|
|
9
|
+
from soia import _spec, reflection
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class AbstractPrimitiveAdapter(TypeAdapter):
|
|
13
13
|
@final
|
|
14
14
|
def finalize(
|
|
15
15
|
self,
|
|
16
|
-
resolve_type_fn: Callable[[
|
|
16
|
+
resolve_type_fn: Callable[[_spec.Type], "TypeAdapter"],
|
|
17
17
|
) -> None:
|
|
18
18
|
pass
|
|
19
19
|
|
|
20
20
|
@final
|
|
21
21
|
def register_records(
|
|
22
22
|
self,
|
|
23
|
-
|
|
23
|
+
registry: dict[str, reflection.Record],
|
|
24
24
|
) -> None:
|
|
25
25
|
pass
|
|
26
26
|
|
|
@@ -48,8 +48,8 @@ class _BoolAdapter(AbstractPrimitiveAdapter):
|
|
|
48
48
|
def from_json_expr(self, json_expr: ExprLike) -> Expr:
|
|
49
49
|
return Expr.join("(True if ", json_expr, " else False)")
|
|
50
50
|
|
|
51
|
-
def get_type(self) ->
|
|
52
|
-
return
|
|
51
|
+
def get_type(self) -> reflection.Type:
|
|
52
|
+
return reflection.PrimitiveType(
|
|
53
53
|
kind="primitive",
|
|
54
54
|
value="bool",
|
|
55
55
|
)
|
|
@@ -94,8 +94,8 @@ class _Int32Adapter(_AbstractIntAdapter):
|
|
|
94
94
|
" < 2147483647 else 2147483647)",
|
|
95
95
|
)
|
|
96
96
|
|
|
97
|
-
def get_type(self) ->
|
|
98
|
-
return
|
|
97
|
+
def get_type(self) -> reflection.Type:
|
|
98
|
+
return reflection.PrimitiveType(
|
|
99
99
|
kind="primitive",
|
|
100
100
|
value="int32",
|
|
101
101
|
)
|
|
@@ -120,8 +120,8 @@ class _Int64Adapter(_AbstractIntAdapter):
|
|
|
120
120
|
def to_json_expr(self, in_expr: ExprLike, readable: bool) -> Expr:
|
|
121
121
|
return Expr.join(Expr.local("int64_to_json", _int64_to_json), "(", in_expr, ")")
|
|
122
122
|
|
|
123
|
-
def get_type(self) ->
|
|
124
|
-
return
|
|
123
|
+
def get_type(self) -> reflection.Type:
|
|
124
|
+
return reflection.PrimitiveType(
|
|
125
125
|
kind="primitive",
|
|
126
126
|
value="int64",
|
|
127
127
|
)
|
|
@@ -145,8 +145,8 @@ class _Uint64Adapter(_AbstractIntAdapter):
|
|
|
145
145
|
Expr.local("uint64_to_json", _uint64_to_json), "(", in_expr, ")"
|
|
146
146
|
)
|
|
147
147
|
|
|
148
|
-
def get_type(self) ->
|
|
149
|
-
return
|
|
148
|
+
def get_type(self) -> reflection.Type:
|
|
149
|
+
return reflection.PrimitiveType(
|
|
150
150
|
kind="primitive",
|
|
151
151
|
value="uint64",
|
|
152
152
|
)
|
|
@@ -181,8 +181,8 @@ class _AbstractFloatAdapter(AbstractPrimitiveAdapter):
|
|
|
181
181
|
class _Float32Adapter(_AbstractFloatAdapter):
|
|
182
182
|
"""Type adapter implementation for float32."""
|
|
183
183
|
|
|
184
|
-
def get_type(self) ->
|
|
185
|
-
return
|
|
184
|
+
def get_type(self) -> reflection.Type:
|
|
185
|
+
return reflection.PrimitiveType(
|
|
186
186
|
kind="primitive",
|
|
187
187
|
value="float32",
|
|
188
188
|
)
|
|
@@ -192,8 +192,8 @@ class _Float32Adapter(_AbstractFloatAdapter):
|
|
|
192
192
|
class _Float64Adapter(_AbstractFloatAdapter):
|
|
193
193
|
"""Type adapter implementation for float32."""
|
|
194
194
|
|
|
195
|
-
def get_type(self) ->
|
|
196
|
-
return
|
|
195
|
+
def get_type(self) -> reflection.Type:
|
|
196
|
+
return reflection.PrimitiveType(
|
|
197
197
|
kind="primitive",
|
|
198
198
|
value="float64",
|
|
199
199
|
)
|
|
@@ -236,8 +236,8 @@ class _TimestampAdapter(AbstractPrimitiveAdapter):
|
|
|
236
236
|
fn = Expr.local("_timestamp_from_json", _timestamp_from_json)
|
|
237
237
|
return Expr.join(fn, "(", json_expr, ")")
|
|
238
238
|
|
|
239
|
-
def get_type(self) ->
|
|
240
|
-
return
|
|
239
|
+
def get_type(self) -> reflection.Type:
|
|
240
|
+
return reflection.PrimitiveType(
|
|
241
241
|
kind="primitive",
|
|
242
242
|
value="timestamp",
|
|
243
243
|
)
|
|
@@ -269,8 +269,8 @@ class _StringAdapter(AbstractPrimitiveAdapter):
|
|
|
269
269
|
def from_json_expr(self, json_expr: ExprLike) -> Expr:
|
|
270
270
|
return Expr.join("('' + (", json_expr, " or ''))")
|
|
271
271
|
|
|
272
|
-
def get_type(self) ->
|
|
273
|
-
return
|
|
272
|
+
def get_type(self) -> reflection.Type:
|
|
273
|
+
return reflection.PrimitiveType(
|
|
274
274
|
kind="primitive",
|
|
275
275
|
value="string",
|
|
276
276
|
)
|
|
@@ -303,8 +303,8 @@ class _BytesAdapter(AbstractPrimitiveAdapter):
|
|
|
303
303
|
Expr.local("fromhex", _BytesAdapter._fromhex_fn), "(", json_expr, ' or "")'
|
|
304
304
|
)
|
|
305
305
|
|
|
306
|
-
def get_type(self) ->
|
|
307
|
-
return
|
|
306
|
+
def get_type(self) -> reflection.Type:
|
|
307
|
+
return reflection.PrimitiveType(
|
|
308
308
|
kind="primitive",
|
|
309
309
|
value="bytes",
|
|
310
310
|
)
|
|
@@ -5,10 +5,11 @@ from functools import cached_property
|
|
|
5
5
|
from typing import Any, Generic, TypeVar, cast, final
|
|
6
6
|
from weakref import WeakValueDictionary
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
|
|
8
|
+
from soia._impl.function_maker import Expr, LineSpan, make_function
|
|
9
|
+
from soia._impl.never import Never
|
|
10
|
+
from soia._impl.type_adapter import TypeAdapter
|
|
11
|
+
|
|
12
|
+
from soia import reflection
|
|
12
13
|
|
|
13
14
|
T = TypeVar("T")
|
|
14
15
|
|
|
@@ -61,10 +62,10 @@ class Serializer(Generic[T]):
|
|
|
61
62
|
return self._from_json_fn(jsonlib.loads(json_code))
|
|
62
63
|
|
|
63
64
|
@cached_property
|
|
64
|
-
def type_descriptor(self) ->
|
|
65
|
-
records: dict[str,
|
|
65
|
+
def type_descriptor(self) -> reflection.TypeDescriptor:
|
|
66
|
+
records: dict[str, reflection.Record] = {}
|
|
66
67
|
self._adapter.register_records(records)
|
|
67
|
-
return
|
|
68
|
+
return reflection.TypeDescriptor(
|
|
68
69
|
type=self._adapter.get_type(),
|
|
69
70
|
records=tuple(records.values()),
|
|
70
71
|
)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
from typing import Final, Literal, TypeVar, overload
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
from
|
|
3
|
+
from soia._impl import primitives
|
|
4
|
+
from soia._impl.arrays import get_array_adapter
|
|
5
|
+
from soia._impl.optionals import get_optional_adapter
|
|
6
|
+
from soia._impl.serializer import Serializer, make_serializer
|
|
7
|
+
from soia._impl.timestamp import Timestamp
|
|
8
8
|
|
|
9
9
|
Item = TypeVar("Item")
|
|
10
10
|
Other = TypeVar("Other")
|
|
@@ -3,15 +3,18 @@ import json
|
|
|
3
3
|
from dataclasses import dataclass
|
|
4
4
|
from typing import Any, Callable, Generic, Literal, Mapping, TypeAlias, Union, cast
|
|
5
5
|
|
|
6
|
-
from
|
|
6
|
+
from soia._impl.method import Method, Request, Response
|
|
7
7
|
|
|
8
8
|
RequestHeaders: TypeAlias = Mapping[str, str]
|
|
9
9
|
ResponseHeaders: TypeAlias = dict[str, str]
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
class
|
|
12
|
+
class Service:
|
|
13
13
|
_number_to_method_impl: dict[int, "_MethodImpl"]
|
|
14
14
|
|
|
15
|
+
def __init__(self):
|
|
16
|
+
self._number_to_method_impl = {}
|
|
17
|
+
|
|
15
18
|
def add_method(
|
|
16
19
|
self,
|
|
17
20
|
method: Method[Request, Response],
|
|
@@ -20,7 +23,7 @@ class ServiceImpl:
|
|
|
20
23
|
Callable[[Request, RequestHeaders], Response],
|
|
21
24
|
Callable[[Request, RequestHeaders, ResponseHeaders], Response],
|
|
22
25
|
],
|
|
23
|
-
) -> "
|
|
26
|
+
) -> "Service":
|
|
24
27
|
signature = inspect.Signature.from_callable(impl)
|
|
25
28
|
num_positional_params = 0
|
|
26
29
|
for param in signature.parameters.values():
|
|
@@ -66,6 +69,26 @@ class ServiceImpl:
|
|
|
66
69
|
data: str
|
|
67
70
|
type: Literal["ok-json", "bad-request", "server-error"]
|
|
68
71
|
|
|
72
|
+
@property
|
|
73
|
+
def status_code(self):
|
|
74
|
+
if self.type == "ok-json":
|
|
75
|
+
return 200
|
|
76
|
+
elif self.type == "bad-request":
|
|
77
|
+
return 400
|
|
78
|
+
elif self.type == "server-error":
|
|
79
|
+
return 500
|
|
80
|
+
else:
|
|
81
|
+
raise TypeError(f"Unknown response type: {self.type}")
|
|
82
|
+
|
|
83
|
+
@property
|
|
84
|
+
def content_type(self):
|
|
85
|
+
if self.type == "ok-json":
|
|
86
|
+
return "application/json"
|
|
87
|
+
elif self.type == "bad-request" or self.type == "server-error":
|
|
88
|
+
return "text/plain; charset=utf-8"
|
|
89
|
+
else:
|
|
90
|
+
raise TypeError(f"Unknown response type: {self.type}")
|
|
91
|
+
|
|
69
92
|
def handle_request(
|
|
70
93
|
self,
|
|
71
94
|
req_body: str,
|
|
@@ -3,9 +3,7 @@ from collections.abc import Callable, Sequence
|
|
|
3
3
|
from dataclasses import FrozenInstanceError, dataclass
|
|
4
4
|
from typing import Any, Final, Union, cast
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
from soialib import spec as _spec
|
|
8
|
-
from soialib.impl.function_maker import (
|
|
6
|
+
from soia._impl.function_maker import (
|
|
9
7
|
BodyBuilder,
|
|
10
8
|
Expr,
|
|
11
9
|
ExprLike,
|
|
@@ -16,8 +14,10 @@ from soialib.impl.function_maker import (
|
|
|
16
14
|
Params,
|
|
17
15
|
make_function,
|
|
18
16
|
)
|
|
19
|
-
from
|
|
20
|
-
from
|
|
17
|
+
from soia._impl.repr import repr_impl
|
|
18
|
+
from soia._impl.type_adapter import TypeAdapter
|
|
19
|
+
|
|
20
|
+
from soia import _spec, reflection
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class StructAdapter(TypeAdapter):
|
|
@@ -201,24 +201,24 @@ class StructAdapter(TypeAdapter):
|
|
|
201
201
|
Expr.local("_cls?", self.gen_class), f".{fn_name}(", json_expr, ")"
|
|
202
202
|
)
|
|
203
203
|
|
|
204
|
-
def get_type(self) ->
|
|
205
|
-
return
|
|
204
|
+
def get_type(self) -> reflection.Type:
|
|
205
|
+
return reflection.RecordType(
|
|
206
206
|
kind="record",
|
|
207
207
|
value=self.spec.id,
|
|
208
208
|
)
|
|
209
209
|
|
|
210
210
|
def register_records(
|
|
211
211
|
self,
|
|
212
|
-
registry: dict[str,
|
|
212
|
+
registry: dict[str, reflection.Record],
|
|
213
213
|
) -> None:
|
|
214
214
|
record_id = self.spec.id
|
|
215
215
|
if record_id in registry:
|
|
216
216
|
return
|
|
217
|
-
registry[record_id] =
|
|
217
|
+
registry[record_id] = reflection.Record(
|
|
218
218
|
kind="struct",
|
|
219
219
|
id=record_id,
|
|
220
220
|
fields=tuple(
|
|
221
|
-
|
|
221
|
+
reflection.Field(
|
|
222
222
|
name=field.field.name,
|
|
223
223
|
number=field.field.number,
|
|
224
224
|
type=field.type.get_type(),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
from collections.abc import Callable
|
|
2
2
|
from typing import Protocol
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
from
|
|
4
|
+
from soia._impl.function_maker import ExprLike
|
|
5
|
+
|
|
6
|
+
from soia import _spec, reflection
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class TypeAdapter(Protocol):
|
|
@@ -52,12 +52,12 @@ class TypeAdapter(Protocol):
|
|
|
52
52
|
|
|
53
53
|
def finalize(
|
|
54
54
|
self,
|
|
55
|
-
resolve_type_fn: Callable[[
|
|
55
|
+
resolve_type_fn: Callable[[_spec.Type], "TypeAdapter"],
|
|
56
56
|
) -> None: ...
|
|
57
57
|
|
|
58
|
-
def get_type(self) ->
|
|
58
|
+
def get_type(self) -> reflection.Type: ...
|
|
59
59
|
|
|
60
60
|
def register_records(
|
|
61
61
|
self,
|
|
62
|
-
registry: dict[str,
|
|
62
|
+
registry: dict[str, reflection.Record],
|
|
63
63
|
) -> None: ...
|
soia_client-1.0.13/soialib/module_initializer.py → soia_client-1.0.15/soia/_module_initializer.py
RENAMED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
from typing import Any, Union
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
|
|
3
|
+
from soia._impl import arrays, enums, method, optionals, primitives, structs
|
|
4
|
+
from soia._impl.serializer import make_serializer
|
|
5
|
+
from soia._impl.type_adapter import TypeAdapter
|
|
6
|
+
|
|
7
|
+
from soia import _spec
|
|
7
8
|
|
|
8
9
|
RecordAdapter = Union[structs.StructAdapter, enums.EnumAdapter]
|
|
9
10
|
|
|
@@ -12,39 +13,39 @@ _record_id_to_adapter: dict[str, RecordAdapter] = {}
|
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
def init_module(
|
|
15
|
-
records: tuple[
|
|
16
|
-
methods: tuple[
|
|
17
|
-
constants: tuple[
|
|
16
|
+
records: tuple[_spec.Record, ...],
|
|
17
|
+
methods: tuple[_spec.Method, ...],
|
|
18
|
+
constants: tuple[_spec.Constant, ...],
|
|
18
19
|
globals: dict[str, Any],
|
|
19
20
|
# For testing
|
|
20
21
|
record_id_to_adapter: dict[str, RecordAdapter] = _record_id_to_adapter,
|
|
21
22
|
) -> None:
|
|
22
|
-
def resolve_type(type:
|
|
23
|
-
if isinstance(type,
|
|
24
|
-
if type ==
|
|
23
|
+
def resolve_type(type: _spec.Type) -> TypeAdapter:
|
|
24
|
+
if isinstance(type, _spec.PrimitiveType):
|
|
25
|
+
if type == _spec.PrimitiveType.BOOL:
|
|
25
26
|
return primitives.BOOL_ADAPTER
|
|
26
|
-
elif type ==
|
|
27
|
+
elif type == _spec.PrimitiveType.BYTES:
|
|
27
28
|
return primitives.BYTES_ADAPTER
|
|
28
|
-
elif type ==
|
|
29
|
+
elif type == _spec.PrimitiveType.FLOAT32:
|
|
29
30
|
return primitives.FLOAT32_ADAPTER
|
|
30
|
-
elif type ==
|
|
31
|
+
elif type == _spec.PrimitiveType.FLOAT64:
|
|
31
32
|
return primitives.FLOAT64_ADAPTER
|
|
32
|
-
elif type ==
|
|
33
|
+
elif type == _spec.PrimitiveType.INT32:
|
|
33
34
|
return primitives.INT32_ADAPTER
|
|
34
|
-
elif type ==
|
|
35
|
+
elif type == _spec.PrimitiveType.INT64:
|
|
35
36
|
return primitives.INT64_ADAPTER
|
|
36
|
-
elif type ==
|
|
37
|
+
elif type == _spec.PrimitiveType.STRING:
|
|
37
38
|
return primitives.STRING_ADAPTER
|
|
38
|
-
elif type ==
|
|
39
|
+
elif type == _spec.PrimitiveType.TIMESTAMP:
|
|
39
40
|
return primitives.TIMESTAMP_ADAPTER
|
|
40
|
-
elif type ==
|
|
41
|
+
elif type == _spec.PrimitiveType.UINT64:
|
|
41
42
|
return primitives.UINT64_ADAPTER
|
|
42
|
-
elif isinstance(type,
|
|
43
|
+
elif isinstance(type, _spec.ArrayType):
|
|
43
44
|
return arrays.get_array_adapter(
|
|
44
45
|
resolve_type(type.item),
|
|
45
46
|
type.key_attributes,
|
|
46
47
|
)
|
|
47
|
-
elif isinstance(type,
|
|
48
|
+
elif isinstance(type, _spec.OptionalType):
|
|
48
49
|
return optionals.get_optional_adapter(resolve_type(type.other))
|
|
49
50
|
elif isinstance(type, str):
|
|
50
51
|
# A record id.
|
|
@@ -55,7 +56,7 @@ def init_module(
|
|
|
55
56
|
if record.id in record_id_to_adapter:
|
|
56
57
|
raise AssertionError(record.id)
|
|
57
58
|
adapter: RecordAdapter
|
|
58
|
-
if isinstance(record,
|
|
59
|
+
if isinstance(record, _spec.Struct):
|
|
59
60
|
adapter = structs.StructAdapter(record)
|
|
60
61
|
else:
|
|
61
62
|
adapter = enums.EnumAdapter(record)
|
|
@@ -67,7 +68,7 @@ def init_module(
|
|
|
67
68
|
gen_class = adapter.gen_class
|
|
68
69
|
# Add the class name to either globals() if the record is defined at the top
|
|
69
70
|
# level, or the parent class otherwise.
|
|
70
|
-
record_id =
|
|
71
|
+
record_id = _spec.RecordId.parse(adapter.spec.id)
|
|
71
72
|
parent_id = record_id.parent
|
|
72
73
|
class_name = adapter.spec.class_name
|
|
73
74
|
if parent_id:
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README
|
|
3
|
+
pyproject.toml
|
|
4
|
+
soia/__init__.py
|
|
5
|
+
soia/_module_initializer.py
|
|
6
|
+
soia/_spec.py
|
|
7
|
+
soia/reflection.py
|
|
8
|
+
soia/_impl/__init__.py
|
|
9
|
+
soia/_impl/arrays.py
|
|
10
|
+
soia/_impl/enums.py
|
|
11
|
+
soia/_impl/function_maker.py
|
|
12
|
+
soia/_impl/keyed_items.py
|
|
13
|
+
soia/_impl/method.py
|
|
14
|
+
soia/_impl/never.py
|
|
15
|
+
soia/_impl/optionals.py
|
|
16
|
+
soia/_impl/primitives.py
|
|
17
|
+
soia/_impl/repr.py
|
|
18
|
+
soia/_impl/serializer.py
|
|
19
|
+
soia/_impl/serializers.py
|
|
20
|
+
soia/_impl/service.py
|
|
21
|
+
soia/_impl/service_client.py
|
|
22
|
+
soia/_impl/structs.py
|
|
23
|
+
soia/_impl/timestamp.py
|
|
24
|
+
soia/_impl/type_adapter.py
|
|
25
|
+
soia_client.egg-info/PKG-INFO
|
|
26
|
+
soia_client.egg-info/SOURCES.txt
|
|
27
|
+
soia_client.egg-info/dependency_links.txt
|
|
28
|
+
soia_client.egg-info/top_level.txt
|
|
29
|
+
tests/test_module_initializer.py
|
|
30
|
+
tests/test_serializers.py
|
|
31
|
+
tests/test_timestamp.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
soia
|
|
@@ -2,12 +2,10 @@ import dataclasses
|
|
|
2
2
|
import unittest
|
|
3
3
|
from typing import Any
|
|
4
4
|
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
|
|
8
|
-
from
|
|
9
|
-
from soialib.reflection import TypeDescriptor
|
|
10
|
-
from soialib.timestamp import Timestamp
|
|
5
|
+
from soia._module_initializer import init_module
|
|
6
|
+
from soia.reflection import TypeDescriptor
|
|
7
|
+
|
|
8
|
+
from soia import KeyedItems, Method, Timestamp, _spec
|
|
11
9
|
|
|
12
10
|
|
|
13
11
|
class ModuleInitializerTestCase(unittest.TestCase):
|
|
@@ -15,182 +13,182 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
15
13
|
globals: dict[str, Any] = {}
|
|
16
14
|
init_module(
|
|
17
15
|
records=(
|
|
18
|
-
|
|
16
|
+
_spec.Struct(
|
|
19
17
|
id="my/module.soia:Point",
|
|
20
18
|
fields=(
|
|
21
|
-
|
|
19
|
+
_spec.Field(
|
|
22
20
|
name="x",
|
|
23
21
|
number=0,
|
|
24
|
-
type=
|
|
22
|
+
type=_spec.PrimitiveType.FLOAT32,
|
|
25
23
|
),
|
|
26
|
-
|
|
24
|
+
_spec.Field(
|
|
27
25
|
name="y",
|
|
28
26
|
number=2,
|
|
29
|
-
type=
|
|
27
|
+
type=_spec.PrimitiveType.FLOAT32,
|
|
30
28
|
),
|
|
31
29
|
),
|
|
32
30
|
removed_numbers=(1,),
|
|
33
31
|
),
|
|
34
|
-
|
|
32
|
+
_spec.Struct(
|
|
35
33
|
id="my/module.soia:Segment",
|
|
36
34
|
fields=(
|
|
37
|
-
|
|
35
|
+
_spec.Field(
|
|
38
36
|
name="a",
|
|
39
37
|
number=0,
|
|
40
38
|
type="my/module.soia:Point",
|
|
41
39
|
has_mutable_getter=True,
|
|
42
40
|
),
|
|
43
|
-
|
|
41
|
+
_spec.Field(
|
|
44
42
|
name="bb",
|
|
45
43
|
_attribute="b",
|
|
46
44
|
number=1,
|
|
47
45
|
type="my/module.soia:Point",
|
|
48
46
|
has_mutable_getter=True,
|
|
49
47
|
),
|
|
50
|
-
|
|
48
|
+
_spec.Field(
|
|
51
49
|
name="c",
|
|
52
50
|
number=2,
|
|
53
|
-
type=
|
|
51
|
+
type=_spec.OptionalType("my/module.soia:Point"),
|
|
54
52
|
has_mutable_getter=True,
|
|
55
53
|
),
|
|
56
54
|
),
|
|
57
55
|
),
|
|
58
|
-
|
|
56
|
+
_spec.Struct(
|
|
59
57
|
id="my/module.soia:Shape",
|
|
60
58
|
fields=(
|
|
61
|
-
|
|
59
|
+
_spec.Field(
|
|
62
60
|
name="points",
|
|
63
61
|
number=0,
|
|
64
|
-
type=
|
|
62
|
+
type=_spec.ArrayType("my/module.soia:Point"),
|
|
65
63
|
has_mutable_getter=True,
|
|
66
64
|
),
|
|
67
65
|
),
|
|
68
66
|
),
|
|
69
|
-
|
|
67
|
+
_spec.Struct(
|
|
70
68
|
id="my/module.soia:Primitives",
|
|
71
69
|
fields=(
|
|
72
|
-
|
|
70
|
+
_spec.Field(
|
|
73
71
|
name="bool",
|
|
74
72
|
number=0,
|
|
75
|
-
type=
|
|
73
|
+
type=_spec.PrimitiveType.BOOL,
|
|
76
74
|
),
|
|
77
|
-
|
|
75
|
+
_spec.Field(
|
|
78
76
|
name="bytes",
|
|
79
77
|
number=1,
|
|
80
|
-
type=
|
|
78
|
+
type=_spec.PrimitiveType.BYTES,
|
|
81
79
|
),
|
|
82
|
-
|
|
80
|
+
_spec.Field(
|
|
83
81
|
name="f32",
|
|
84
82
|
number=2,
|
|
85
|
-
type=
|
|
83
|
+
type=_spec.PrimitiveType.FLOAT32,
|
|
86
84
|
),
|
|
87
|
-
|
|
85
|
+
_spec.Field(
|
|
88
86
|
name="f64",
|
|
89
87
|
number=3,
|
|
90
|
-
type=
|
|
88
|
+
type=_spec.PrimitiveType.FLOAT64,
|
|
91
89
|
),
|
|
92
|
-
|
|
90
|
+
_spec.Field(
|
|
93
91
|
name="i32",
|
|
94
92
|
number=4,
|
|
95
|
-
type=
|
|
93
|
+
type=_spec.PrimitiveType.INT32,
|
|
96
94
|
),
|
|
97
|
-
|
|
95
|
+
_spec.Field(
|
|
98
96
|
name="i64",
|
|
99
97
|
number=5,
|
|
100
|
-
type=
|
|
98
|
+
type=_spec.PrimitiveType.INT64,
|
|
101
99
|
),
|
|
102
|
-
|
|
100
|
+
_spec.Field(
|
|
103
101
|
name="u64",
|
|
104
102
|
number=6,
|
|
105
|
-
type=
|
|
103
|
+
type=_spec.PrimitiveType.UINT64,
|
|
106
104
|
),
|
|
107
|
-
|
|
105
|
+
_spec.Field(
|
|
108
106
|
name="s",
|
|
109
107
|
number=7,
|
|
110
|
-
type=
|
|
108
|
+
type=_spec.PrimitiveType.STRING,
|
|
111
109
|
),
|
|
112
|
-
|
|
110
|
+
_spec.Field(
|
|
113
111
|
name="t",
|
|
114
112
|
number=8,
|
|
115
|
-
type=
|
|
113
|
+
type=_spec.PrimitiveType.TIMESTAMP,
|
|
116
114
|
),
|
|
117
115
|
),
|
|
118
116
|
),
|
|
119
|
-
|
|
117
|
+
_spec.Struct(
|
|
120
118
|
id="my/module.soia:After",
|
|
121
119
|
fields=(
|
|
122
|
-
|
|
120
|
+
_spec.Field(
|
|
123
121
|
name="points",
|
|
124
122
|
number=0,
|
|
125
|
-
type=
|
|
123
|
+
type=_spec.ArrayType("my/module.soia:Point"),
|
|
126
124
|
has_mutable_getter=True,
|
|
127
125
|
),
|
|
128
126
|
),
|
|
129
127
|
),
|
|
130
|
-
|
|
128
|
+
_spec.Enum(
|
|
131
129
|
id="my/module.soia:PrimaryColor",
|
|
132
130
|
constant_fields=(
|
|
133
|
-
|
|
131
|
+
_spec.ConstantField(
|
|
134
132
|
name="RED",
|
|
135
133
|
number=10,
|
|
136
134
|
),
|
|
137
|
-
|
|
135
|
+
_spec.ConstantField(
|
|
138
136
|
name="GREEN",
|
|
139
137
|
number=20,
|
|
140
138
|
),
|
|
141
|
-
|
|
139
|
+
_spec.ConstantField(
|
|
142
140
|
name="BLUE",
|
|
143
141
|
number=30,
|
|
144
142
|
),
|
|
145
143
|
),
|
|
146
144
|
),
|
|
147
|
-
|
|
145
|
+
_spec.Enum(
|
|
148
146
|
id="my/module.soia:Status",
|
|
149
147
|
constant_fields=(
|
|
150
|
-
|
|
148
|
+
_spec.ConstantField(
|
|
151
149
|
name="OK",
|
|
152
150
|
number=1,
|
|
153
151
|
),
|
|
154
152
|
),
|
|
155
153
|
value_fields=(
|
|
156
|
-
|
|
154
|
+
_spec.ValueField(
|
|
157
155
|
name="error",
|
|
158
156
|
number=2,
|
|
159
|
-
type=
|
|
157
|
+
type=_spec.PrimitiveType.STRING,
|
|
160
158
|
),
|
|
161
159
|
),
|
|
162
160
|
removed_numbers=(1, 4),
|
|
163
161
|
),
|
|
164
|
-
|
|
162
|
+
_spec.Enum(
|
|
165
163
|
id="my/module.soia:JsonValue",
|
|
166
164
|
constant_fields=(
|
|
167
|
-
|
|
165
|
+
_spec.ConstantField(
|
|
168
166
|
name="NULL",
|
|
169
167
|
number=1,
|
|
170
168
|
),
|
|
171
169
|
),
|
|
172
170
|
value_fields=(
|
|
173
|
-
|
|
171
|
+
_spec.ValueField(
|
|
174
172
|
name="bool",
|
|
175
173
|
number=2,
|
|
176
|
-
type=
|
|
174
|
+
type=_spec.PrimitiveType.BOOL,
|
|
177
175
|
),
|
|
178
|
-
|
|
176
|
+
_spec.ValueField(
|
|
179
177
|
name="number",
|
|
180
178
|
number=3,
|
|
181
|
-
type=
|
|
179
|
+
type=_spec.PrimitiveType.FLOAT64,
|
|
182
180
|
),
|
|
183
|
-
|
|
181
|
+
_spec.ValueField(
|
|
184
182
|
name="string",
|
|
185
183
|
number=4,
|
|
186
|
-
type=
|
|
184
|
+
type=_spec.PrimitiveType.STRING,
|
|
187
185
|
),
|
|
188
|
-
|
|
186
|
+
_spec.ValueField(
|
|
189
187
|
name="array",
|
|
190
188
|
number=5,
|
|
191
|
-
type=
|
|
189
|
+
type=_spec.ArrayType("my/module.soia:JsonValue"),
|
|
192
190
|
),
|
|
193
|
-
|
|
191
|
+
_spec.ValueField(
|
|
194
192
|
name="object",
|
|
195
193
|
number=6,
|
|
196
194
|
type="my/module.soia:JsonValue.Object",
|
|
@@ -201,48 +199,48 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
201
199
|
101,
|
|
202
200
|
),
|
|
203
201
|
),
|
|
204
|
-
|
|
202
|
+
_spec.Struct(
|
|
205
203
|
id="my/module.soia:JsonValue.Object",
|
|
206
204
|
fields=(
|
|
207
|
-
|
|
205
|
+
_spec.Field(
|
|
208
206
|
name="entries",
|
|
209
207
|
number=0,
|
|
210
|
-
type=
|
|
208
|
+
type=_spec.ArrayType(
|
|
211
209
|
item="my/module.soia:JsonValue.ObjectEntry",
|
|
212
210
|
key_attributes=("name",),
|
|
213
211
|
),
|
|
214
212
|
),
|
|
215
213
|
),
|
|
216
214
|
),
|
|
217
|
-
|
|
215
|
+
_spec.Struct(
|
|
218
216
|
id="my/module.soia:JsonValue.ObjectEntry",
|
|
219
217
|
fields=(
|
|
220
|
-
|
|
218
|
+
_spec.Field(
|
|
221
219
|
name="name",
|
|
222
220
|
number=0,
|
|
223
|
-
type=
|
|
221
|
+
type=_spec.PrimitiveType.STRING,
|
|
224
222
|
),
|
|
225
|
-
|
|
223
|
+
_spec.Field(
|
|
226
224
|
name="value",
|
|
227
225
|
number=1,
|
|
228
226
|
type="my/module.soia:JsonValue",
|
|
229
227
|
),
|
|
230
228
|
),
|
|
231
229
|
),
|
|
232
|
-
|
|
230
|
+
_spec.Struct(
|
|
233
231
|
id="my/module.soia:Parent",
|
|
234
232
|
fields=(),
|
|
235
233
|
),
|
|
236
|
-
|
|
234
|
+
_spec.Enum(
|
|
237
235
|
id="my/module.soia:Parent.NestedEnum",
|
|
238
236
|
),
|
|
239
|
-
|
|
237
|
+
_spec.Struct(
|
|
240
238
|
id="my/module.soia:Stuff",
|
|
241
239
|
fields=(
|
|
242
|
-
|
|
240
|
+
_spec.Field(
|
|
243
241
|
name="enum_wrappers",
|
|
244
242
|
number=0,
|
|
245
|
-
type=
|
|
243
|
+
type=_spec.ArrayType(
|
|
246
244
|
item="my/module.soia:EnumWrapper",
|
|
247
245
|
key_attributes=(
|
|
248
246
|
"status",
|
|
@@ -252,78 +250,78 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
252
250
|
),
|
|
253
251
|
),
|
|
254
252
|
),
|
|
255
|
-
|
|
253
|
+
_spec.Struct(
|
|
256
254
|
id="my/module.soia:EnumWrapper",
|
|
257
255
|
fields=(
|
|
258
|
-
|
|
256
|
+
_spec.Field(
|
|
259
257
|
name="status",
|
|
260
258
|
number=0,
|
|
261
259
|
type="my/module.soia:Status",
|
|
262
260
|
),
|
|
263
261
|
),
|
|
264
262
|
),
|
|
265
|
-
|
|
263
|
+
_spec.Struct(
|
|
266
264
|
id="my/module.soia:Stuff.Overrides",
|
|
267
265
|
_class_name="NameOverrides",
|
|
268
266
|
_class_qualname="Stuff.NameOverrides",
|
|
269
267
|
fields=(
|
|
270
|
-
|
|
268
|
+
_spec.Field(
|
|
271
269
|
name="x",
|
|
272
270
|
_attribute="y",
|
|
273
271
|
number=0,
|
|
274
|
-
type=
|
|
272
|
+
type=_spec.PrimitiveType.INT32,
|
|
275
273
|
),
|
|
276
274
|
),
|
|
277
275
|
),
|
|
278
|
-
|
|
276
|
+
_spec.Struct(
|
|
279
277
|
id="my/module.soia:RecOuter",
|
|
280
278
|
fields=(
|
|
281
|
-
|
|
279
|
+
_spec.Field(
|
|
282
280
|
name="r",
|
|
283
281
|
number=0,
|
|
284
282
|
type="my/module.soia:RecOuter.RecInner",
|
|
285
283
|
),
|
|
286
284
|
),
|
|
287
285
|
),
|
|
288
|
-
|
|
286
|
+
_spec.Struct(
|
|
289
287
|
id="my/module.soia:RecOuter.RecInner",
|
|
290
288
|
fields=(
|
|
291
|
-
|
|
289
|
+
_spec.Field(
|
|
292
290
|
name="r",
|
|
293
291
|
number=0,
|
|
294
292
|
type="my/module.soia:RecOuter",
|
|
295
293
|
),
|
|
296
294
|
),
|
|
297
295
|
),
|
|
298
|
-
|
|
296
|
+
_spec.Struct(
|
|
299
297
|
id="my/module.soia:Rec",
|
|
300
298
|
fields=(
|
|
301
|
-
|
|
299
|
+
_spec.Field(
|
|
302
300
|
name="r",
|
|
303
301
|
number=0,
|
|
304
302
|
type="my/module.soia:Rec",
|
|
305
303
|
),
|
|
306
|
-
|
|
304
|
+
_spec.Field(
|
|
307
305
|
name="x",
|
|
308
306
|
number=1,
|
|
309
|
-
type=
|
|
307
|
+
type=_spec.PrimitiveType.INT32,
|
|
310
308
|
),
|
|
311
309
|
),
|
|
312
310
|
),
|
|
313
|
-
|
|
311
|
+
_spec.Struct(
|
|
314
312
|
id="my/module.soia:Foobar",
|
|
315
313
|
fields=(
|
|
316
|
-
|
|
314
|
+
_spec.Field(
|
|
317
315
|
name="a",
|
|
318
316
|
number=1,
|
|
319
|
-
type=
|
|
317
|
+
type=_spec.PrimitiveType.INT32,
|
|
320
318
|
),
|
|
321
|
-
|
|
319
|
+
_spec.Field(
|
|
322
320
|
name="b",
|
|
323
321
|
number=3,
|
|
324
|
-
type=
|
|
322
|
+
type=_spec.PrimitiveType.INT32,
|
|
325
323
|
),
|
|
326
|
-
|
|
324
|
+
_spec.Field(
|
|
327
325
|
name="point",
|
|
328
326
|
number=4,
|
|
329
327
|
type="my/module.soia:Point",
|
|
@@ -333,13 +331,13 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
333
331
|
),
|
|
334
332
|
),
|
|
335
333
|
methods=(
|
|
336
|
-
|
|
334
|
+
_spec.Method(
|
|
337
335
|
name="FirstMethod",
|
|
338
336
|
number=-300,
|
|
339
337
|
request_type="my/module.soia:Point",
|
|
340
338
|
response_type="my/module.soia:Shape",
|
|
341
339
|
),
|
|
342
|
-
|
|
340
|
+
_spec.Method(
|
|
343
341
|
name="SecondMethod",
|
|
344
342
|
number=-301,
|
|
345
343
|
request_type="my/module.soia:Point",
|
|
@@ -348,7 +346,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
348
346
|
),
|
|
349
347
|
),
|
|
350
348
|
constants=(
|
|
351
|
-
|
|
349
|
+
_spec.Constant(
|
|
352
350
|
name="C",
|
|
353
351
|
type="my/module.soia:Point",
|
|
354
352
|
json_code="[1.5, 0, 2.5]",
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import unittest
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
Timestamp,
|
|
5
|
-
array_serializer,
|
|
6
|
-
optional_serializer,
|
|
7
|
-
primitive_serializer,
|
|
8
|
-
)
|
|
3
|
+
from soia import Timestamp, array_serializer, optional_serializer, primitive_serializer
|
|
9
4
|
|
|
10
5
|
|
|
11
6
|
class TimestampTestCase(unittest.TestCase):
|
|
@@ -3,8 +3,7 @@ import unittest
|
|
|
3
3
|
from datetime import datetime, timedelta, timezone
|
|
4
4
|
from typing import Any
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
from soialib.timestamp import Timestamp
|
|
6
|
+
from soia import Timestamp
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
class TimestampTestCase(unittest.TestCase):
|
|
@@ -122,6 +121,3 @@ class TimestampTestCase(unittest.TestCase):
|
|
|
122
121
|
repr(Timestamp.MIN),
|
|
123
122
|
"Timestamp(unix_millis=-8640000000000000)",
|
|
124
123
|
)
|
|
125
|
-
|
|
126
|
-
def test_exported_from_soialib(self):
|
|
127
|
-
self.assertIs(soialib.Timestamp, Timestamp)
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
LICENSE
|
|
2
|
-
README
|
|
3
|
-
pyproject.toml
|
|
4
|
-
soia_client.egg-info/PKG-INFO
|
|
5
|
-
soia_client.egg-info/SOURCES.txt
|
|
6
|
-
soia_client.egg-info/dependency_links.txt
|
|
7
|
-
soia_client.egg-info/top_level.txt
|
|
8
|
-
soialib/_.py
|
|
9
|
-
soialib/__init__.py
|
|
10
|
-
soialib/keyed_items.py
|
|
11
|
-
soialib/method.py
|
|
12
|
-
soialib/module_initializer.py
|
|
13
|
-
soialib/never.py
|
|
14
|
-
soialib/reflection.py
|
|
15
|
-
soialib/serializer.py
|
|
16
|
-
soialib/serializers.py
|
|
17
|
-
soialib/service.py
|
|
18
|
-
soialib/service_client.py
|
|
19
|
-
soialib/spec.py
|
|
20
|
-
soialib/timestamp.py
|
|
21
|
-
soialib/impl/__init__.py
|
|
22
|
-
soialib/impl/arrays.py
|
|
23
|
-
soialib/impl/enums.py
|
|
24
|
-
soialib/impl/function_maker.py
|
|
25
|
-
soialib/impl/optionals.py
|
|
26
|
-
soialib/impl/primitives.py
|
|
27
|
-
soialib/impl/repr.py
|
|
28
|
-
soialib/impl/structs.py
|
|
29
|
-
soialib/impl/type_adapter.py
|
|
30
|
-
tests/test_module_initializer.py
|
|
31
|
-
tests/test_serializers.py
|
|
32
|
-
tests/test_timestamp.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
soialib
|
soia_client-1.0.13/soialib/_.py
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
from soialib.keyed_items import KeyedItems
|
|
2
|
-
from soialib.method import Method
|
|
3
|
-
from soialib.serializer import Serializer
|
|
4
|
-
from soialib.serializers import (
|
|
5
|
-
array_serializer,
|
|
6
|
-
optional_serializer,
|
|
7
|
-
primitive_serializer,
|
|
8
|
-
)
|
|
9
|
-
from soialib.service import RequestHeaders, ResponseHeaders, ServiceImpl
|
|
10
|
-
from soialib.service_client import ServiceClient
|
|
11
|
-
from soialib.timestamp import Timestamp
|
|
12
|
-
|
|
13
|
-
__all__ = [
|
|
14
|
-
"KeyedItems",
|
|
15
|
-
"Method",
|
|
16
|
-
"RequestHeaders",
|
|
17
|
-
"ResponseHeaders",
|
|
18
|
-
"Serializer",
|
|
19
|
-
"ServiceImpl",
|
|
20
|
-
"ServiceClient",
|
|
21
|
-
"Timestamp",
|
|
22
|
-
"array_serializer",
|
|
23
|
-
"optional_serializer",
|
|
24
|
-
"primitive_serializer",
|
|
25
|
-
]
|
|
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
|