soia-client 1.0.18__tar.gz → 1.0.20__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.
Files changed (34) hide show
  1. {soia_client-1.0.18 → soia_client-1.0.20}/PKG-INFO +16 -1
  2. soia_client-1.0.20/README.md +14 -0
  3. {soia_client-1.0.18 → soia_client-1.0.20}/pyproject.toml +1 -1
  4. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_impl/service.py +19 -16
  5. {soia_client-1.0.18 → soia_client-1.0.20}/soia_client.egg-info/PKG-INFO +16 -1
  6. {soia_client-1.0.18 → soia_client-1.0.20}/soia_client.egg-info/SOURCES.txt +1 -1
  7. soia_client-1.0.18/README +0 -5
  8. {soia_client-1.0.18 → soia_client-1.0.20}/LICENSE +0 -0
  9. {soia_client-1.0.18 → soia_client-1.0.20}/setup.cfg +0 -0
  10. {soia_client-1.0.18 → soia_client-1.0.20}/soia/__init__.py +0 -0
  11. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_impl/__init__.py +0 -0
  12. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_impl/arrays.py +0 -0
  13. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_impl/enums.py +0 -0
  14. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_impl/function_maker.py +0 -0
  15. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_impl/keyed_items.py +0 -0
  16. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_impl/method.py +0 -0
  17. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_impl/never.py +0 -0
  18. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_impl/optionals.py +0 -0
  19. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_impl/primitives.py +0 -0
  20. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_impl/repr.py +0 -0
  21. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_impl/serializer.py +0 -0
  22. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_impl/serializers.py +0 -0
  23. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_impl/service_client.py +0 -0
  24. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_impl/structs.py +0 -0
  25. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_impl/timestamp.py +0 -0
  26. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_impl/type_adapter.py +0 -0
  27. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_module_initializer.py +0 -0
  28. {soia_client-1.0.18 → soia_client-1.0.20}/soia/_spec.py +0 -0
  29. {soia_client-1.0.18 → soia_client-1.0.20}/soia/reflection.py +0 -0
  30. {soia_client-1.0.18 → soia_client-1.0.20}/soia_client.egg-info/dependency_links.txt +0 -0
  31. {soia_client-1.0.18 → soia_client-1.0.20}/soia_client.egg-info/top_level.txt +0 -0
  32. {soia_client-1.0.18 → soia_client-1.0.20}/tests/test_module_initializer.py +0 -0
  33. {soia_client-1.0.18 → soia_client-1.0.20}/tests/test_serializers.py +0 -0
  34. {soia_client-1.0.18 → soia_client-1.0.20}/tests/test_timestamp.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: soia-client
3
- Version: 1.0.18
3
+ Version: 1.0.20
4
4
  Author-email: Tyler Fibonacci <gepheum@gmail.com>
5
5
  License: MIT License
6
6
 
@@ -32,3 +32,18 @@ Requires-Python: >=3.10
32
32
  Description-Content-Type: text/markdown
33
33
  License-File: LICENSE
34
34
  Dynamic: license-file
