protobin 0.0.50__tar.gz → 0.1.0__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.50 → protobin-0.1.0}/PKG-INFO +1 -1
- {protobin-0.0.50 → protobin-0.1.0}/protobin/protocol.py +4 -0
- {protobin-0.0.50 → protobin-0.1.0}/pyproject.toml +1 -1
- {protobin-0.0.50 → protobin-0.1.0}/tests/tests.py +7 -4
- {protobin-0.0.50 → protobin-0.1.0}/.gitignore +0 -0
- {protobin-0.0.50 → protobin-0.1.0}/LICENSE.txt +0 -0
- {protobin-0.0.50 → protobin-0.1.0}/README.md +0 -0
- {protobin-0.0.50 → protobin-0.1.0}/protobin/__init__.py +0 -0
- {protobin-0.0.50 → protobin-0.1.0}/protobin/errors.py +0 -0
- {protobin-0.0.50 → protobin-0.1.0}/protobin/fields.py +0 -0
- {protobin-0.0.50 → protobin-0.1.0}/protobin/interfaces.py +0 -0
- {protobin-0.0.50 → protobin-0.1.0}/protobin/singleton.py +0 -0
- {protobin-0.0.50 → protobin-0.1.0}/tests/codec8.json +0 -0
- {protobin-0.0.50 → protobin-0.1.0}/tests/demo.json +0 -0
- {protobin-0.0.50 → protobin-0.1.0}/tests/demo.yaml +0 -0
- {protobin-0.0.50 → protobin-0.1.0}/tests/teltonika.json +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: protobin
|
|
3
|
-
Version: 0.0
|
|
3
|
+
Version: 0.1.0
|
|
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
|
|
@@ -74,6 +74,7 @@ class Protocol:
|
|
|
74
74
|
self.server = server
|
|
75
75
|
self.headers = {}
|
|
76
76
|
self.codecs = {}
|
|
77
|
+
self.file = file
|
|
77
78
|
if file:
|
|
78
79
|
with open(file, 'r') as f:
|
|
79
80
|
if 'json' in file:
|
|
@@ -85,6 +86,9 @@ class Protocol:
|
|
|
85
86
|
else:
|
|
86
87
|
self.load_format(js)
|
|
87
88
|
|
|
89
|
+
def __str__(self):
|
|
90
|
+
return self.file
|
|
91
|
+
|
|
88
92
|
def load_format(self, js):
|
|
89
93
|
if 'crc' in js:
|
|
90
94
|
self.config_crc(js['crc'])
|
|
@@ -457,10 +457,11 @@ class BasicTest(unittest.TestCase):
|
|
|
457
457
|
self.assertEqual(data, recv)
|
|
458
458
|
|
|
459
459
|
def test_timestamp(self):
|
|
460
|
-
data = {'test': datetime.datetime(
|
|
460
|
+
data = {'test': datetime.datetime(2025, 9, 2, 12, 9, 50, 732000)}
|
|
461
461
|
binary = self.protocol.encode(data, 'timestamp')
|
|
462
462
|
print(binary)
|
|
463
463
|
h, recv = self.protocol.decode(binary)
|
|
464
|
+
print('recv', recv)
|
|
464
465
|
self.assertEqual(data, recv)
|
|
465
466
|
|
|
466
467
|
def test_timestamp6(self):
|
|
@@ -477,12 +478,14 @@ class BasicTest(unittest.TestCase):
|
|
|
477
478
|
self.assertEqual(data, recv)
|
|
478
479
|
|
|
479
480
|
def test_timestamp_default(self):
|
|
480
|
-
data = {'test': datetime.datetime
|
|
481
|
+
data = {'test': datetime.datetime(2025, 9, 2, 12, 9, 50, 732000)}
|
|
482
|
+
# data = {'test': datetime.datetime.now()}
|
|
481
483
|
print(data)
|
|
482
484
|
binary = self.protocol.encode(data, 'timestamp_default')
|
|
483
|
-
print(binary)
|
|
485
|
+
print('mio', binary)
|
|
486
|
+
binary = b'\x54\x44\x3d\x01\x99\x0A\x55\x5D\x8C'
|
|
484
487
|
h, recv = self.protocol.decode(binary)
|
|
485
|
-
print(recv)
|
|
488
|
+
print('edu', recv)
|
|
486
489
|
self.assertEqual(data['test'].replace(microsecond=(data['test'].microsecond // 1000) * 1000), recv['test'])
|
|
487
490
|
|
|
488
491
|
class AdvancedTest(unittest.TestCase):
|
|
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
|