labfreed 0.2.5a22__py3-none-any.whl → 0.2.6a1__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.
labfreed/__init__.py CHANGED
@@ -2,7 +2,7 @@
2
2
  Python implementation of LabFREED building blocks
3
3
  '''
4
4
 
5
- __version__ = "0.2.5a22"
5
+ __version__ = "0.2.6a1"
6
6
 
7
7
  from labfreed.pac_id import * # noqa: F403
8
8
  from labfreed.pac_cat import * # noqa: F403
@@ -179,6 +179,7 @@ class LabFREED_BaseModel(PDOC_Workaround_Base):
179
179
 
180
180
  logging.info(table)
181
181
  print(table)
182
+ return table
182
183
 
183
184
 
184
185
  def format_validation_messages(self, target='console') -> list[str]:
@@ -1,5 +1,6 @@
1
1
 
2
2
 
3
+ import logging
3
4
  import re
4
5
  from types import MappingProxyType
5
6
 
@@ -73,6 +74,7 @@ class PAC_Parser():
73
74
  pac_id.extensions = extensions
74
75
 
75
76
  if not pac_id.is_valid and not suppress_validation_errors:
77
+ logging.error(pac_id.print_validation_messages())
76
78
  raise LabFREED_ValidationError(validation_msgs = pac_id._get_nested_validation_messages())
77
79
 
78
80
  return pac_id
@@ -48,6 +48,7 @@ class CIT_v1(LabFREED_BaseModel):
48
48
  applicable_if = cols[3],
49
49
  template_url = cols[4]
50
50
  )
51
+ entries.append(entry)
51
52
  except ValueError:
52
53
  logging.error(f'invalid line {line}')
53
54
  msg = ValidationMessage(
@@ -59,13 +60,15 @@ class CIT_v1(LabFREED_BaseModel):
59
60
  )
60
61
  errors.append(msg)
61
62
 
62
- entries.append(entry)
63
+
63
64
  cit = CIT_v1(origin=origin, entries=entries)
64
65
  cit._validation_messages.extend(errors)
65
66
  cit._csv_original = csv
66
67
  return cit
67
68
 
68
- def evaluate_pac_id(self, pac):
69
+ def evaluate_pac_id(self, pac:PAC_ID):
70
+ if not type(pac) is PAC_ID:
71
+ raise ValueError(f'CIT v1 does only handle PAC-IDs. PAC-CAT it does not know what to do')
69
72
  cit_evaluated = ServiceGroup(origin=self.origin)
70
73
  for e in self.entries:
71
74
  conditions = e.applicable_if.split(';')
@@ -19,18 +19,19 @@ __all__ = ["PAC_ID_Resolver"]
19
19
  def load_cit(path):
20
20
  with open(path, 'r') as f:
21
21
  s = f.read()
22
- return _cit_from_str(s)
22
+ return cit_from_str(s)
23
23
 
24
24
 
25
- def _cit_from_str(s:str, issuer:str='') -> CIT_v1|CIT_v2:
25
+ def cit_from_str(s:str, origin:str='') -> CIT_v1|CIT_v2:
26
26
  try:
27
27
  cit_yml= yaml.safe_load(s)
28
28
  cit2 = CIT_v2.from_yaml(cit_yml)
29
+ cit_version = 'v2'
29
30
  except Exception:
30
31
  cit2 = None
31
-
32
32
  try:
33
- cit1 = CIT_v1.from_csv(s, issuer)
33
+ cit1 = CIT_v1.from_csv(s, origin)
34
+ cit_version = 'v1'
34
35
  except Exception:
35
36
  cit1 = None
36
37
 
@@ -50,7 +51,7 @@ def _get_issuer_cit(issuer:str):
50
51
  except Exception:
51
52
  logging.error(f"Could not get CIT form {issuer}")
52
53
  cit_str = None
53
- cit = _cit_from_str(cit_str, issuer=issuer)
54
+ cit = cit_from_str(cit_str, origin=issuer)
54
55
  return cit
55
56
 
56
57
 
@@ -63,15 +64,23 @@ class PAC_ID_Resolver():
63
64
  self._cits = cits
64
65
 
65
66
 
66
- def resolve(self, pac_id:PAC_ID|str, check_service_status=True) -> list[ServiceGroup]:
67
+ def resolve(self, pac_url:PAC_ID|str, check_service_status=True) -> list[ServiceGroup]:
67
68
  '''Resolve a PAC-ID'''
68
- if isinstance(pac_id, str):
69
- pac_id = PAC_CAT.from_url(pac_id)
69
+ if isinstance(pac_url, str):
70
+ pac_id = PAC_CAT.from_url(pac_url)
71
+ pac_id_catless = PAC_ID.from_url(pac_url, try_pac_cat=False)
70
72
 
73
+ cits = self._cits.copy()
71
74
  if issuer_cit := _get_issuer_cit(pac_id.issuer):
72
- self._cits.append(issuer_cit)
75
+ cits.append(issuer_cit)
73
76
 
74
- matches = [cit.evaluate_pac_id(pac_id) for cit in self._cits]
77
+ matches = []
78
+ for cit in cits:
79
+ if isinstance(cit, CIT_v1):
80
+ # cit v1 has no concept of categories and implied keys. It would treat these segments as value segment
81
+ matches.append(cit.evaluate_pac_id(pac_id_catless))
82
+ else:
83
+ matches.append(cit.evaluate_pac_id(pac_id))
75
84
 
76
85
  if check_service_status:
77
86
  for m in matches:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: labfreed
3
- Version: 0.2.5a22
3
+ Version: 0.2.6a1
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
@@ -27,6 +27,10 @@ Requires-Dist: pytest>=8.3.5 ; extra == "dev"
27
27
  Requires-Dist: pdoc>=15.0.1 ; extra == "dev"
28
28
  Requires-Dist: flit>=3.12.0 ; extra == "dev"
29
29
  Requires-Dist: ruff>=0.11.5 ; extra == "dev"
30
+ Project-URL: Documentation, https://github.com/retothuerer/LabFREED?tab=readme-ov-file#readme
31
+ Project-URL: Homepage, https://github.com/retothuerer/LabFREED
32
+ Project-URL: Source, https://github.com/retothuerer/LabFREED
33
+ Project-URL: Tracker, https://github.com/retothuerer/LabFREED/issues
30
34
  Provides-Extra: dev
31
35
 
32
36
  # LabFREED for Python
@@ -101,7 +105,7 @@ pac.print_validation_messages()
101
105
  >> Validation Results
102
106
  >> ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
103
107
  >> │ **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 '+' │
108
+ >> │ Characters 'b','l','a' should not be used., Characters SHOULD be limited to upper case letters (A-Z), numbers (0-9), '-' and '+' │
105
109
  >> │ │
106
110
  >> │ HTTPS://PAC.METTORIUS.COM/-MD/240:👉bal👈500/21:@1234 │
107
111
  >> ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
@@ -111,7 +115,7 @@ pac.print_validation_messages()
111
115
  >> │ HTTPS://PAC.METTORIUS.COM/-MD/240:bal500/21:👉@👈1234 │
112
116
  >> ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
113
117
  >> │ **RECOMMENDATION** in id segment value bal500 │
114
- >> │ Characters 'a','l','b' should not be used., Characters SHOULD be limited to upper case letters (A-Z), numbers (0-9), '-' and '+' │
118
+ >> │ Characters 'b','l','a' should not be used., Characters SHOULD be limited to upper case letters (A-Z), numbers (0-9), '-' and '+' │
115
119
  >> │ │
116
120
  >> │ HTTPS://PAC.METTORIUS.COM/-MD/240:👉bal👈500/21:@1234 │
117
121
  >> ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
@@ -244,7 +248,7 @@ trex.print_validation_messages()
244
248
  >> Validation Results
245
249
  >> ┌────────────────────────────────────────────────────────────┐
246
250
  >> │ **ERROR** in TREX table column Date │
247
- >> │ Column header key contains invalid characters: 'a','t','e' │
251
+ >> │ Column header key contains invalid characters: 'e','a','t' │
248
252
  >> │ │
249
253
  >> │ STOP$T.D:20240505T1306 │
250
254
  >> │ +TEMP$KEL:10.15 │
@@ -252,9 +256,9 @@ trex.print_validation_messages()
252
256
  >> │ +COMMENT$T.A:FOO │
253
257
  >> │ +COMMENT2$T.T:12G3 │
254
258
  >> │ +TABLE$$DURATION$HUR:D👉ate👈$T.D:OK$T.B:COMMENT$T.A:: │
255
- >> │ 1:20250425T081731.192:T:FOO:: │
256
- >> │ 1.1:20250425T081731.192:T:BAR:: │
257
- >> │ 1.3:20250425T081731.192:F:BLUBB │
259
+ >> │ 1:20250430T100239.279:T:FOO:: │
260
+ >> │ 1.1:20250430T100239.280:T:BAR:: │
261
+ >> │ 1.3:20250430T100239.280:F:BLUBB │
258
262
  >> └────────────────────────────────────────────────────────────┘
259
263
  ```
260
264
  #### Combine PAC-ID and TREX and serialize
@@ -266,7 +270,7 @@ pac_str = pac.to_url()
266
270
  print(pac_str)
267
271
  ```
268
272
  ```text
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:12G3+TABLE$$DURATION$HUR:Date$T.D:OK$T.B:COMMENT$T.A::1:20250425T081731.192:T:FOO::1.1:20250425T081731.192:T:BAR::1.3:20250425T081731.192:F:BLUBB
273
+ >> 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:20250430T100239.279:T:FOO::1.1:20250430T100239.280:T:BAR::1.3:20250430T100239.280:F:BLUBB
270
274
  ```
271
275
  ## PAC-ID Resolver
272
276
 
@@ -292,7 +296,6 @@ cit2.origin = 'MY_COMPANY'
292
296
  pac_str = 'HTTPS://PAC.METTORIUS.COM/-MS/X3511/CAS:7732-18-5'
293
297
  service_groups = PAC_ID_Resolver(cits=[cit, cit2]).resolve(pac_str)
294
298
  for sg in service_groups:
295
- sg.update_states()
296
299
  sg.print()
297
300
 
298
301
  ```
@@ -324,6 +327,15 @@ for sg in service_groups:
324
327
 
325
328
  <!-- BEGIN CHANGELOG -->
326
329
  ## Change Log
330
+ ### v0.2.5
331
+ - resolvers checks service states by default
332
+ - improvements and bugfixes in conversion from python types to TREX
333
+ - follow better naming conventions in CIT v1
334
+
335
+ ### v0.2.4
336
+ - improvements in formatting of validation messages
337
+ - bugfix in DataTable
338
+
327
339
  ### v0.2.3
328
340
  - improvements in formatting of validation messages
329
341
  - bugfix in DisplayNameExtension
@@ -1,5 +1,5 @@
1
- labfreed/__init__.py,sha256=3RVSAhyE9FV9v1Fm9wRroBieDrCsoqsXYikr_9tvaRQ,339
2
- labfreed/labfreed_infrastructure.py,sha256=yxZkI0mPrHyeZGWKtgFIV9R54edSUcww-w1ExHt8F-o,9990
1
+ labfreed/__init__.py,sha256=KMWS_7my-1C0c_qdDMUahb4PLT1ARoVag-fhFhU4iQo,338
2
+ labfreed/labfreed_infrastructure.py,sha256=jTplE0_ctiNE_BA1i0C-z-D--I5vmbha18XRYgp-OBw,10012
3
3
  labfreed/pac_cat/__init__.py,sha256=KNPtQzBD1XVohvG_ucOs7RJj-oi6biUTGB1k-T2o6pk,568
4
4
  labfreed/pac_cat/category_base.py,sha256=lFQNiTUukyhWdaSCAI7CZxLtj6kNtnBCE4UsePwsGqE,1801
5
5
  labfreed/pac_cat/pac_cat.py,sha256=AJUYDsyGOHy-sRRpXpY0awtbf3HCvn3RhMax6ofvYRA,5318
@@ -8,12 +8,12 @@ labfreed/pac_id/__init__.py,sha256=NGMbzkwQ4txKeT5pxdIZordwHO8J3_q84jzPanjKoHg,6
8
8
  labfreed/pac_id/extension.py,sha256=zuHI8e51otPbpO1r1xDFh32uXTT8L5pCJn74B-aOUpI,1112
9
9
  labfreed/pac_id/id_segment.py,sha256=r5JU1SJuRXhZJJxy5T3xjrb598wIDTLpivSJhIUAzjQ,4526
10
10
  labfreed/pac_id/pac_id.py,sha256=IWXYlKFjQKB_9U5bINWC5_Lb5pcVbuleocvGs79A28w,5300
11
- labfreed/pac_id/url_parser.py,sha256=016Gd-V2OORDN2toAZEPmnXobrWNVVXM_zICBrQtqGY,5863
11
+ labfreed/pac_id/url_parser.py,sha256=TAQHxFf7Li8GA517mfOivmnJAJgh782oaSDzmOOkyTE,5942
12
12
  labfreed/pac_id/url_serializer.py,sha256=3D5pwcAP4ZrCQ22BRtxIwqWrFtZuY9913hCLPJNeyPI,2845
13
13
  labfreed/pac_id_resolver/__init__.py,sha256=RNBlrDOSR42gmSNH9wJVhK_xwEX45cvTKVgWW2bjh7Q,113
14
- labfreed/pac_id_resolver/cit_v1.py,sha256=G5CitglgN9Vg0yoNPApcgcI1GjOgW6k4HUwqpJgINKQ,5800
14
+ labfreed/pac_id_resolver/cit_v1.py,sha256=SAI6W9FgJV4wirDN1CZqYKy6wCI8bkHgHmhgnp9vMU8,5965
15
15
  labfreed/pac_id_resolver/cit_v2.py,sha256=J7KsYUKSz4k7lqSHmLnouRY-etEbwmcj35O5SqVRm-o,11594
16
- labfreed/pac_id_resolver/resolver.py,sha256=5v8p7hM4dkjygClN1isYVy-BpCMZouBn5tVHzXR6Qso,2300
16
+ labfreed/pac_id_resolver/resolver.py,sha256=SQlATlaUsmS6EZlEMyBQsp00ixpN3r-3V5pMXcvHYCw,2739
17
17
  labfreed/pac_id_resolver/services.py,sha256=TPoH6YlSwa0hmawHpOiMwIpBAinhoRhMSoexop0YscI,2462
18
18
  labfreed/qr/__init__.py,sha256=fdKwP6W2Js--yMbBUdn-g_2uq2VqPpfQJeDLHsMDO-Y,61
19
19
  labfreed/qr/generate_qr.py,sha256=mSt-U872O3ReHB_UdS-MzYu0wRgdlKcAOEfTxg5CLRk,16616
@@ -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.5a22.dist-info/licenses/LICENSE,sha256=gHFOv9FRKHxO8cInP3YXyPoJnuNeqrvcHjaE_wPSsQ8,1100
42
- labfreed-0.2.5a22.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
43
- labfreed-0.2.5a22.dist-info/METADATA,sha256=XALiaFCjKEkmXi6pgb_XxLCRfL0azXWCHqh2d41Bwrc,18093
44
- labfreed-0.2.5a22.dist-info/RECORD,,
41
+ labfreed-0.2.6a1.dist-info/licenses/LICENSE,sha256=gHFOv9FRKHxO8cInP3YXyPoJnuNeqrvcHjaE_wPSsQ8,1100
42
+ labfreed-0.2.6a1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
43
+ labfreed-0.2.6a1.dist-info/METADATA,sha256=zSzgN9eN2fLyZ_cw8a0kZhvaBp3jTPVSiA24-cIoU5w,18616
44
+ labfreed-0.2.6a1.dist-info/RECORD,,