labfreed 0.0.15__tar.gz → 0.0.17__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.

Potentially problematic release.


This version of labfreed might be problematic. Click here for more details.

Files changed (41) hide show
  1. {labfreed-0.0.15 → labfreed-0.0.17}/PKG-INFO +49 -38
  2. {labfreed-0.0.15 → labfreed-0.0.17}/README.md +44 -37
  3. {labfreed-0.0.15 → labfreed-0.0.17}/examples.py +14 -22
  4. {labfreed-0.0.15 → labfreed-0.0.17}/labfreed/PAC_CAT/data_model.py +26 -8
  5. labfreed-0.0.17/labfreed/QR_Generator/generate_qr.py +450 -0
  6. {labfreed-0.0.15 → labfreed-0.0.17}/labfreed/TREX/data_model.py +1 -0
  7. {labfreed-0.0.15 → labfreed-0.0.17}/labfreed/__init__.py +1 -1
  8. {labfreed-0.0.15 → labfreed-0.0.17}/pyproject.toml +6 -0
  9. labfreed-0.0.17/update_readme.py +93 -0
  10. labfreed-0.0.15/labfreed/PAC_CAT/data_model copy.py +0 -232
  11. labfreed-0.0.15/update_readme.py +0 -63
  12. {labfreed-0.0.15 → labfreed-0.0.17}/.vscode/launch.json +0 -0
  13. {labfreed-0.0.15 → labfreed-0.0.17}/.vscode/settings.json +0 -0
  14. {labfreed-0.0.15 → labfreed-0.0.17}/LICENSE +0 -0
  15. {labfreed-0.0.15 → labfreed-0.0.17}/labfreed/DisplayNameExtension/DisplayNameExtension.py +0 -0
  16. {labfreed-0.0.15 → labfreed-0.0.17}/labfreed/PAC_CAT/__init__.py +0 -0
  17. {labfreed-0.0.15 → labfreed-0.0.17}/labfreed/PAC_ID/__init__.py +0 -0
  18. {labfreed-0.0.15 → labfreed-0.0.17}/labfreed/PAC_ID/data_model.py +0 -0
  19. {labfreed-0.0.15 → labfreed-0.0.17}/labfreed/PAC_ID/extensions.py +0 -0
  20. {labfreed-0.0.15 → labfreed-0.0.17}/labfreed/TREX/UneceUnits.json +0 -0
  21. {labfreed-0.0.15 → labfreed-0.0.17}/labfreed/TREX/parse.py +0 -0
  22. {labfreed-0.0.15 → labfreed-0.0.17}/labfreed/TREX/unece_units.py +0 -0
  23. {labfreed-0.0.15 → labfreed-0.0.17}/labfreed/parse_pac.py +0 -0
  24. {labfreed-0.0.15 → labfreed-0.0.17}/labfreed/utilities/base36.py +0 -0
  25. {labfreed-0.0.15 → labfreed-0.0.17}/labfreed/utilities/extension_intertpreters.py +0 -0
  26. {labfreed-0.0.15 → labfreed-0.0.17}/labfreed/utilities/utility_types.py +0 -0
  27. {labfreed-0.0.15 → labfreed-0.0.17}/labfreed/utilities/well_known_keys.py +0 -0
  28. {labfreed-0.0.15 → labfreed-0.0.17}/labfreed/validation.py +0 -0
  29. {labfreed-0.0.15 → labfreed-0.0.17}/main.py +0 -0
  30. {labfreed-0.0.15 → labfreed-0.0.17}/publish.ps1 +0 -0
  31. {labfreed-0.0.15 → labfreed-0.0.17}/publish.sh +0 -0
  32. {labfreed-0.0.15 → labfreed-0.0.17}/publish_commands +0 -0
  33. {labfreed-0.0.15 → labfreed-0.0.17}/pytest.ini +0 -0
  34. {labfreed-0.0.15 → labfreed-0.0.17}/tests/test_(de)_serialization_incl_extension/test__parse.py +0 -0
  35. {labfreed-0.0.15 → labfreed-0.0.17}/tests/test_(de)_serialization_incl_extension/test__serialize.py +0 -0
  36. {labfreed-0.0.15 → labfreed-0.0.17}/tests/test_PAC_CAT/test_PAC_CAT_parse.py +0 -0
  37. {labfreed-0.0.15 → labfreed-0.0.17}/tests/test_PAC_CAT/test_PAC_CAT_serialize.py +0 -0
  38. {labfreed-0.0.15 → labfreed-0.0.17}/tests/test_PAC_ID/test_PAC_ID_serialize.py +0 -0
  39. {labfreed-0.0.15 → labfreed-0.0.17}/tests/test_PAC_ID/test_pac_id_parse.py +0 -0
  40. {labfreed-0.0.15 → labfreed-0.0.17}/tests/test_TREX/test_TREX_parse.py +0 -0
  41. {labfreed-0.0.15 → labfreed-0.0.17}/tests/test_TREX/test_TREX_serialize.py +0 -0
