protobin 0.0.38__tar.gz → 0.0.39__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.38 → protobin-0.0.39}/PKG-INFO +1 -1
- {protobin-0.0.38 → protobin-0.0.39}/protobin/errors.py +1 -1
- {protobin-0.0.38 → protobin-0.0.39}/protobin/fields.py +6 -3
- {protobin-0.0.38 → protobin-0.0.39}/pyproject.toml +1 -1
- {protobin-0.0.38 → protobin-0.0.39}/tests/codec8.json +1 -1
- {protobin-0.0.38 → protobin-0.0.39}/tests/teltonika.json +1 -1
- {protobin-0.0.38 → protobin-0.0.39}/tests/tests.py +8 -0
- {protobin-0.0.38 → protobin-0.0.39}/.gitignore +0 -0
- {protobin-0.0.38 → protobin-0.0.39}/LICENSE.txt +0 -0
- {protobin-0.0.38 → protobin-0.0.39}/README.md +0 -0
- {protobin-0.0.38 → protobin-0.0.39}/protobin/__init__.py +0 -0
- {protobin-0.0.38 → protobin-0.0.39}/protobin/interfaces.py +0 -0
- {protobin-0.0.38 → protobin-0.0.39}/protobin/protocol.py +0 -0
- {protobin-0.0.38 → protobin-0.0.39}/protobin/singleton.py +0 -0
- {protobin-0.0.38 → protobin-0.0.39}/tests/demo.json +0 -0
- {protobin-0.0.38 → protobin-0.0.39}/tests/demo.yaml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: protobin
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.39
|
|
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
|
|
@@ -3,7 +3,7 @@ import datetime
|
|
|
3
3
|
import math
|
|
4
4
|
from typing import Union, List
|
|
5
5
|
|
|
6
|
-
from protobin.errors import
|
|
6
|
+
from protobin.errors import DecodeError, FormatError
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
# removed for python 3.8
|
|
@@ -50,7 +50,7 @@ class FieldBase:
|
|
|
50
50
|
def ensure_length(self, binary):
|
|
51
51
|
if self.bytes:
|
|
52
52
|
if len(binary) < self.bytes:
|
|
53
|
-
raise
|
|
53
|
+
raise DecodeError(f'Binary has not enough data for {self}')
|
|
54
54
|
|
|
55
55
|
def from_binary(self, binary):
|
|
56
56
|
raise NotImplementedError()
|
|
@@ -398,7 +398,10 @@ class StringField(FieldBase):
|
|
|
398
398
|
return f'StringField<key: {self.key}, bytes: {self.bytes}>'
|
|
399
399
|
|
|
400
400
|
def from_binary(self, binary):
|
|
401
|
-
|
|
401
|
+
try:
|
|
402
|
+
return binary.decode('utf')
|
|
403
|
+
except UnicodeEncodeError:
|
|
404
|
+
raise DecodeError(f"Can't decode string: {binary}")
|
|
402
405
|
|
|
403
406
|
def split(self, binary):
|
|
404
407
|
if self.bytes:
|
|
@@ -727,3 +727,11 @@ report:
|
|
|
727
727
|
binary = client.encode(data, 'login_status')
|
|
728
728
|
print(binary)
|
|
729
729
|
self.assertEqual(b'P=\x03110\x04roma\x04IO37\x19\x8f', binary)
|
|
730
|
+
|
|
731
|
+
def test_teltonika_login_urbanito(self):
|
|
732
|
+
client = Protocol(file='codec8.json', server=None)
|
|
733
|
+
data = {'company': 'urbanito', 'route': '9802'}
|
|
734
|
+
binary = client.encode(data, 'login_status')
|
|
735
|
+
print(binary)
|
|
736
|
+
self.assertEqual(b'P=\x00\x08urbanito\x049802+\xbf', binary)
|
|
737
|
+
|
|
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
|