labfreed 0.2.1__py3-none-any.whl → 0.2.2__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 CHANGED
@@ -2,7 +2,10 @@
2
2
  Python implementation of LabFREED building blocks
3
3
  '''
4
4
 
5
- __version__ = "0.2.1"
5
+ __version__ = "0.2.2"
6
6
 
7
- from labfreed.pac_id import PAC_ID # noqa: F401
8
- from labfreed.labfreed_infrastructure import LabFREED_ValidationError # noqa: F401
7
+ from labfreed.pac_id import * # noqa: F403
8
+ from labfreed.pac_cat import * # noqa: F403
9
+ from labfreed.pac_id_resolver import * # noqa: F403
10
+ from labfreed.trex import * # noqa: F403
11
+ from labfreed.labfreed_infrastructure import * # noqa: F403
@@ -177,7 +177,7 @@ class LabFREED_BaseModel(PDOC_Workaround_Base):
177
177
 
178
178
 
179
179
  def print_validation_messages(self, target='console'):
180
- msgs = self._get_nested_validation_messages()
180
+ msgs = self.format_validation_messages(target=target)
181
181
 
182
182
  table = Table(title="Validation Results", show_header=False, title_justify='left')
183
183
 
@@ -185,12 +185,29 @@ class LabFREED_BaseModel(PDOC_Workaround_Base):
185
185
  return table.add_column(s, vertical='top')
186
186
  col("-")
187
187
 
188
-
189
188
  if not msgs:
190
189
  table.add_row('All clear!', end_section=True)
191
190
  return
192
191
 
193
192
  for m in msgs:
193
+ table.add_row(m)
194
+ table.add_section()
195
+
196
+ logging.info(table)
197
+ print(table)
198
+
199
+
200
+ def format_validation_messages(self, target='console') -> list[str]:
201
+ """Format validation messages
202
+
203
+ Args:
204
+ target (str, optional): Target format: 'markdown', 'console', 'html', 'html_styled'.
205
+
206
+ Returns:
207
+ list[str]: formated messages
208
+ """
209
+ formatted_msg = list()
210
+ for m in self.validation_messages():
194
211
  if m.level == ValidationMsgLevel.ERROR:
195
212
  color = 'red'
196
213
  else:
@@ -213,12 +230,9 @@ class LabFREED_BaseModel(PDOC_Workaround_Base):
213
230
  txt = f'[bold {color}]{m.level.name} [/bold {color}] in {m.source}'
214
231
  txt += '\n' + f'{m.msg}'
215
232
  txt += '\n\n' + emphazised_highlight
216
-
217
- table.add_row( txt)
218
- table.add_section()
219
-
220
- logging.info(table)
221
- print(table)
233
+
234
+ formatted_msg.append(txt)
235
+ return formatted_msg
222
236
 
223
237
 
224
238
 
@@ -1,6 +1,9 @@
1
1
  from .pac_cat import PAC_CAT
2
2
  from .category_base import Category
3
- from .predefined_categories import Material_Device, Material_Substance, Material_Consumable, Material_Misc, Data_Method, Data_Result, Data_Progress, Data_Calibration, Data_Abstract
3
+ from .predefined_categories import (
4
+ Material_Device, Material_Substance, Material_Consumable, Material_Misc, Data_Method, Data_Result, Data_Progress,
5
+ Data_Calibration, Data_Abstract, category_key_to_class_map
6
+ )
4
7
 
5
8
  __all__ = [
6
9
  "PAC_CAT",
@@ -10,7 +10,7 @@ from rich.table import Table
10
10
  from labfreed.labfreed_infrastructure import ValidationMsgLevel
11
11
 
12
12
  from labfreed.pac_cat.category_base import Category
13
- from labfreed.pac_cat.predefined_categories import Data_Calibration, Data_Method, Data_Progress, Data_Result, Material_Consumable, Material_Device, Material_Misc, Material_Substance, Data_Static
13
+ from labfreed.pac_cat.predefined_categories import category_key_to_class_map
14
14
  from labfreed.pac_id.id_segment import IDSegment
15
15
  from labfreed.pac_id.pac_id import PAC_ID
16
16
 
@@ -68,18 +68,7 @@ class PAC_CAT(PAC_ID):
68
68
  category_key = segments[0].value
69
69
  segments.pop(0)
70
70
 
71
- mapping = {
72
- '-MD': Material_Device,
73
- '-MS': Material_Substance,
74
- '-MC': Material_Consumable,
75
- '-MM': Material_Misc,
76
- '-DM': Data_Method,
77
- '-DR': Data_Result,
78
- '-DC': Data_Calibration,
79
- '-DP': Data_Progress,
80
- '-DS': Data_Static
81
- }
82
- known_cat = mapping.get(category_key)
71
+ known_cat = category_key_to_class_map.get(category_key)
83
72
 
84
73
  if not known_cat:
85
74
  return Category(key=category_key, segments=segments)
@@ -157,3 +146,5 @@ class PAC_CAT(PAC_ID):
157
146
  table.add_section()
158
147
  print(table)
159
148
 
149
+
150
+
@@ -188,3 +188,14 @@ class Data_Static(Data_Abstract):
188
188
  ''' Category segments, which are not defined in the specification'''
189
189
 
190
190
 
191
+ category_key_to_class_map = {
192
+ '-MD': Material_Device,
193
+ '-MS': Material_Substance,
194
+ '-MC': Material_Consumable,
195
+ '-MM': Material_Misc,
196
+ '-DM': Data_Method,
197
+ '-DR': Data_Result,
198
+ '-DC': Data_Calibration,
199
+ '-DP': Data_Progress,
200
+ '-DS': Data_Static
201
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: labfreed
3
- Version: 0.2.1
3
+ Version: 0.2.2
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
@@ -98,30 +98,28 @@ There is a nice function to highlight problems
98
98
  pac.print_validation_messages()
99
99
  ```
100
100
  ```text
101
- >> Validation Results
102
- >> ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
103
- >> │ RECOMMENDATION in id segment value bal500
104
- >> │ Characters 'a','l','b' should not be used., Characters SHOULD be limited to upper case letters (A-Z), numbers (0-9), '-' and │
105
- >> │ '+'
106
- >> │
107
- >> │ HTTPS://PAC.METTORIUS.COM/-MD/240:👉bal👈500/21:@1234 │
108
- >> ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
109
- >> │ RECOMMENDATION in id segment value @1234
110
- >> │ Characters '@' should not be used., Characters SHOULD be limited to upper case letters (A-Z), numbers (0-9), '-' and '+'
111
- >> │
112
- >> │ HTTPS://PAC.METTORIUS.COM/-MD/240:bal500/21:👉@👈1234 │
113
- >> ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
114
- >> │ RECOMMENDATION in id segment value bal500
115
- >> │ Characters 'a','l','b' should not be used., Characters SHOULD be limited to upper case letters (A-Z), numbers (0-9), '-' and
116
- >> │ '+'
117
- >> │ │
118
- >> │ HTTPS://PAC.METTORIUS.COM/-MD/240:👉bal👈500/21:@1234
119
- >> ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
120
- >> │ RECOMMENDATION in id segment value @1234
121
- >> │ Characters '@' should not be used., Characters SHOULD be limited to upper case letters (A-Z), numbers (0-9), '-' and '+'
122
- >> │ │
123
- >> │ HTTPS://PAC.METTORIUS.COM/-MD/240:bal500/21:👉@👈1234 │
124
- >> └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
101
+ >> Validation Results
102
+ >> ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
103
+ >> │ RECOMMENDATION in id segment value bal500
104
+ >> │ Characters 'b','l','a' should not be used., Characters SHOULD be limited to upper case letters (A-Z), numbers (0-9), '-' and '+'
105
+ >> │
106
+ >> │ HTTPS://PAC.METTORIUS.COM/-MD/240:👉bal👈500/21:@1234
107
+ >> ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
108
+ >> │ RECOMMENDATION in id segment value @1234 │
109
+ >> │ Characters '@' should not be used., Characters SHOULD be limited to upper case letters (A-Z), numbers (0-9), '-' and '+'
110
+ >> │
111
+ >> │ HTTPS://PAC.METTORIUS.COM/-MD/240:bal500/21:👉@👈1234
112
+ >> ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
113
+ >> │ RECOMMENDATION in id segment value bal500 │
114
+ >> │ Characters 'b','l','a' should not be used., Characters SHOULD be limited to upper case letters (A-Z), numbers (0-9), '-' and '+'
115
+ >> │
116
+ >> │ HTTPS://PAC.METTORIUS.COM/-MD/240:👉bal👈500/21:@1234
117
+ >> ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
118
+ >> │ RECOMMENDATION in id segment value @1234
119
+ >> │ Characters '@' should not be used., Characters SHOULD be limited to upper case letters (A-Z), numbers (0-9), '-' and '+' │
120
+ >> │
121
+ >> │ HTTPS://PAC.METTORIUS.COM/-MD/240:bal500/21:👉@👈1234
122
+ >> └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
125
123
  ```
126
124
  ### Save as QR Code
127
125
 
@@ -141,7 +139,7 @@ PAC-CAT defines a (optional) way how the identifier is structured.
141
139
  PAC_ID.from_url() automatically converts to PAC-CAT if possible.
142
140
 
143
141
  ```python
144
- from labfreed.pac_cat import PAC_CAT
142
+ from labfreed import PAC_CAT
145
143
  pac_str = 'HTTPS://PAC.METTORIUS.COM/-DR/XQ908756/-MD/bal500/@1234'
146
144
  pac = PAC_ID.from_url(pac_str)
147
145
  if isinstance(pac, PAC_CAT):
@@ -197,7 +195,7 @@ print(f'WEIGHT = {v.value}')
197
195
  #### Create PAC-ID
198
196
 
199
197
  ```python
200
- from labfreed.pac_id import PAC_ID, IDSegment
198
+ from labfreed import PAC_ID, IDSegment
201
199
  from labfreed.well_known_keys.labfreed.well_known_keys import WellKnownKeys
202
200
 
203
201
  pac = PAC_ID(issuer='METTORIUS.COM', identifier=[IDSegment(key=WellKnownKeys.SERIAL, value='1234')])
@@ -213,9 +211,9 @@ Note that utility types for Quantity (number with unit) and table are needed
213
211
 
214
212
  ```python
215
213
  from datetime import datetime
216
- from labfreed.trex.python_convenience.pyTREX import pyTREX
217
- from labfreed.trex.python_convenience.data_table import DataTable
218
- from labfreed.trex.python_convenience.quantity import Quantity
214
+ from labfreed.trex.python_convenience import pyTREX
215
+ from labfreed.trex.python_convenience import DataTable
216
+ from labfreed.trex.python_convenience import Quantity
219
217
 
220
218
  # Value segments of different type
221
219
  segments = {
@@ -246,7 +244,7 @@ trex.print_validation_messages()
246
244
  >> Validation Results
247
245
  >> ┌────────────────────────────────────────────────────────────┐
248
246
  >> │ ERROR in TREX table column Date │
249
- >> │ Column header key contains invalid characters: 'a','e','t' │
247
+ >> │ Column header key contains invalid characters: 'e','t','a' │
250
248
  >> │ │
251
249
  >> │ STOP$T.D:20240505T1306 │
252
250
  >> │ +TEMP$KEL:10.15 │
@@ -254,9 +252,9 @@ trex.print_validation_messages()
254
252
  >> │ +COMMENT$T.A:FOO │
255
253
  >> │ +COMMENT2$T.T:QMDTNXIKU │
256
254
  >> │ +TABLE$$DURATION$HUR:D👉ate👈$T.D:OK$T.B:COMMENT$T.A:: │
257
- >> │ 1:20250424T161739.312:T:FOO:: │
258
- >> │ 1.1:20250424T161739.312:T:BAR:: │
259
- >> │ 1.3:20250424T161739.312:F:BLUBB │
255
+ >> │ 1:20250424T200626.801:T:FOO:: │
256
+ >> │ 1.1:20250424T200626.801:T:BAR:: │
257
+ >> │ 1.3:20250424T200626.801:F:BLUBB │
260
258
  >> └────────────────────────────────────────────────────────────┘
261
259
  ```
262
260
  #### Combine PAC-ID and TREX and serialize
@@ -268,12 +266,12 @@ pac_str = pac.to_url()
268
266
  print(pac_str)
269
267
  ```
270
268
  ```text
271
- >> 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:QMDTNXIKU+TABLE$$DURATION$HUR:Date$T.D:OK$T.B:COMMENT$T.A::1:20250424T161739.312:T:FOO::1.1:20250424T161739.312:T:BAR::1.3:20250424T161739.312:F:BLUBB
269
+ >> 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:QMDTNXIKU+TABLE$$DURATION$HUR:Date$T.D:OK$T.B:COMMENT$T.A::1:20250424T200626.801:T:FOO::1.1:20250424T200626.801:T:BAR::1.3:20250424T200626.801:F:BLUBB
272
270
  ```
273
271
  ## PAC-ID Resolver
274
272
 
275
273
  ```python
276
- from labfreed.pac_id_resolver import PAC_ID_Resolver, load_cit
274
+ from labfreed import PAC_ID_Resolver, load_cit
277
275
  # Get a CIT
278
276
  dir = os.path.join(os.getcwd(), 'examples')
279
277
  p = os.path.join(dir, 'cit_mine.yaml')
@@ -299,7 +297,26 @@ for sg in service_groups:
299
297
 
300
298
  ```
301
299
  ```text
302
- >> [Error during execution: No Internet Connection]
300
+ >> Services from origin 'PERSONAL
301
+ >> ┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
302
+ >> ┃ Service Name ┃ URL ┃ Reachable ┃
303
+ >> ┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
304
+ >> │ CAS Search │ https://pubchem.ncbi.nlm.nih.gov/#query=7732-18-5 │ ACTIVE │
305
+ >> └──────────────┴───────────────────────────────────────────────────┴───────────┘
306
+ >> Services from origin 'MY_COMPANY
307
+ >> ┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
308
+ >> ┃ Service Name ┃ URL ┃ Reachable ┃
309
+ >> ┡━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
310
+ >> │ Chemical Management │ https://chem-manager.com/METTORIUS.COM/-MS/240:X3511/CAS:7732-18-5 │ INACTIVE │
311
+ >> └─────────────────────┴────────────────────────────────────────────────────────────────────┴───────────┘
312
+ >> Services from origin 'METTORIUS.COM
313
+ >> ┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
314
+ >> ┃ Service Name ┃ URL ┃ Reachable ┃
315
+ >> ┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
316
+ >> │ CoA │ https://mettorius.com/CoA.pdf │ ACTIVE │
317
+ >> │ MSDS │ https://mettorius.com/MSDS.pdf │ ACTIVE │
318
+ >> │ Shop │ https://mettorius.com/shop.html │ ACTIVE │
319
+ >> └──────────────┴─────────────────────────────────┴───────────┘
303
320
  ```
304
321
  <!-- END EXAMPLES -->
305
322
 
@@ -307,6 +324,9 @@ for sg in service_groups:
307
324
 
308
325
  <!-- BEGIN CHANGELOG -->
309
326
  ## Change Log
327
+ ### v0.2.2
328
+ - minor changes for better access of subfunctions. No change in existing API
329
+
310
330
  ### v0.2.1
311
331
  - improved docu. no code changes
312
332
 
@@ -329,6 +349,7 @@ for sg in service_groups:
329
349
  - supports PAC-ID, PAC-CAT, TREX and DisplayName
330
350
  - QR generation
331
351
  - ok-ish test coverage
352
+ <!-- END CHANGELOG -->
332
353
 
333
354
  # Attributions
334
355
  The following tools were used:
@@ -336,4 +357,4 @@ The following tools were used:
336
357
  - [Pydantic](https://docs.pydantic.dev/latest/)
337
358
  - json with UNECE units from (https://github.com/quadient/unece-units/blob/main/python/src/unece_excel_parser/parsedUneceUnits.json)
338
359
  - json with GS1 codes from (https://ref.gs1.org/ai/GS1_Application_Identifiers.jsonld)
339
- <!-- END CHANGELOG -->
360
+
@@ -1,9 +1,9 @@
1
- labfreed/__init__.py,sha256=CgFS3IzTYiq7S4f4VZzeneIGDHNBVqFn-9BQ0xCpzbQ,224
2
- labfreed/labfreed_infrastructure.py,sha256=V-5sLhqKkfckKim5VxlB_D1qIzk-Ztxfx4VIlwaR6Jc,10850
3
- labfreed/pac_cat/__init__.py,sha256=rJ2dFTN8aErTvGf4xwcNZ04xrbTieLAE2v5C2bmgPOA,507
1
+ labfreed/__init__.py,sha256=uSmYPYE1cNYpdOYNFUoI-chJ0T0Jh_4r50mfhTvzLiY,336
2
+ labfreed/labfreed_infrastructure.py,sha256=SZhwBN66ti5ABH1eHOu3a6j5uRWaMKQ3wb1pj-NlTu0,11322
3
+ labfreed/pac_cat/__init__.py,sha256=S4T-QgzcEDjup44WvHCY3_K30B6_e8ducR--DxBb_DM,554
4
4
  labfreed/pac_cat/category_base.py,sha256=lFQNiTUukyhWdaSCAI7CZxLtj6kNtnBCE4UsePwsGqE,1801
5
- labfreed/pac_cat/pac_cat.py,sha256=UxWyPsuZsekq3ZmHSQLBdB1tocvVlxz_FOQXxHg_dlU,5800
6
- labfreed/pac_cat/predefined_categories.py,sha256=BEf7rxN5IcKVhuxMNhdfQ_1xnkax5l8Z1pJMRIROKpw,8510
5
+ labfreed/pac_cat/pac_cat.py,sha256=AJUYDsyGOHy-sRRpXpY0awtbf3HCvn3RhMax6ofvYRA,5318
6
+ labfreed/pac_cat/predefined_categories.py,sha256=5wnMCj-CrACV2W4lH13w7qynWIwi506G3uLNcxuJQGg,8832
7
7
  labfreed/pac_id/__init__.py,sha256=NGMbzkwQ4txKeT5pxdIZordwHO8J3_q84jzPanjKoHg,675
8
8
  labfreed/pac_id/extension.py,sha256=uIs_9aasJ_n7ua067wR7XvtL05H-JZP4f_HtW4qnQDw,1114
9
9
  labfreed/pac_id/id_segment.py,sha256=r5JU1SJuRXhZJJxy5T3xjrb598wIDTLpivSJhIUAzjQ,4526
@@ -38,7 +38,7 @@ labfreed/well_known_keys/labfreed/well_known_keys.py,sha256=nqk66kHdSwJTJfMKlP-x
38
38
  labfreed/well_known_keys/unece/UneceUnits.json,sha256=kwfQSp_nTuWbADfBBgqTWrvPl6XtM5SedEVLbMJrM7M,898953
39
39
  labfreed/well_known_keys/unece/__init__.py,sha256=MSP9lmjg9_D9iqG9Yq2_ajYfQSNS9wIT7FXA1c--59M,122
40
40
  labfreed/well_known_keys/unece/unece_units.py,sha256=gNDQk6KGl-nGMf9Ycq_fQ8P2xxKITgLkcQWPd4H49gI,1630
41
- labfreed-0.2.1.dist-info/licenses/LICENSE,sha256=gHFOv9FRKHxO8cInP3YXyPoJnuNeqrvcHjaE_wPSsQ8,1100
42
- labfreed-0.2.1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
43
- labfreed-0.2.1.dist-info/METADATA,sha256=TZAAEd3mlli0oXeEkQ7x5kbfpwMI59mx8WVIbS5KxQU,14965
44
- labfreed-0.2.1.dist-info/RECORD,,
41
+ labfreed-0.2.2.dist-info/licenses/LICENSE,sha256=gHFOv9FRKHxO8cInP3YXyPoJnuNeqrvcHjaE_wPSsQ8,1100
42
+ labfreed-0.2.2.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
43
+ labfreed-0.2.2.dist-info/METADATA,sha256=T4rheRh4e31HYkTSjIc4ljZU8oFxxzuQJcEUgeQP1rY,17996
44
+ labfreed-0.2.2.dist-info/RECORD,,