@@ -1,11 +1,15 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: labfreed
3
- Version: 0.0.15
3
+ Version: 0.0.17
4
4
  Summary: Python implementation of LabFREED building blocks
5
5
  Author-email: Reto Thürer <thuerer.r@buchi.com>
6
6
  Description-Content-Type: text/markdown
7
7
  License-Expression: MIT
8
8
  License-File: LICENSE
9
+ Requires-Dist: numpy>=2.2.4
10
+ Requires-Dist: pydantic>=2.11.3
11
+ Requires-Dist: segno>=1.6.6
12
+ Requires-Dist: typer>=0.15.2
9
13
 
10
14
  # LabFREED for Python
11
15
 
@@ -32,13 +36,9 @@ pip install labfreed
32
36
 
33
37
 
34
38
  ## Usage Examples
39
+ > ⚠️ **Note:** These examples are building on each other. Imports and parsing are not repeated in each example.
35
40
  <!-- BEGIN EXAMPLES -->
36
- ```python
37
-
38
- ```
39
-
40
- ### Parse a simple PAC-ID
41
- The
41
+ ### Parse a simple PAC-ID
42
42
 
43
43
  ```python
44
44
  from labfreed.parse_pac import PAC_Parser
@@ -50,34 +50,33 @@ pac_id = PAC_Parser().parse(pac_str).pac_id
50
50
  # Check validity of this PAC-ID
51
51
  pac_id = PAC_Parser().parse(pac_str).pac_id
52
52
  is_valid = pac_id.is_valid()
53
- print('PAC-ID is valid: {is_valid}')
54
- # >> PAC-ID is valid: {is_valid}
53
+ print(f'PAC-ID is valid: {is_valid}')
55
54
  ```
56
-
57
- Show recommendations:
58
- Note that the PAC-ID, while valid uses characters, which are not recommended (results in larger QR code).
55
+ ```text
56
+ >> [Error during execution: No module named 'quantities']
57
+ ```
58
+ ### Show recommendations:
59
+ Note that the PAC-ID -- while valid -- uses characters which are not recommended (results in larger QR code).
59
60
  There is a nice function to highlight problems
60
61
 
61
62
  ```python
62
63
  pac_id.print_validation_messages()
63
- # >>
64
- # =======================================
65
- # Validation Results
66
- # ---------------------------------------
67
-
68
- # Recommendation in id segment value bal500
69
- # HTTPS://PAC.METTORIUS.COM/-MD/bal500/@1234
70
- # Characters a b l should not be used.
71
-
72
- # Recommendation in id segment value @1234
73
- # HTTPS://PAC.METTORIUS.COM/-MD/bal500/@1234
74
- # Characters @ should not be used.
75
-
76
- # Warning in Category -MD
77
- # HTTPS://PAC.METTORIUS.COM/-MD/bal500/@1234
78
- # Category key -MD is not a well known key. It is recommended to use well known keys only
79
64
  ```
65
+ ```text
66
+ >> [Error during execution: name 'pac_id' is not defined]
67
+ ```
68
+ ### PAC-CAT
80
69
 
