protobin 0.0.28__tar.gz → 0.0.30__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.28 → protobin-0.0.30}/PKG-INFO +1 -1
- protobin-0.0.30/protobin/__init__.py +2 -0
- protobin-0.0.30/protobin/singleton.py +18 -0
- {protobin-0.0.28 → protobin-0.0.30}/pyproject.toml +1 -1
- {protobin-0.0.28 → protobin-0.0.30}/tests/tests.py +9 -7
- protobin-0.0.28/protobin/__init__.py +0 -1
- protobin-0.0.28/protobin/singleton.py +0 -17
- {protobin-0.0.28 → protobin-0.0.30}/.gitignore +0 -0
- {protobin-0.0.28 → protobin-0.0.30}/LICENSE.txt +0 -0
- {protobin-0.0.28 → protobin-0.0.30}/README.md +0 -0
- {protobin-0.0.28 → protobin-0.0.30}/protobin/errors.py +0 -0
- {protobin-0.0.28 → protobin-0.0.30}/protobin/fields.py +0 -0
- {protobin-0.0.28 → protobin-0.0.30}/protobin/interfaces.py +0 -0
- {protobin-0.0.28 → protobin-0.0.30}/protobin/protocol.py +0 -0
- {protobin-0.0.28 → protobin-0.0.30}/tests/codec8.json +0 -0
- {protobin-0.0.28 → protobin-0.0.30}/tests/demo.json +0 -0
- {protobin-0.0.28 → protobin-0.0.30}/tests/demo.yaml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: protobin
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.30
|
|
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
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from protobin import Protocol
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ProtobinLoader(object):
|
|
5
|
+
__instance = None
|
|
6
|
+
protocols = {}
|
|
7
|
+
|
|
8
|
+
def __new__(cls, path, server=None):
|
|
9
|
+
if ProtobinLoader.__instance is None:
|
|
10
|
+
ProtobinLoader.__instance = object.__new__(cls)
|
|
11
|
+
return ProtobinLoader.__instance.get(path, server)
|
|
12
|
+
|
|
13
|
+
def get(self, path, server):
|
|
14
|
+
key = f'{path}|{server}'
|
|
15
|
+
if key not in self.protocols:
|
|
16
|
+
print('load protocol', path, server)
|
|
17
|
+
self.protocols[key] = Protocol(file=path, server=server)
|
|
18
|
+
return self.protocols[key]
|
|
@@ -5,7 +5,7 @@ import json
|
|
|
5
5
|
import yaml
|
|
6
6
|
from protobin import Protocol
|
|
7
7
|
from protobin.errors import InputError, FormatError
|
|
8
|
-
from protobin
|
|
8
|
+
from protobin import ProtobinLoader
|
|
9
9
|
|
|
10
10
|
DATA = {
|
|
11
11
|
'positions': [
|
|
@@ -646,9 +646,11 @@ report:
|
|
|
646
646
|
print(header, recv)
|
|
647
647
|
|
|
648
648
|
def test_singleton(self):
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
649
|
+
protocol1 = ProtobinLoader('codec8.json')
|
|
650
|
+
protocol2 = ProtobinLoader('codec8.json')
|
|
651
|
+
protocol3 = ProtobinLoader('codec8.json')
|
|
652
|
+
protocol4 = ProtobinLoader('codec8.json')
|
|
653
|
+
protocol5 = ProtobinLoader('demo.json', server=False)
|
|
654
|
+
protocol6 = ProtobinLoader('demo.json', server=True)
|
|
655
|
+
protocol7 = ProtobinLoader('demo.json', server=True)
|
|
656
|
+
protocol8 = ProtobinLoader('demo.json', server=True)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .protocol import Protocol
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
from protobin import Protocol
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class ProtobinLoader(object):
|
|
5
|
-
__instance = None
|
|
6
|
-
protocols = {}
|
|
7
|
-
|
|
8
|
-
def __new__(cls):
|
|
9
|
-
if ProtobinLoader.__instance is None:
|
|
10
|
-
ProtobinLoader.__instance = object.__new__(cls)
|
|
11
|
-
return ProtobinLoader.__instance
|
|
12
|
-
|
|
13
|
-
def get(self, path):
|
|
14
|
-
if path not in self.protocols:
|
|
15
|
-
# print('load protocol', path)
|
|
16
|
-
self.protocols[path] = Protocol(file=path)
|
|
17
|
-
return self.protocols[path]
|
|
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
|