protobin 0.0.30__tar.gz → 0.0.31__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.
- {protobin-0.0.30 → protobin-0.0.31}/PKG-INFO +3 -2
- {protobin-0.0.30 → protobin-0.0.31}/protobin/protocol.py +2 -0
- {protobin-0.0.30 → protobin-0.0.31}/pyproject.toml +1 -1
- {protobin-0.0.30 → protobin-0.0.31}/tests/tests.py +32 -2
- {protobin-0.0.30 → protobin-0.0.31}/.gitignore +0 -0
- {protobin-0.0.30 → protobin-0.0.31}/LICENSE.txt +0 -0
- {protobin-0.0.30 → protobin-0.0.31}/README.md +0 -0
- {protobin-0.0.30 → protobin-0.0.31}/protobin/__init__.py +0 -0
- {protobin-0.0.30 → protobin-0.0.31}/protobin/errors.py +0 -0
- {protobin-0.0.30 → protobin-0.0.31}/protobin/fields.py +0 -0
- {protobin-0.0.30 → protobin-0.0.31}/protobin/interfaces.py +0 -0
- {protobin-0.0.30 → protobin-0.0.31}/protobin/singleton.py +0 -0
- {protobin-0.0.30 → protobin-0.0.31}/tests/codec8.json +0 -0
- {protobin-0.0.30 → protobin-0.0.31}/tests/demo.json +0 -0
- {protobin-0.0.30 → protobin-0.0.31}/tests/demo.yaml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: protobin
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.31
|
|
4
4
|
Summary: Python library for encode and decode data in protobin format
|
|
5
5
|
Project-URL: Homepage, https://github.com/drmelectronic/protobin-python
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/drmelectronic/protobin-python/issues
|
|
@@ -28,6 +28,7 @@ License: MIT License
|
|
|
28
28
|
SOFTWARE. 1
|
|
29
29
|
1. en.wikipedia.org
|
|
30
30
|
en.wikipedia.org
|
|
31
|
+
License-File: LICENSE.txt
|
|
31
32
|
Classifier: License :: OSI Approved :: MIT License
|
|
32
33
|
Classifier: Operating System :: OS Independent
|
|
33
34
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -25,6 +25,8 @@ class Format:
|
|
|
25
25
|
input_mode = 'client' if server else 'server'
|
|
26
26
|
output_mode = 'server' if server else 'client'
|
|
27
27
|
for k, f in format[input_mode].items():
|
|
28
|
+
if 'type' not in f:
|
|
29
|
+
raise FormatError(f'Not found type in field {k} of format {name}')
|
|
28
30
|
if f['type'] not in FIELD_MAP:
|
|
29
31
|
raise FormatError(f'Invalid protobin type {f["type"]}')
|
|
30
32
|
self.input_fields.append(FIELD_MAP[f['type']](k, f))
|
|
@@ -451,10 +451,10 @@ report:
|
|
|
451
451
|
'order': 5,
|
|
452
452
|
'logged': False,
|
|
453
453
|
'data': None,
|
|
454
|
-
'schedule':
|
|
454
|
+
'schedule': None
|
|
455
455
|
}
|
|
456
456
|
binary = server.encode(data, 'login')
|
|
457
|
-
print('server', binary)
|
|
457
|
+
print(f'server ({len(binary)})', binary)
|
|
458
458
|
header, recv = client.decode(binary)
|
|
459
459
|
self.assertEqual(header, 'login')
|
|
460
460
|
self.assertEqual(data, recv)
|
|
@@ -645,6 +645,22 @@ report:
|
|
|
645
645
|
header, recv = client.decode(binary)
|
|
646
646
|
print(header, recv)
|
|
647
647
|
|
|
648
|
+
def test_decode_sergio(self):
|
|
649
|
+
val = {'id': '675882972c030d7f86188ee9', 'command': 'C', 'value': 'value'}
|
|
650
|
+
client = Protocol(js={"formats": {"command": {
|
|
651
|
+
"header": "$",
|
|
652
|
+
"server": {
|
|
653
|
+
"comando": {"bytes": 1, "type": "char"},
|
|
654
|
+
"id": {"bytes": 0, "type": "string"},
|
|
655
|
+
"value": {"bytes": 0, "type": "string"}
|
|
656
|
+
},
|
|
657
|
+
"client": {
|
|
658
|
+
"id": {"bytes": 0, "type": "string"}
|
|
659
|
+
}
|
|
660
|
+
}}}, server=True)
|
|
661
|
+
binary = client.encode(val, 'command')
|
|
662
|
+
print(binary)
|
|
663
|
+
|
|
648
664
|
def test_singleton(self):
|
|
649
665
|
protocol1 = ProtobinLoader('codec8.json')
|
|
650
666
|
protocol2 = ProtobinLoader('codec8.json')
|
|
@@ -654,3 +670,17 @@ report:
|
|
|
654
670
|
protocol6 = ProtobinLoader('demo.json', server=True)
|
|
655
671
|
protocol7 = ProtobinLoader('demo.json', server=True)
|
|
656
672
|
protocol8 = ProtobinLoader('demo.json', server=True)
|
|
673
|
+
|
|
674
|
+
def test_error_type(self):
|
|
675
|
+
with self.assertRaises(FormatError):
|
|
676
|
+
Protocol(js={"formats": {"command": {
|
|
677
|
+
"header": "$",
|
|
678
|
+
"server": {
|
|
679
|
+
"comando": {"bytes": 1, "type": "char"},
|
|
680
|
+
"id": {"bytes": 0, "type": "string"},
|
|
681
|
+
"value": {"bytes": 0, "type": "string"}
|
|
682
|
+
},
|
|
683
|
+
"client": {
|
|
684
|
+
"id": {"bytes": 0}
|
|
685
|
+
}
|
|
686
|
+
}}}, server=True)
|
|
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
|