70
+ ```python
71
+ from labfreed.PAC_CAT.data_model import PAC_CAT
72
+ pac_str = 'HTTPS://PAC.METTORIUS.COM/-DR/XQ908756/-MD/bal500/@1234'
73
+ pac_id = PAC_Parser().parse(pac_str).pac_id
74
+ if isinstance(pac_id, PAC_CAT):
75
+ pac_id.print_categories()
76
+ ```
77
+ ```text
78
+ >> [Error during execution: name 'PAC_Parser' is not defined]
79
+ ```
81
80
  ### Parse a PAC-ID with extensions
82
81
  PAC-ID can have extensions. Here we parse a PAC-ID with attached display names and summary.
83
82
 
@@ -87,17 +86,21 @@ pac_id = PAC_Parser().parse(pac_str)
87
86
 
88
87
  # Display Name
89
88
  display_names = pac_id.get_extension('N') # display name has name 'N'
90
- print(f'\n {display_names}')
91
- # >> Display names: My Balance ❤️
92
-
89
+ print(display_names)
90
+ ```
91
+ ```text
92
+ >> [Error during execution: name 'PAC_Parser' is not defined]
93
+ ```
94
+ ```python
93
95
  # TREX
94
96
  trexes = pac_id.get_extension_of_type('TREX')
95
97
  trex = trexes[0] # there could be multiple trexes. In this example there is only one, though
96
98
  v = trex.get_segment('WEIGHT').to_python_type()
97
99
  print(f'WEIGHT = {v}')
98
- # >> WEIGHT = 67.89 g
99
100
  ```
100
-
101
+ ```text
102
+ >> [Error during execution: name 'pac_id' is not defined]
103
+ ```
101
104
  ### Create a PAC-ID with Extensions
102
105
 
103
106
  #### Create PAC-ID
@@ -108,10 +111,11 @@ from labfreed.utilities.well_known_keys import WellKnownKeys
108
111
 
109
112
  pac_id = PACID(issuer='METTORIUS:COM', identifier=[IDSegment(key=WellKnownKeys.SERIAL, value='1234')])
110
113
  pac_str = pac_id.serialize()
111
- pac_str = pac_id.serialize()
112
114
  print(pac_str)
113
115
  ```
114
-
116
+ ```text
117
+ >> HTTPS://PAC.METTORIUS:COM/21:1234
118
+ ```
115
119
  #### Create a TREX
116
120
  TREX can conveniently be created from a python dictionary.
117
121
  Note that utility types for Quantity (number with unit) and table are needed
@@ -149,7 +153,9 @@ if trex.get_nested_validation_messages():
149
153
  # Side Note: The TREX can be turned back into a dict
150
154
  d = trex.dict()
151
155
  ```
152
-
156
+ ```text
157
+ >> [Error during execution: No module named 'quantities']
158
+ ```
153
159
  #### Combine PAC-ID and TREX and serialize
154
160
 
155
161
  ```python
@@ -159,13 +165,18 @@ pac_with_trex = PACID_With_Extensions(pac_id=pac_id, extensions=[trex])
159
165
  pac_str = pac_with_trex.serialize()
160
166
  print(pac_str)
161
167
  ```
162
-
168
+ ```text
169
+ >> [Error during execution: No module named 'quantities']
170
+ ```
163
171
  <!-- END EXAMPLES -->
164
172
 
165
173
 
166
174
 
167
175
  ## Change Log
168
176
 
169
- ### v0.0.9
177
+ ### v0.0.17
178
+ - dependencies are installed automatically
179
+
180
+ ### v0.0.16
170
181
  - supports PAC-ID, PAC-CAT, TREX and DisplayName
171
182
  - ok-ish test coverage
@@ -23,13 +23,9 @@ pip install labfreed
23
23
 
24
24
 
25
25
  ## Usage Examples
26
+ > ⚠️ **Note:** These examples are building on each other. Imports and parsing are not repeated in each example.
26
27
  <!-- BEGIN EXAMPLES -->
27
- ```python
28
-
29
- ```
30
-
31
- ### Parse a simple PAC-ID
32
- The
28
+ ### Parse a simple PAC-ID
33
29
 
34
30
  ```python
35
31
  from labfreed.parse_pac import PAC_Parser
@@ -41,34 +37,33 @@ pac_id = PAC_Parser().parse(pac_str).pac_id
41
37
  # Check validity of this PAC-ID
