labfreed 0.2.8__py3-none-any.whl → 0.2.9__py3-none-any.whl
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 labfreed might be problematic. Click here for more details.
- labfreed/__init__.py +11 -11
- labfreed/labfreed_infrastructure.py +258 -258
- labfreed/pac_cat/__init__.py +19 -19
- labfreed/pac_cat/category_base.py +51 -51
- labfreed/pac_cat/pac_cat.py +150 -150
- labfreed/pac_cat/predefined_categories.py +200 -200
- labfreed/pac_id/__init__.py +19 -19
- labfreed/pac_id/extension.py +48 -48
- labfreed/pac_id/id_segment.py +89 -89
- labfreed/pac_id/pac_id.py +140 -140
- labfreed/pac_id/url_parser.py +155 -155
- labfreed/pac_id/url_serializer.py +85 -84
- labfreed/pac_id_resolver/__init__.py +2 -2
- labfreed/pac_id_resolver/cit_common.py +81 -81
- labfreed/pac_id_resolver/cit_v1.py +244 -244
- labfreed/pac_id_resolver/cit_v2.py +313 -313
- labfreed/pac_id_resolver/resolver.py +97 -97
- labfreed/pac_id_resolver/services.py +82 -82
- labfreed/qr/__init__.py +1 -1
- labfreed/qr/generate_qr.py +422 -422
- labfreed/trex/__init__.py +16 -16
- labfreed/trex/python_convenience/__init__.py +3 -3
- labfreed/trex/python_convenience/data_table.py +87 -87
- labfreed/trex/python_convenience/pyTREX.py +248 -248
- labfreed/trex/python_convenience/quantity.py +66 -66
- labfreed/trex/table_segment.py +245 -245
- labfreed/trex/trex.py +69 -69
- labfreed/trex/trex_base_models.py +209 -209
- labfreed/trex/value_segments.py +99 -99
- labfreed/utilities/base36.py +82 -82
- labfreed/well_known_extensions/__init__.py +4 -4
- labfreed/well_known_extensions/default_extension_interpreters.py +6 -6
- labfreed/well_known_extensions/display_name_extension.py +40 -40
- labfreed/well_known_extensions/trex_extension.py +30 -30
- labfreed/well_known_keys/gs1/__init__.py +5 -5
- labfreed/well_known_keys/gs1/gs1.py +3 -3
- labfreed/well_known_keys/labfreed/well_known_keys.py +15 -15
- labfreed/well_known_keys/unece/__init__.py +3 -3
- labfreed/well_known_keys/unece/unece_units.py +67 -67
- {labfreed-0.2.8.dist-info → labfreed-0.2.9.dist-info}/METADATA +11 -8
- labfreed-0.2.9.dist-info/RECORD +45 -0
- {labfreed-0.2.8.dist-info → labfreed-0.2.9.dist-info}/licenses/LICENSE +21 -21
- labfreed-0.2.8.dist-info/RECORD +0 -45
- {labfreed-0.2.8.dist-info → labfreed-0.2.9.dist-info}/WHEEL +0 -0
labfreed/utilities/base36.py
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import re
|
|
2
|
-
import string
|
|
3
|
-
|
|
4
|
-
from pydantic import field_validator, RootModel
|
|
5
|
-
|
|
6
|
-
class base36(RootModel[str]):
|
|
7
|
-
@field_validator('root')
|
|
8
|
-
@classmethod
|
|
9
|
-
def validate_format(cls, v: str) -> str:
|
|
10
|
-
if not re.fullmatch(r'[A-Z0-9]*', v):
|
|
11
|
-
raise ValueError("Value must only contain uppercase letters and digits (A-Z, 0-9)")
|
|
12
|
-
return v
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def to_base36(s:str) -> base36:
|
|
16
|
-
"""Takes a string, encodes it in UTF-8 and then as base36 string."""
|
|
17
|
-
utf8_encoded = s.encode('utf-8')
|
|
18
|
-
num = int.from_bytes(utf8_encoded, byteorder='big', signed=False)
|
|
19
|
-
|
|
20
|
-
# note: this cannot be arbitrarily chosen. The choice here corresponds to what pythons int(s:str, base:int=10) function used.
|
|
21
|
-
base36_chars = _alphabet(base=36)
|
|
22
|
-
if num == 0:
|
|
23
|
-
return base36_chars[0]
|
|
24
|
-
base_36 = []
|
|
25
|
-
_num = num
|
|
26
|
-
while _num:
|
|
27
|
-
_num, i = divmod(_num, 36)
|
|
28
|
-
base_36.append(base36_chars[i])
|
|
29
|
-
b36_str = ''.join(reversed(base_36))
|
|
30
|
-
b36_str = base36(b36_str)
|
|
31
|
-
return b36_str
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def from_base36(s36:base36) -> str:
|
|
35
|
-
"""inverse of to_base36"""
|
|
36
|
-
# this built in function interprets each character as number in a base represented by the standartd alphabet [0-9 (A-Z|a-z)][0:base] it is case INsensitive.
|
|
37
|
-
num = int(s36, 36)
|
|
38
|
-
num_bytes = (num.bit_length() + 7) // 8
|
|
39
|
-
_bytes = num.to_bytes(num_bytes, byteorder='big')
|
|
40
|
-
s = _bytes.decode('utf-8')
|
|
41
|
-
return s
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def _alphabet(base):
|
|
45
|
-
""" returns an alphabet, which corresponds to what pythons int(s:str, base:int=10) function used.
|
|
46
|
-
"""
|
|
47
|
-
if base < 2 or base > 36:
|
|
48
|
-
ValueError('base can only be between 2 and 36')
|
|
49
|
-
alphabet = (string.digits + string.ascii_uppercase)[0:base]
|
|
50
|
-
return alphabet
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if __name__ == "__main__":
|
|
54
|
-
ss = ["A",
|
|
55
|
-
"B-500 B",
|
|
56
|
-
"B-500 Ba",
|
|
57
|
-
"B-500 Bal",
|
|
58
|
-
"B-500 Bala",
|
|
59
|
-
"B-500 Balanc",
|
|
60
|
-
"B-500 Balance",
|
|
61
|
-
"B-500 D",
|
|
62
|
-
"Mini Spray Dryer S-300",
|
|
63
|
-
"w3ApashAt!!£NAGDSAF*ç%&/()",
|
|
64
|
-
"HELLOWORLD",
|
|
65
|
-
"Helloworld",
|
|
66
|
-
"$£äö!'?^{]<@#¦&¬|¢)&§°😀你好🌍🏯😇🎵🔥你👻🐉😀你好🌍🏯😇🎵🔥你👻🐉😀你好🌍🏯😇🎵🔥你👻🐉😀你好🌍🏯😇🎵🔥你👻🐉😀你好🌍🏯😇🎵🔥你👻🐉😀你好🌍🏯😇🎵🔥你👻🐉😀你好🌍🏯😇🎵🔥你👻🐉",
|
|
67
|
-
"往跟住!師立甲錯什正再圓身升因月室",
|
|
68
|
-
"Balance BAL500 @☣️Lab",
|
|
69
|
-
"BAL500 @☣️Lab",
|
|
70
|
-
"BAL-CLEAN",
|
|
71
|
-
"Smørrebrød µ-Nutrients",
|
|
72
|
-
"Demo Result from R-300",
|
|
73
|
-
"Rotavapor R-300",
|
|
74
|
-
"Rotavapor R-250",
|
|
75
|
-
"Rotavapor R-220",
|
|
76
|
-
"SyncorePlus"
|
|
77
|
-
]
|
|
78
|
-
for s in ss:
|
|
79
|
-
s36 = to_base36(s)
|
|
80
|
-
s_back = from_base36(s36)
|
|
81
|
-
identical = (s == s_back)
|
|
82
|
-
print(f'{s} >> {s36} >> {s_back}: match:{identical}')
|
|
1
|
+
import re
|
|
2
|
+
import string
|
|
3
|
+
|
|
4
|
+
from pydantic import field_validator, RootModel
|
|
5
|
+
|
|
6
|
+
class base36(RootModel[str]):
|
|
7
|
+
@field_validator('root')
|
|
8
|
+
@classmethod
|
|
9
|
+
def validate_format(cls, v: str) -> str:
|
|
10
|
+
if not re.fullmatch(r'[A-Z0-9]*', v):
|
|
11
|
+
raise ValueError("Value must only contain uppercase letters and digits (A-Z, 0-9)")
|
|
12
|
+
return v
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def to_base36(s:str) -> base36:
|
|
16
|
+
"""Takes a string, encodes it in UTF-8 and then as base36 string."""
|
|
17
|
+
utf8_encoded = s.encode('utf-8')
|
|
18
|
+
num = int.from_bytes(utf8_encoded, byteorder='big', signed=False)
|
|
19
|
+
|
|
20
|
+
# note: this cannot be arbitrarily chosen. The choice here corresponds to what pythons int(s:str, base:int=10) function used.
|
|
21
|
+
base36_chars = _alphabet(base=36)
|
|
22
|
+
if num == 0:
|
|
23
|
+
return base36_chars[0]
|
|
24
|
+
base_36 = []
|
|
25
|
+
_num = num
|
|
26
|
+
while _num:
|
|
27
|
+
_num, i = divmod(_num, 36)
|
|
28
|
+
base_36.append(base36_chars[i])
|
|
29
|
+
b36_str = ''.join(reversed(base_36))
|
|
30
|
+
b36_str = base36(b36_str)
|
|
31
|
+
return b36_str
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def from_base36(s36:base36) -> str:
|
|
35
|
+
"""inverse of to_base36"""
|
|
36
|
+
# this built in function interprets each character as number in a base represented by the standartd alphabet [0-9 (A-Z|a-z)][0:base] it is case INsensitive.
|
|
37
|
+
num = int(s36, 36)
|
|
38
|
+
num_bytes = (num.bit_length() + 7) // 8
|
|
39
|
+
_bytes = num.to_bytes(num_bytes, byteorder='big')
|
|
40
|
+
s = _bytes.decode('utf-8')
|
|
41
|
+
return s
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _alphabet(base):
|
|
45
|
+
""" returns an alphabet, which corresponds to what pythons int(s:str, base:int=10) function used.
|
|
46
|
+
"""
|
|
47
|
+
if base < 2 or base > 36:
|
|
48
|
+
ValueError('base can only be between 2 and 36')
|
|
49
|
+
alphabet = (string.digits + string.ascii_uppercase)[0:base]
|
|
50
|
+
return alphabet
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
if __name__ == "__main__":
|
|
54
|
+
ss = ["A",
|
|
55
|
+
"B-500 B",
|
|
56
|
+
"B-500 Ba",
|
|
57
|
+
"B-500 Bal",
|
|
58
|
+
"B-500 Bala",
|
|
59
|
+
"B-500 Balanc",
|
|
60
|
+
"B-500 Balance",
|
|
61
|
+
"B-500 D",
|
|
62
|
+
"Mini Spray Dryer S-300",
|
|
63
|
+
"w3ApashAt!!£NAGDSAF*ç%&/()",
|
|
64
|
+
"HELLOWORLD",
|
|
65
|
+
"Helloworld",
|
|
66
|
+
"$£äö!'?^{]<@#¦&¬|¢)&§°😀你好🌍🏯😇🎵🔥你👻🐉😀你好🌍🏯😇🎵🔥你👻🐉😀你好🌍🏯😇🎵🔥你👻🐉😀你好🌍🏯😇🎵🔥你👻🐉😀你好🌍🏯😇🎵🔥你👻🐉😀你好🌍🏯😇🎵🔥你👻🐉😀你好🌍🏯😇🎵🔥你👻🐉",
|
|
67
|
+
"往跟住!師立甲錯什正再圓身升因月室",
|
|
68
|
+
"Balance BAL500 @☣️Lab",
|
|
69
|
+
"BAL500 @☣️Lab",
|
|
70
|
+
"BAL-CLEAN",
|
|
71
|
+
"Smørrebrød µ-Nutrients",
|
|
72
|
+
"Demo Result from R-300",
|
|
73
|
+
"Rotavapor R-300",
|
|
74
|
+
"Rotavapor R-250",
|
|
75
|
+
"Rotavapor R-220",
|
|
76
|
+
"SyncorePlus"
|
|
77
|
+
]
|
|
78
|
+
for s in ss:
|
|
79
|
+
s36 = to_base36(s)
|
|
80
|
+
s_back = from_base36(s36)
|
|
81
|
+
identical = (s == s_back)
|
|
82
|
+
print(f'{s} >> {s36} >> {s_back}: match:{identical}')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
from .display_name_extension import DisplayNameExtension
|
|
2
|
-
from .trex_extension import TREX_Extension
|
|
3
|
-
from .default_extension_interpreters import default_extension_interpreters # noqa: F401
|
|
4
|
-
|
|
1
|
+
from .display_name_extension import DisplayNameExtension
|
|
2
|
+
from .trex_extension import TREX_Extension
|
|
3
|
+
from .default_extension_interpreters import default_extension_interpreters # noqa: F401
|
|
4
|
+
|
|
5
5
|
__all__ = ["DisplayNameExtension", "TREX_Extension"]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
from .display_name_extension import DisplayNameExtension
|
|
2
|
-
from .trex_extension import TREX_Extension
|
|
3
|
-
|
|
4
|
-
default_extension_interpreters = {
|
|
5
|
-
'TREX': TREX_Extension,
|
|
6
|
-
'N': DisplayNameExtension
|
|
1
|
+
from .display_name_extension import DisplayNameExtension
|
|
2
|
+
from .trex_extension import TREX_Extension
|
|
3
|
+
|
|
4
|
+
default_extension_interpreters = {
|
|
5
|
+
'TREX': TREX_Extension,
|
|
6
|
+
'N': DisplayNameExtension
|
|
7
7
|
}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
from typing import Literal, Self
|
|
3
|
-
from pydantic import computed_field
|
|
4
|
-
from labfreed.labfreed_infrastructure import LabFREED_BaseModel
|
|
5
|
-
from labfreed.pac_id.extension import ExtensionBase
|
|
6
|
-
from labfreed.utilities.base36 import from_base36, to_base36
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class DisplayNameExtension(ExtensionBase, LabFREED_BaseModel):
|
|
10
|
-
name:Literal['N'] = 'N'
|
|
11
|
-
type:Literal['N'] = 'N'
|
|
12
|
-
display_name: str
|
|
13
|
-
|
|
14
|
-
@computed_field
|
|
15
|
-
@property
|
|
16
|
-
def data(self)->str:
|
|
17
|
-
# return '/'.join([to_base36(dn) for dn in self.display_name])
|
|
18
|
-
return to_base36(self.display_name).root
|
|
19
|
-
|
|
20
|
-
@staticmethod
|
|
21
|
-
def from_extension(ext:ExtensionBase) -> Self:
|
|
22
|
-
return DisplayNameExtension.create(name=ext.name,
|
|
23
|
-
type=ext.type,
|
|
24
|
-
data=ext.data)
|
|
25
|
-
|
|
26
|
-
@staticmethod
|
|
27
|
-
def create(*, name, type, data):
|
|
28
|
-
if name != 'N':
|
|
29
|
-
logging.warning(f'Name {name} was given, but this extension should only be used with name "N". Will ignore input')
|
|
30
|
-
|
|
31
|
-
if type != 'N':
|
|
32
|
-
logging.warning(f'Type {name} was given, but this extension should only be used with type "N". Will try to parse data as display names')
|
|
33
|
-
|
|
34
|
-
display_name = from_base36(data)
|
|
35
|
-
|
|
36
|
-
return DisplayNameExtension(display_name=display_name)
|
|
37
|
-
|
|
38
|
-
def __str__(self):
|
|
39
|
-
return 'Display name: '+ self.display_name
|
|
40
|
-
|
|
1
|
+
import logging
|
|
2
|
+
from typing import Literal, Self
|
|
3
|
+
from pydantic import computed_field
|
|
4
|
+
from labfreed.labfreed_infrastructure import LabFREED_BaseModel
|
|
5
|
+
from labfreed.pac_id.extension import ExtensionBase
|
|
6
|
+
from labfreed.utilities.base36 import from_base36, to_base36
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class DisplayNameExtension(ExtensionBase, LabFREED_BaseModel):
|
|
10
|
+
name:Literal['N'] = 'N'
|
|
11
|
+
type:Literal['N'] = 'N'
|
|
12
|
+
display_name: str
|
|
13
|
+
|
|
14
|
+
@computed_field
|
|
15
|
+
@property
|
|
16
|
+
def data(self)->str:
|
|
17
|
+
# return '/'.join([to_base36(dn) for dn in self.display_name])
|
|
18
|
+
return to_base36(self.display_name).root
|
|
19
|
+
|
|
20
|
+
@staticmethod
|
|
21
|
+
def from_extension(ext:ExtensionBase) -> Self:
|
|
22
|
+
return DisplayNameExtension.create(name=ext.name,
|
|
23
|
+
type=ext.type,
|
|
24
|
+
data=ext.data)
|
|
25
|
+
|
|
26
|
+
@staticmethod
|
|
27
|
+
def create(*, name, type, data):
|
|
28
|
+
if name != 'N':
|
|
29
|
+
logging.warning(f'Name {name} was given, but this extension should only be used with name "N". Will ignore input')
|
|
30
|
+
|
|
31
|
+
if type != 'N':
|
|
32
|
+
logging.warning(f'Type {name} was given, but this extension should only be used with type "N". Will try to parse data as display names')
|
|
33
|
+
|
|
34
|
+
display_name = from_base36(data)
|
|
35
|
+
|
|
36
|
+
return DisplayNameExtension(display_name=display_name)
|
|
37
|
+
|
|
38
|
+
def __str__(self):
|
|
39
|
+
return 'Display name: '+ self.display_name
|
|
40
|
+
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
from typing import Literal, Self
|
|
2
|
-
|
|
3
|
-
from pydantic import computed_field
|
|
4
|
-
from labfreed.labfreed_infrastructure import LabFREED_BaseModel
|
|
5
|
-
from labfreed.pac_id.extension import ExtensionBase
|
|
6
|
-
from labfreed.trex.trex import TREX
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class TREX_Extension(ExtensionBase, LabFREED_BaseModel):
|
|
10
|
-
name:str
|
|
11
|
-
type:Literal['TREX'] = 'TREX'
|
|
12
|
-
trex:TREX
|
|
13
|
-
|
|
14
|
-
@computed_field
|
|
15
|
-
@property
|
|
16
|
-
def data(self)->str:
|
|
17
|
-
trex_str = self.trex.serialize()
|
|
18
|
-
return trex_str
|
|
19
|
-
|
|
20
|
-
@staticmethod
|
|
21
|
-
def from_extension(ext:ExtensionBase) -> Self:
|
|
22
|
-
return TREX_Extension.create(name=ext.name,
|
|
23
|
-
type=ext.type,
|
|
24
|
-
data=ext.data)
|
|
25
|
-
|
|
26
|
-
@staticmethod
|
|
27
|
-
def create(*, name, data, type='TREX'):
|
|
28
|
-
trex_extension = TREX_Extension(name= name, trex = TREX.deserialize(data))
|
|
29
|
-
return trex_extension
|
|
30
|
-
|
|
1
|
+
from typing import Literal, Self
|
|
2
|
+
|
|
3
|
+
from pydantic import computed_field
|
|
4
|
+
from labfreed.labfreed_infrastructure import LabFREED_BaseModel
|
|
5
|
+
from labfreed.pac_id.extension import ExtensionBase
|
|
6
|
+
from labfreed.trex.trex import TREX
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TREX_Extension(ExtensionBase, LabFREED_BaseModel):
|
|
10
|
+
name:str
|
|
11
|
+
type:Literal['TREX'] = 'TREX'
|
|
12
|
+
trex:TREX
|
|
13
|
+
|
|
14
|
+
@computed_field
|
|
15
|
+
@property
|
|
16
|
+
def data(self)->str:
|
|
17
|
+
trex_str = self.trex.serialize()
|
|
18
|
+
return trex_str
|
|
19
|
+
|
|
20
|
+
@staticmethod
|
|
21
|
+
def from_extension(ext:ExtensionBase) -> Self:
|
|
22
|
+
return TREX_Extension.create(name=ext.name,
|
|
23
|
+
type=ext.type,
|
|
24
|
+
data=ext.data)
|
|
25
|
+
|
|
26
|
+
@staticmethod
|
|
27
|
+
def create(*, name, data, type='TREX'):
|
|
28
|
+
trex_extension = TREX_Extension(name= name, trex = TREX.deserialize(data))
|
|
29
|
+
return trex_extension
|
|
30
|
+
|
|
31
31
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
'''
|
|
2
|
-
Data from
|
|
3
|
-
https://ref.gs1.org/ai/GS1_Application_Identifiers.jsonld
|
|
4
|
-
|
|
5
|
-
processes by ChatGPT
|
|
1
|
+
'''
|
|
2
|
+
Data from
|
|
3
|
+
https://ref.gs1.org/ai/GS1_Application_Identifiers.jsonld
|
|
4
|
+
|
|
5
|
+
processes by ChatGPT
|
|
6
6
|
'''
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'''
|
|
2
|
-
Data from
|
|
3
|
-
https://ref.gs1.org/ai/GS1_Application_Identifiers.jsonld
|
|
1
|
+
'''
|
|
2
|
+
Data from
|
|
3
|
+
https://ref.gs1.org/ai/GS1_Application_Identifiers.jsonld
|
|
4
4
|
'''
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
from enum import Enum
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class WellKnownKeys(Enum):
|
|
5
|
-
GTIN = '01'
|
|
6
|
-
BATCH = '10'
|
|
7
|
-
SERIAL = '21'
|
|
8
|
-
ADDITIONAL_IDINTIFIER = '240'
|
|
9
|
-
RUN_ID_ABSOLUTE = 'RNR'
|
|
10
|
-
SAMPLE_ID = 'SMP'
|
|
11
|
-
EXPERIMENT_ID = 'EXP'
|
|
12
|
-
RESULT_ID = 'RST'
|
|
13
|
-
METHOD_ID = 'MTD'
|
|
14
|
-
REPORT_ID = 'RPT'
|
|
15
|
-
TIMESTAMP = 'TS'
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class WellKnownKeys(Enum):
|
|
5
|
+
GTIN = '01'
|
|
6
|
+
BATCH = '10'
|
|
7
|
+
SERIAL = '21'
|
|
8
|
+
ADDITIONAL_IDINTIFIER = '240'
|
|
9
|
+
RUN_ID_ABSOLUTE = 'RNR'
|
|
10
|
+
SAMPLE_ID = 'SMP'
|
|
11
|
+
EXPERIMENT_ID = 'EXP'
|
|
12
|
+
RESULT_ID = 'RST'
|
|
13
|
+
METHOD_ID = 'MTD'
|
|
14
|
+
REPORT_ID = 'RPT'
|
|
15
|
+
TIMESTAMP = 'TS'
|
|
16
16
|
VERSION = 'V'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'''
|
|
2
|
-
Data from
|
|
3
|
-
https://github.com/quadient/unece-units/blob/main/python/src/unece_excel_parser/parsedUneceUnits.json
|
|
1
|
+
'''
|
|
2
|
+
Data from
|
|
3
|
+
https://github.com/quadient/unece-units/blob/main/python/src/unece_excel_parser/parsedUneceUnits.json
|
|
4
4
|
'''
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
from functools import cache
|
|
2
|
-
import json
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@cache
|
|
9
|
-
def unece_units() -> list[dict]:
|
|
10
|
-
p = Path(__file__).parent / 'UneceUnits.json'
|
|
11
|
-
with open(p) as f:
|
|
12
|
-
l = json.load(f) # noqa: E741
|
|
13
|
-
return l
|
|
14
|
-
|
|
15
|
-
@cache
|
|
16
|
-
def unece_unit_codes():
|
|
17
|
-
codes= [u.get('commonCode') for u in unece_units() if u.get('state') == 'ACTIVE']
|
|
18
|
-
return codes
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def unece_unit(unit_code):
|
|
22
|
-
unit = [u for u in unece_units() if u['commonCode'] == unit_code]
|
|
23
|
-
if len(unit) == 0:
|
|
24
|
-
return None
|
|
25
|
-
else:
|
|
26
|
-
return unit[0]
|
|
27
|
-
|
|
28
|
-
def unit_symbol(unit:dict) ->str:
|
|
29
|
-
return unit.get('symbol')
|
|
30
|
-
|
|
31
|
-
def unit_name(unit:dict) ->str:
|
|
32
|
-
return unit.get('name')
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
# def check_compatibility_unece_quantities():
|
|
37
|
-
# unece = unece_units()
|
|
38
|
-
# print(f'Number of units in file: {len(unece)}')
|
|
39
|
-
|
|
40
|
-
# failed = list()
|
|
41
|
-
# success = list()
|
|
42
|
-
# for u in unece:
|
|
43
|
-
# if u.get('state') == 'ACTIVE':
|
|
44
|
-
# try:
|
|
45
|
-
# if not u.get('symbol'):
|
|
46
|
-
# assert False
|
|
47
|
-
# u.get('name')
|
|
48
|
-
# validate_unit(u.get('symbol'))
|
|
49
|
-
# success.append(u)
|
|
50
|
-
# except AssertionError:
|
|
51
|
-
# failed.append(u)
|
|
52
|
-
# else:
|
|
53
|
-
# pass
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
# print('[blue] FAILED [/blue]')
|
|
58
|
-
# for u in failed:
|
|
59
|
-
# print(f'{u.get('commonCode')}: {u.get('name')}')
|
|
60
|
-
|
|
61
|
-
# print('[yellow] SUCCESSFUL [/yellow]')
|
|
62
|
-
# for u in success:
|
|
63
|
-
# print(u)
|
|
64
|
-
|
|
65
|
-
# print(f'{len(failed)} / {len(unece)} failed to convert')
|
|
66
|
-
|
|
67
|
-
|
|
1
|
+
from functools import cache
|
|
2
|
+
import json
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@cache
|
|
9
|
+
def unece_units() -> list[dict]:
|
|
10
|
+
p = Path(__file__).parent / 'UneceUnits.json'
|
|
11
|
+
with open(p) as f:
|
|
12
|
+
l = json.load(f) # noqa: E741
|
|
13
|
+
return l
|
|
14
|
+
|
|
15
|
+
@cache
|
|
16
|
+
def unece_unit_codes():
|
|
17
|
+
codes= [u.get('commonCode') for u in unece_units() if u.get('state') == 'ACTIVE']
|
|
18
|
+
return codes
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def unece_unit(unit_code):
|
|
22
|
+
unit = [u for u in unece_units() if u['commonCode'] == unit_code]
|
|
23
|
+
if len(unit) == 0:
|
|
24
|
+
return None
|
|
25
|
+
else:
|
|
26
|
+
return unit[0]
|
|
27
|
+
|
|
28
|
+
def unit_symbol(unit:dict) ->str:
|
|
29
|
+
return unit.get('symbol')
|
|
30
|
+
|
|
31
|
+
def unit_name(unit:dict) ->str:
|
|
32
|
+
return unit.get('name')
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# def check_compatibility_unece_quantities():
|
|
37
|
+
# unece = unece_units()
|
|
38
|
+
# print(f'Number of units in file: {len(unece)}')
|
|
39
|
+
|
|
40
|
+
# failed = list()
|
|
41
|
+
# success = list()
|
|
42
|
+
# for u in unece:
|
|
43
|
+
# if u.get('state') == 'ACTIVE':
|
|
44
|
+
# try:
|
|
45
|
+
# if not u.get('symbol'):
|
|
46
|
+
# assert False
|
|
47
|
+
# u.get('name')
|
|
48
|
+
# validate_unit(u.get('symbol'))
|
|
49
|
+
# success.append(u)
|
|
50
|
+
# except AssertionError:
|
|
51
|
+
# failed.append(u)
|
|
52
|
+
# else:
|
|
53
|
+
# pass
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# print('[blue] FAILED [/blue]')
|
|
58
|
+
# for u in failed:
|
|
59
|
+
# print(f'{u.get('commonCode')}: {u.get('name')}')
|
|
60
|
+
|
|
61
|
+
# print('[yellow] SUCCESSFUL [/yellow]')
|
|
62
|
+
# for u in success:
|
|
63
|
+
# print(u)
|
|
64
|
+
|
|
65
|
+
# print(f'{len(failed)} / {len(unece)} failed to convert')
|
|
66
|
+
|
|
67
|
+
|
|
68
68
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: labfreed
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.9
|
|
4
4
|
Summary: Python implementation of LabFREED building blocks
|
|
5
5
|
Author-email: Reto Thürer <thuerer.r@buchi.com>
|
|
6
6
|
Requires-Python: >=3.11
|
|
@@ -106,7 +106,7 @@ pac.print_validation_messages()
|
|
|
106
106
|
>> Validation Results
|
|
107
107
|
>> ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
|
108
108
|
>> │ **RECOMMENDATION** in id segment value bal500 │
|
|
109
|
-
>> │ Characters '
|
|
109
|
+
>> │ Characters 'l','a','b' should not be used., Characters SHOULD be limited to upper case letters (A-Z), numbers (0-9), '-' and '+' │
|
|
110
110
|
>> │ │
|
|
111
111
|
>> │ HTTPS://PAC.METTORIUS.COM/-MD/👉bal👈500/@1234 │
|
|
112
112
|
>> ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
@@ -116,7 +116,7 @@ pac.print_validation_messages()
|
|
|
116
116
|
>> │ HTTPS://PAC.METTORIUS.COM/-MD/bal500/👉@👈1234 │
|
|
117
117
|
>> ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
118
118
|
>> │ **RECOMMENDATION** in id segment value bal500 │
|
|
119
|
-
>> │ Characters '
|
|
119
|
+
>> │ Characters 'l','a','b' should not be used., Characters SHOULD be limited to upper case letters (A-Z), numbers (0-9), '-' and '+' │
|
|
120
120
|
>> │ │
|
|
121
121
|
>> │ HTTPS://PAC.METTORIUS.COM/-MD/👉bal👈500/@1234 │
|
|
122
122
|
>> ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
@@ -249,7 +249,7 @@ trex.print_validation_messages()
|
|
|
249
249
|
>> Validation Results
|
|
250
250
|
>> ┌────────────────────────────────────────────────────────────┐
|
|
251
251
|
>> │ **ERROR** in TREX table column Date │
|
|
252
|
-
>> │ Column header key contains invalid characters: '
|
|
252
|
+
>> │ Column header key contains invalid characters: 'e','t','a' │
|
|
253
253
|
>> │ │
|
|
254
254
|
>> │ STOP$T.D:20240505T1306 │
|
|
255
255
|
>> │ +TEMP$KEL:10.15 │
|
|
@@ -257,9 +257,9 @@ trex.print_validation_messages()
|
|
|
257
257
|
>> │ +COMMENT$T.A:FOO │
|
|
258
258
|
>> │ +COMMENT2$T.T:12G3 │
|
|
259
259
|
>> │ +TABLE$$DURATION$HUR:D👉ate👈$T.D:OK$T.B:COMMENT$T.A:: │
|
|
260
|
-
>> │ 1:
|
|
261
|
-
>> │ 1.1:
|
|
262
|
-
>> │ 1.3:
|
|
260
|
+
>> │ 1:20250522T163256.043:T:FOO:: │
|
|
261
|
+
>> │ 1.1:20250522T163256.043:T:BAR:: │
|
|
262
|
+
>> │ 1.3:20250522T163256.043:F:BLUBB │
|
|
263
263
|
>> └────────────────────────────────────────────────────────────┘
|
|
264
264
|
```
|
|
265
265
|
#### Combine PAC-ID and TREX and serialize
|
|
@@ -271,7 +271,7 @@ pac_str = pac.to_url()
|
|
|
271
271
|
print(pac_str)
|
|
272
272
|
```
|
|
273
273
|
```text
|
|
274
|
-
>> HTTPS://PAC.METTORIUS.COM/21:1234*MYTREX$TREX/STOP$T.D:20240505T1306+TEMP$KEL:10.15+OK$T.B:F+COMMENT$T.A:FOO+COMMENT2$T.T:12G3+TABLE$$DURATION$HUR:Date$T.D:OK$T.B:COMMENT$T.A::1:
|
|
274
|
+
>> HTTPS://PAC.METTORIUS.COM/21:1234*MYTREX$TREX/STOP$T.D:20240505T1306+TEMP$KEL:10.15+OK$T.B:F+COMMENT$T.A:FOO+COMMENT2$T.T:12G3+TABLE$$DURATION$HUR:Date$T.D:OK$T.B:COMMENT$T.A::1:20250522T163256.043:T:FOO::1.1:20250522T163256.043:T:BAR::1.3:20250522T163256.043:F:BLUBB
|
|
275
275
|
```
|
|
276
276
|
## PAC-ID Resolver
|
|
277
277
|
|
|
@@ -332,6 +332,9 @@ for sg in service_groups:
|
|
|
332
332
|
|
|
333
333
|
<!-- BEGIN CHANGELOG -->
|
|
334
334
|
## Change Log
|
|
335
|
+
### v0.2.9
|
|
336
|
+
- bugfix in serialization of PAC-CAT with multiple categories
|
|
337
|
+
|
|
335
338
|
### v0.2.8
|
|
336
339
|
- option to pass cache to resolver for speedier check of service availability
|
|
337
340
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
labfreed/__init__.py,sha256=MESGKPVXWMtef1oYbq_A-tK2W2uS94Qh63a6JhSivJ0,336
|
|
2
|
+
labfreed/labfreed_infrastructure.py,sha256=EPDSCaGxWakAoPpHyc6ltf-pOuKyS5829lj_EG6wa74,10072
|
|
3
|
+
labfreed/pac_cat/__init__.py,sha256=KNPtQzBD1XVohvG_ucOs7RJj-oi6biUTGB1k-T2o6pk,568
|
|
4
|
+
labfreed/pac_cat/category_base.py,sha256=lFQNiTUukyhWdaSCAI7CZxLtj6kNtnBCE4UsePwsGqE,1801
|
|
5
|
+
labfreed/pac_cat/pac_cat.py,sha256=AJUYDsyGOHy-sRRpXpY0awtbf3HCvn3RhMax6ofvYRA,5318
|
|
6
|
+
labfreed/pac_cat/predefined_categories.py,sha256=5wnMCj-CrACV2W4lH13w7qynWIwi506G3uLNcxuJQGg,8832
|
|
7
|
+
labfreed/pac_id/__init__.py,sha256=NGMbzkwQ4txKeT5pxdIZordwHO8J3_q84jzPanjKoHg,675
|
|
8
|
+
labfreed/pac_id/extension.py,sha256=zuHI8e51otPbpO1r1xDFh32uXTT8L5pCJn74B-aOUpI,1112
|
|
9
|
+
labfreed/pac_id/id_segment.py,sha256=r5JU1SJuRXhZJJxy5T3xjrb598wIDTLpivSJhIUAzjQ,4526
|
|
10
|
+
labfreed/pac_id/pac_id.py,sha256=PyOa5y2IVLEcmj7ZkFuURC1lrP3BU0Yj8pzAllhtatw,5309
|
|
11
|
+
labfreed/pac_id/url_parser.py,sha256=TAQHxFf7Li8GA517mfOivmnJAJgh782oaSDzmOOkyTE,5942
|
|
12
|
+
labfreed/pac_id/url_serializer.py,sha256=Thh41ejth2xv5OcvLDlhVMAzKvu4bDX563cQbJHMxFc,3301
|
|
13
|
+
labfreed/pac_id_resolver/__init__.py,sha256=RNBlrDOSR42gmSNH9wJVhK_xwEX45cvTKVgWW2bjh7Q,113
|
|
14
|
+
labfreed/pac_id_resolver/cit_common.py,sha256=xEkSSumj_IYgnXn3yKvoTBbgExnIfPY7E-RHU-7pcX8,2905
|
|
15
|
+
labfreed/pac_id_resolver/cit_v1.py,sha256=W7UCO0Gm0w09FSo_USFB1-V2tl3iErDxoe2OHh4fkvc,9383
|
|
16
|
+
labfreed/pac_id_resolver/cit_v2.py,sha256=wM1wf8UWbepatWNgkJ3l0l-HNJHqsqqPMql5k8fkVso,12127
|
|
17
|
+
labfreed/pac_id_resolver/resolver.py,sha256=UfSxRwTTjSgL4VoHfsQiaGTj3tt8dTDDd2wVcbr2Xvc,2817
|
|
18
|
+
labfreed/pac_id_resolver/services.py,sha256=fCt-CBUKoEm4-SZqlkt94Or-BnmJ91Q5kZO9ydPw55s,2609
|
|
19
|
+
labfreed/qr/__init__.py,sha256=fdKwP6W2Js--yMbBUdn-g_2uq2VqPpfQJeDLHsMDO-Y,61
|
|
20
|
+
labfreed/qr/generate_qr.py,sha256=mSt-U872O3ReHB_UdS-MzYu0wRgdlKcAOEfTxg5CLRk,16616
|
|
21
|
+
labfreed/trex/__init__.py,sha256=r0MYrGk_XxsqSKo9c2i9jRXApTDeTZD8QRXcRpkOVXY,428
|
|
22
|
+
labfreed/trex/table_segment.py,sha256=qlItBK1x3Qr7KUSM_L6dcmv3Y2fNhiqTaiXbXm5BKs0,9154
|
|
23
|
+
labfreed/trex/trex.py,sha256=WDoPvuhiilLtRSIkntCmDGkFBnD6oRZg0E6hhoV-I2g,2400
|
|
24
|
+
labfreed/trex/trex_base_models.py,sha256=591559BISc82fyIoEP_dq_GHDbPCVzApx7FM3TRQPlY,7545
|
|
25
|
+
labfreed/trex/value_segments.py,sha256=qizDsinE-ddta8jzkJbGT3OUjHpYhI2GwxjZ6InzLDs,3712
|
|
26
|
+
labfreed/trex/python_convenience/__init__.py,sha256=dyAQG7t-uYN6VfGXbWIq2bHxGcGI63l7FS2-VPYs2RQ,137
|
|
27
|
+
labfreed/trex/python_convenience/data_table.py,sha256=De0UMVCUUPeK-bUTToRTvL88EywHf6EOPYjgoUHsUpA,3158
|
|
28
|
+
labfreed/trex/python_convenience/pyTREX.py,sha256=mja3EDF4yPCfPyotlG6FEtIuGC0_q9mk3X1VFq5lz-U,10165
|
|
29
|
+
labfreed/trex/python_convenience/quantity.py,sha256=Uwu43SKCLN5C8MssRHEdiZbBIJ4C4hhLHVr25UUG_7I,2261
|
|
30
|
+
labfreed/utilities/base36.py,sha256=_yX8aQ1OwrK5tnJU1NUEzQSFGr9xAVnNvPObpNzCPYs,2895
|
|
31
|
+
labfreed/well_known_extensions/__init__.py,sha256=CjZTjx8Cn8763Hhnv_--Wj1LcFpFs2cyQwWrrzOS4xM,246
|
|
32
|
+
labfreed/well_known_extensions/default_extension_interpreters.py,sha256=3-BkJrAyBa99NN5Q2QPAm59CcWmPket-rvLzgltp8KY,201
|
|
33
|
+
labfreed/well_known_extensions/display_name_extension.py,sha256=1BZY3Tffak4bNeirBKAktYCG1u2dhEvx8RqamUT6TxU,1465
|
|
34
|
+
labfreed/well_known_extensions/trex_extension.py,sha256=tffklaambkFPExcIDRAG9GJ7CHXeuFAagl6FuwS-2kI,929
|
|
35
|
+
labfreed/well_known_keys/gs1/__init__.py,sha256=LOFycgqS6OuV8t22TmtHy-ZI2iuXc3jJfVFwRFVDM3I,103
|
|
36
|
+
labfreed/well_known_keys/gs1/gs1.py,sha256=LIyy-W89m9L0gVxOu-lpBotsHN6CHvmdE3Vu2VwxUQA,79
|
|
37
|
+
labfreed/well_known_keys/gs1/gs1_ai_enum_sorted.py,sha256=D8hE6vm-GedS7W2uC52oYrvAKa4zM-7X11JeT_k23oM,1252
|
|
38
|
+
labfreed/well_known_keys/labfreed/well_known_keys.py,sha256=nqk66kHdSwJTJfMKlP-xQbBglS8F_NoWsGkfOVITFN0,331
|
|
39
|
+
labfreed/well_known_keys/unece/UneceUnits.json,sha256=kwfQSp_nTuWbADfBBgqTWrvPl6XtM5SedEVLbMJrM7M,898953
|
|
40
|
+
labfreed/well_known_keys/unece/__init__.py,sha256=MSP9lmjg9_D9iqG9Yq2_ajYfQSNS9wIT7FXA1c--59M,122
|
|
41
|
+
labfreed/well_known_keys/unece/unece_units.py,sha256=gNDQk6KGl-nGMf9Ycq_fQ8P2xxKITgLkcQWPd4H49gI,1630
|
|
42
|
+
labfreed-0.2.9.dist-info/licenses/LICENSE,sha256=gHFOv9FRKHxO8cInP3YXyPoJnuNeqrvcHjaE_wPSsQ8,1100
|
|
43
|
+
labfreed-0.2.9.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
44
|
+
labfreed-0.2.9.dist-info/METADATA,sha256=oMfY9l0zDd-pB02stoHMFgS0vJZ7PErO7bx3LPcFXK0,19167
|
|
45
|
+
labfreed-0.2.9.dist-info/RECORD,,
|