soia-client 1.1.10__tar.gz → 1.1.12__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.1.10/soia_client.egg-info → soia_client-1.1.12}/PKG-INFO +1 -1
- {soia_client-1.1.10 → soia_client-1.1.12}/pyproject.toml +1 -1
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/primitives.py +22 -8
- {soia_client-1.1.10 → soia_client-1.1.12/soia_client.egg-info}/PKG-INFO +1 -1
- {soia_client-1.1.10 → soia_client-1.1.12}/tests/test_serializers.py +3 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/LICENSE +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/README.md +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/setup.cfg +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/__init__.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/__init__.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/arrays.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/binary.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/enums.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/function_maker.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/keep.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/keyed_items.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/method.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/never.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/optionals.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/repr.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/serializer.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/serializers.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/service.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/service_client.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/structs.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/timestamp.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_impl/type_adapter.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_module_initializer.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/_spec.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia/reflection.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia_client.egg-info/SOURCES.txt +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia_client.egg-info/dependency_links.txt +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/soia_client.egg-info/top_level.txt +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/tests/test_module_initializer.py +0 -0
- {soia_client-1.1.10 → soia_client-1.1.12}/tests/test_timestamp.py +0 -0
|
@@ -66,7 +66,7 @@ class _BoolAdapter(AbstractPrimitiveAdapter[bool]):
|
|
|
66
66
|
def from_json_expr(
|
|
67
67
|
self, json_expr: ExprLike, keep_unrecognized_expr: ExprLike
|
|
68
68
|
) -> Expr:
|
|
69
|
-
return Expr.join("(
|
|
69
|
+
return Expr.join("(", json_expr, " not in (0, '0'))")
|
|
70
70
|
|
|
71
71
|
@staticmethod
|
|
72
72
|
def encode(
|
|
@@ -407,6 +407,13 @@ class _StringAdapter(AbstractPrimitiveAdapter[str]):
|
|
|
407
407
|
STRING_ADAPTER: Final[TypeAdapter] = _StringAdapter()
|
|
408
408
|
|
|
409
409
|
|
|
410
|
+
def _bytes_from_json(json: str) -> bytes:
|
|
411
|
+
if json.startswith("hex:"):
|
|
412
|
+
return bytes.fromhex(json[4:])
|
|
413
|
+
else:
|
|
414
|
+
return base64.b64decode(json)
|
|
415
|
+
|
|
416
|
+
|
|
410
417
|
class _BytesAdapter(AbstractPrimitiveAdapter[bytes]):
|
|
411
418
|
def default_expr(self) -> ExprLike:
|
|
412
419
|
return 'b""'
|
|
@@ -422,18 +429,25 @@ class _BytesAdapter(AbstractPrimitiveAdapter[bytes]):
|
|
|
422
429
|
in_expr: ExprLike,
|
|
423
430
|
readable: bool,
|
|
424
431
|
) -> Expr:
|
|
425
|
-
|
|
426
|
-
Expr.
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
432
|
+
if readable:
|
|
433
|
+
return Expr.join(
|
|
434
|
+
"('hex:' + ",
|
|
435
|
+
in_expr,
|
|
436
|
+
".hex())",
|
|
437
|
+
)
|
|
438
|
+
else:
|
|
439
|
+
return Expr.join(
|
|
440
|
+
Expr.local("b64encode", base64.b64encode),
|
|
441
|
+
"(",
|
|
442
|
+
in_expr,
|
|
443
|
+
").decode('utf-8')",
|
|
444
|
+
)
|
|
431
445
|
|
|
432
446
|
def from_json_expr(
|
|
433
447
|
self, json_expr: ExprLike, keep_unrecognized_expr: ExprLike
|
|
434
448
|
) -> Expr:
|
|
435
449
|
return Expr.join(
|
|
436
|
-
Expr.local("
|
|
450
|
+
Expr.local("bytes_from_json", _bytes_from_json), "(", json_expr, ' or "")'
|
|
437
451
|
)
|
|
438
452
|
|
|
439
453
|
@staticmethod
|
|
@@ -13,6 +13,9 @@ class SerializersTestCase(unittest.TestCase):
|
|
|
13
13
|
self.assertEqual(primitive_serializer("bool").from_json_code("true"), True)
|
|
14
14
|
self.assertEqual(primitive_serializer("bool").from_json_code("false"), False)
|
|
15
15
|
self.assertEqual(primitive_serializer("bool").from_json_code("0"), False)
|
|
16
|
+
self.assertEqual(primitive_serializer("bool").from_json_code('"0"'), False)
|
|
17
|
+
self.assertEqual(primitive_serializer("bool").from_json_code("1"), True)
|
|
18
|
+
self.assertEqual(primitive_serializer("bool").from_json_code('"1"'), True)
|
|
16
19
|
|
|
17
20
|
self.assertEqual(primitive_serializer("int32").to_json_code(7), "7")
|
|
18
21
|
self.assertEqual(
|
|
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
|
|
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
|