42
38
  pac_id = PAC_Parser().parse(pac_str).pac_id
43
39
  is_valid = pac_id.is_valid()
44
- print('PAC-ID is valid: {is_valid}')
45
- # >> PAC-ID is valid: {is_valid}
40
+ print(f'PAC-ID is valid: {is_valid}')
46
41
  ```
47
-
48
- Show recommendations:
49
- Note that the PAC-ID, while valid uses characters, which are not recommended (results in larger QR code).
42
+ ```text
43
+ >> [Error during execution: No module named 'quantities']
44
+ ```
45
+ ### Show recommendations:
46
+ Note that the PAC-ID -- while valid -- uses characters which are not recommended (results in larger QR code).
50
47
  There is a nice function to highlight problems
51
48
 
52
49
  ```python
53
50
  pac_id.print_validation_messages()
54
- # >>
55
- # =======================================
56
- # Validation Results
57
- # ---------------------------------------
58
-
59
- # Recommendation in id segment value bal500
60
- # HTTPS://PAC.METTORIUS.COM/-MD/bal500/@1234
61
- # Characters a b l should not be used.
62
-
63
- # Recommendation in id segment value @1234
64
- # HTTPS://PAC.METTORIUS.COM/-MD/bal500/@1234
65
- # Characters @ should not be used.
66
-
67
- # Warning in Category -MD
68
- # HTTPS://PAC.METTORIUS.COM/-MD/bal500/@1234
69
- # Category key -MD is not a well known key. It is recommended to use well known keys only
70
51
  ```
52
+ ```text
53
+ >> [Error during execution: name 'pac_id' is not defined]
54
+ ```
55
+ ### PAC-CAT
71
56
 
57
+ ```python
58
+ from labfreed.PAC_CAT.data_model import PAC_CAT
59
+ pac_str = 'HTTPS://PAC.METTORIUS.COM/-DR/XQ908756/-MD/bal500/@1234'
60
+ pac_id = PAC_Parser().parse(pac_str).pac_id
61
+ if isinstance(pac_id, PAC_CAT):
62
+ pac_id.print_categories()
63
+ ```
64
+ ```text
65
+ >> [Error during execution: name 'PAC_Parser' is not defined]
66
+ ```
72
67
  ### Parse a PAC-ID with extensions
73
68
  PAC-ID can have extensions. Here we parse a PAC-ID with attached display names and summary.
74
69
 
@@ -78,17 +73,21 @@ pac_id = PAC_Parser().parse(pac_str)
78
73
 
79
74
  # Display Name
80
75
  display_names = pac_id.get_extension('N') # display name has name 'N'
81
- print(f'\n {display_names}')
82
- # >> Display names: My Balance ❤️
83
-
76
+ print(display_names)
77
+ ```
78
+ ```text
79
+ >> [Error during execution: name 'PAC_Parser' is not defined]
80
+ ```
81
+ ```python
84
82
  # TREX
85
83
  trexes = pac_id.get_extension_of_type('TREX')
86
84
  trex = trexes[0] # there could be multiple trexes. In this example there is only one, though
87
85
  v = trex.get_segment('WEIGHT').to_python_type()
88
86
  print(f'WEIGHT = {v}')
89
- # >> WEIGHT = 67.89 g
90
87
  ```
91
-
88
+ ```text
89
+ >> [Error during execution: name 'pac_id' is not defined]
90
+ ```
92
91
  ### Create a PAC-ID with Extensions
93
92
 
94
93
  #### Create PAC-ID
@@ -99,10 +98,11 @@ from labfreed.utilities.well_known_keys import WellKnownKeys
99
98
 
100
99
  pac_id = PACID(issuer='METTORIUS:COM', identifier=[IDSegment(key=WellKnownKeys.SERIAL, value='1234')])
101
100
  pac_str = pac_id.serialize()
102
- pac_str = pac_id.serialize()
103
101
  print(pac_str)