35
+
36
+ # Soia Python Client
37
+
38
+ Library imported from Python code generated from soia files.
39
+
40
+ Install with:
41
+ ```shell
42
+ pip install soia-client
43
+ ```
44
+
45
+ See:
46
+
47
+ * [soia](https://github.com/gepheum/soia): home of the soia compiler
48
+ * [soia-python-gen](https://github.com/gepheum/soia-python-gen): soia to Python code generator
49
+ * [soia-python-example](https://github.com/gepheum/soia-python-example): example showing how to use soia's Python code generator in a project
@@ -0,0 +1,14 @@
1
+ # Soia Python Client
2
+
3
+ Library imported from Python code generated from soia files.
4
+
5
+ Install with:
6
+ ```shell
7
+ pip install soia-client
8
+ ```
9
+
10
+ See:
11
+
12
+ * [soia](https://github.com/gepheum/soia): home of the soia compiler
13
+ * [soia-python-gen](https://github.com/gepheum/soia-python-gen): soia to Python code generator
14
+ * [soia-python-example](https://github.com/gepheum/soia-python-example): example showing how to use soia's Python code generator in a project
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "soia-client"
7
- version = "1.0.18"
7
+ version = "1.0.20"
8
8
  description = ""
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Tyler Fibonacci", email = "gepheum@gmail.com" }]
@@ -1,44 +1,47 @@
1
1
  import inspect
2
2
  import json
3
- from collections.abc import Mapping
4
3
  from dataclasses import dataclass
5
- from typing import Any, Callable, Generic, Literal, TypeAlias, Union, cast
4
+ from typing import Any, Callable, Generic, Literal, TypeVar, Union, cast
6
5
 
7
6
  from soia._impl.method import Method, Request, Response
8
7
 
9
- RequestHeaders: TypeAlias = Mapping[str, str]
8
+ RequestHeaders = TypeVar("RequestHeaders")
10
9
 
10
+ ResponseHeaders = TypeVar("ResponseHeaders")
11
11
 
12
- ResponseHeaders: TypeAlias = dict[str, str]
13
12
 
14
-
15
- class Service:
13
+ class Service(Generic[RequestHeaders, ResponseHeaders]):
16
14
  """Wraps around the implementation of a soia service on the server side.
17
15
 
18
16
  Usage: call '.add_method()' to register method implementations, then call
19
17
  '.handle_request()' from the function called by your web framework when an
20
- HTTP request is sent to your service's URL.
18
+ HTTP request is received at your service's endpoint.
21
19
 
22
20
  Example with Flask:
23
21
 
24
22
  from flask import Response, request
23
+ from werkzeug.datastructures import Headers
24
+
25
25
 
26
- soia_service = soia.Service()
27
- soia_service.add_method(...)
28
- soia_service.add_method(...)
26
+ s = soia.Service[Headers, Headers]()
27
+ s.add_method(...)
28
+ s.add_method(...)
29
29
 
30
30
  @app.route("/myapi", methods=["GET", "POST"])
31
31
  def myapi():
32
32
  if request.method == "POST":
33
33
  req_body = request.get_data(as_text=True)
34
34
  else:
35
- req_body = urllib.parse.unquote(request.query_string.decode("utf-8"))
36
- req_headers = dict(request.headers)
37
- raw_response = soia_service.handle_request(req_body, req_headers, {})
35
+ query_string = request.query_string.decode("utf-8")
36
+ req_body = urllib.parse.unquote(query_string)
37
+ req_headers = request.headers
38
+ res_headers = Headers()
39
+ raw_response = s.handle_request(req_body, req_headers, res_headers)
38
40
  return Response(
39
41
  raw_response.data,
40
42
  status=raw_response.status_code,
41
43
  content_type=raw_response.content_type,
44
+ headers=res_headers,
42
45
  )
43
46
  """
44
47
 
@@ -125,7 +128,7 @@ class Service:
125
128
  self,
126
129
  req_body: str,
127
130
  req_headers: RequestHeaders,
128
- res_headers: ResponseHeaders | None,
131
+ res_headers: ResponseHeaders,
129
132
  ) -> RawResponse:
130
133
  if req_body == "list":
131
134
 
@@ -180,7 +183,7 @@ class Service:
180
183
  )
181
184
 
182
185
  try:
183
- res: Any = method_impl.impl(req, req_headers, res_headers or {})
186
+ res: Any = method_impl.impl(req, req_headers, res_headers)
184
187
  except Exception as e:
185
188
  return self.RawResponse(f"server error: {e}", "server-error")
186
189
 
@@ -197,6 +200,6 @@ class Service:
197
200
 
198
201
 
199
202
  @dataclass(frozen=True)
200
- class _MethodImpl(Generic[Request, Response]):
203
+ class _MethodImpl(Generic[Request, Response, RequestHeaders, ResponseHeaders]):
201
204
  method: Method[Request, Response]
202
205
  impl: Callable[[Request, RequestHeaders, ResponseHeaders], Response]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: soia-client
3
- Version: 1.0.18
3
+ Version: 1.0.20
4
4
  Author-email: Tyler Fibonacci <gepheum@gmail.com>
5
5
  License: MIT License
6
6
 
@@ -32,3 +32,18 @@ Requires-Python: >=3.10
32
32
  Description-Content-Type: text/markdown
33
33
  License-File: LICENSE
34
34
  Dynamic: license-file
35
+
36
+ # Soia Python Client
37
+
38
+ Library imported from Python code generated from soia files.
39
+
40
+ Install with:
41
+ ```shell
42
+ pip install soia-client
43
+ ```
44
+
45
+ See:
46
+
47
+ * [soia](https://github.com/gepheum/soia): home of the soia compiler
48
+ * [soia-python-gen](https://github.com/gepheum/soia-python-gen): soia to Python code generator
49
+ * [soia-python-example](https://github.com/gepheum/soia-python-example): example showing how to use soia's Python code generator in a project
@@ -1,5 +1,5 @@
1
1
  LICENSE
2
- README
2
+ README.md
3
3
  pyproject.toml
4
4
  soia/__init__.py
5
5
  soia/_module_initializer.py
soia_client-1.0.18/README DELETED
@@ -1,5 +0,0 @@
1
- python3 -m unittest tests/**.py
2
-
3
- pyright
4
- flake8
5
- black-formatter
File without changes
File without changes
File without changes