104
102
  ```
105
-
103
+ ```text
104
+ >> HTTPS://PAC.METTORIUS:COM/21:1234
105
+ ```
106
106
  #### Create a TREX
107
107
  TREX can conveniently be created from a python dictionary.
108
108
  Note that utility types for Quantity (number with unit) and table are needed
@@ -140,7 +140,9 @@ if trex.get_nested_validation_messages():
140
140
  # Side Note: The TREX can be turned back into a dict
141
141
  d = trex.dict()
142
142
  ```
143
-
143
+ ```text
144
+ >> [Error during execution: No module named 'quantities']
145
+ ```
144
146
  #### Combine PAC-ID and TREX and serialize
145
147
 
146
148
  ```python
@@ -150,13 +152,18 @@ pac_with_trex = PACID_With_Extensions(pac_id=pac_id, extensions=[trex])
150
152
  pac_str = pac_with_trex.serialize()
151
153
  print(pac_str)
152
154
  ```
153
-
155
+ ```text
156
+ >> [Error during execution: No module named 'quantities']
157
+ ```
154
158
  <!-- END EXAMPLES -->
155
159
 
156
160
 
157
161
 
158
162
  ## Change Log
159
163
 
160
- ### v0.0.9
164
+ ### v0.0.17
165
+ - dependencies are installed automatically
166
+
167
+ ### v0.0.16
161
168
  - supports PAC-ID, PAC-CAT, TREX and DisplayName
162
169
  - ok-ish test coverage
@@ -1,6 +1,5 @@
1
1
  '''
2
2
  ### Parse a simple PAC-ID
3
- The
4
3
  '''
5
4
  from labfreed.parse_pac import PAC_Parser
6
5
 
@@ -11,31 +10,26 @@ pac_id = PAC_Parser().parse(pac_str).pac_id
11
10
  # Check validity of this PAC-ID
12
11
  pac_id = PAC_Parser().parse(pac_str).pac_id
13
12
  is_valid = pac_id.is_valid()
14
- print('PAC-ID is valid: {is_valid}')
15
- # >> PAC-ID is valid: {is_valid}
13
+ print(f'PAC-ID is valid: {is_valid}')
16
14
 
17
15
  '''
18
- Show recommendations:
19
- Note that the PAC-ID, while valid uses characters, which are not recommended (results in larger QR code).
16
+ ### Show recommendations:
17
+ Note that the PAC-ID -- while valid -- uses characters which are not recommended (results in larger QR code).
20
18
  There is a nice function to highlight problems
21
19
  '''
22
20
  pac_id.print_validation_messages()
23
- # >>
24
- # =======================================
25
- # Validation Results
26
- # ---------------------------------------
27
21
 
28
- # Recommendation in id segment value bal500
29
- # HTTPS://PAC.METTORIUS.COM/-MD/bal500/@1234
30
- # Characters a b l should not be used.
31
22
 
32
- # Recommendation in id segment value @1234
33
- # HTTPS://PAC.METTORIUS.COM/-MD/bal500/@1234
34
- # Characters @ should not be used.
23
+ '''
24
+ ### PAC-CAT
25
+ '''
26
+ from labfreed.PAC_CAT.data_model import PAC_CAT
27
+ pac_str = 'HTTPS://PAC.METTORIUS.COM/-DR/XQ908756/-MD/bal500/@1234'
28
+ pac_id = PAC_Parser().parse(pac_str).pac_id
29
+ if isinstance(pac_id, PAC_CAT):
30
+ pac_id.print_categories()
31
+
35
32
 
36
- # Warning in Category -MD
37
- # HTTPS://PAC.METTORIUS.COM/-MD/bal500/@1234
38
- # Category key -MD is not a well known key. It is recommended to use well known keys only
39
33
 
40
34
 
41
35
 
@@ -48,15 +42,14 @@ pac_id = PAC_Parser().parse(pac_str)
48
42
 
49
43
  # Display Name
50
44
  display_names = pac_id.get_extension('N') # display name has name 'N'
51
- print(f'\n {display_names}')
52
- # >> Display names: My Balance ❤️
45
+ print(display_names)
53
46
 
47
+ ''''''
54
48
  # TREX
55
49
  trexes = pac_id.get_extension_of_type('TREX')
56
50
  trex = trexes[0] # there could be multiple trexes. In this example there is only one, though
57
51
  v = trex.get_segment('WEIGHT').to_python_type()
58
52
  print(f'WEIGHT = {v}')
59
- # >> WEIGHT = 67.89 g
60
53
 
61
54
 
62
55
 
@@ -70,7 +63,6 @@ from labfreed.utilities.well_known_keys import WellKnownKeys
70
63
 
71
64
  pac_id = PACID(issuer='METTORIUS:COM', identifier=[IDSegment(key=WellKnownKeys.SERIAL, value='1234')])
72
65
  pac_str = pac_id.serialize()
73
- pac_str = pac_id.serialize()
74
66
  print(pac_str)
75
67
 
76
68
 
@@ -138,6 +138,19 @@ class PAC_CAT(PACID):
138
138
  )
139
139
  return self
140
140
 
141
+ def print_categories(self):
142
+ s = ''
143
+ for i, c in enumerate(self.categories):
144
+ if i == 0:
145
+ title = 'Main Category\n----------'
146
+ else:
147
+ title = 'Category\n------ '
148
+
149
+ s += f'{title}\n'
150
+ s += str(c)
151
+ s += '\n'
152
+ print(s)
153
+
141
154
 
142
155
  # @classmethod
143
156
  # def from_categories(cls, issuer:str, categories:list[Category]):
@@ -198,6 +211,11 @@ class Category(BaseModelWithValidationMessages):
198
211
  return self
199
212
 
200
213
 
214
+ def __str__(self):
215
+ s = '\n'.join( [f'{field_name} \t ({field_info.alias or ''}): \t {getattr(self, field_name)}' for field_name, field_info in self.model_fields.items() if getattr(self, field_name)])
216
+ return s
217
+
218
+
201
219
  # def to_identifier_category(self, use_short_notation=False):
202
220
  # '''Creates a Category with the correct segments.
203
221
  # Segments are in order of the Pydantic model fields.
@@ -261,14 +279,14 @@ class Material_Device(Category):
261
279
  self.add_validation_message(
262
280
  source=f"Category {self.key}",
263
281
  type="Error",
264
- msg=f'Category key {self.key} is missing mandatory field Model NUmber',
282
+ msg=f'Category key {self.key} is missing mandatory field Model Number',
265
283
  highlight_pattern = f"{self.key}"
266
284
  )
267
285
  if not self.serial_number:
268
286
  self.add_validation_message(
269
287
  source=f"Category {self.key}",
270
288
  type="Error",
271
- msg=f'Category key {self.key} is missing mandatory field Serial NUmber',
289
+ msg=f'Category key {self.key} is missing mandatory field Serial Number',
272
290
  highlight_pattern = f"{self.key}"
273
291
  )
274
292
 
@@ -286,7 +304,7 @@ class Material_Substance(Category):
286
304
  self.add_validation_message(
287
305
  source=f"Category {self.key}",
288
306
  type="Error",
289
- msg=f'Category key {self.key} is missing mandatory field Product NUmber',
307
+ msg=f'Category key {self.key} is missing mandatory field Product Number',
290
308
  highlight_pattern = f"{self.key}"
291
309
  )
292
310
 
@@ -328,19 +346,19 @@ class Data_Abstract(Category, ABC):
328
346
  highlight_pattern = f"{self.key}"
329
347
  )
330
348
 
331
- class Data_Result(Category):
349
+ class Data_Result(Data_Abstract):
332
350
  key: str = Field(default='-DR', frozen=True)
333
351
 
334
- class Data_Method(Category):
352
+ class Data_Method(Data_Abstract):
335
353
  key: str = Field(default='-DM', frozen=True)
336
354
 
337
- class Data_Calibration(Category):
355
+ class Data_Calibration(Data_Abstract):
338
356
  key: str = Field(default='-DC', frozen=True)
339
357
 
340
- class Data_Progress(Category):
358
+ class Data_Progress(Data_Abstract):
341
359
  key: str = Field(default='-DP', frozen=True)
342
360
 
343
- class Data_Static(Category):
361
+ class Data_Static(Data_Abstract):
344
362
  key: str = Field(default='-DS', frozen=True)
345
363
 
346
364