labfreed 0.0.19__tar.gz → 0.0.20__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.
- {labfreed-0.0.19 → labfreed-0.0.20}/PKG-INFO +33 -15
- {labfreed-0.0.19 → labfreed-0.0.20}/README.md +32 -15
- {labfreed-0.0.19 → labfreed-0.0.20}/examples.py +9 -7
- {labfreed-0.0.19 → labfreed-0.0.20}/labfreed/TREX/data_model.py +2 -2
- {labfreed-0.0.19 → labfreed-0.0.20}/labfreed/__init__.py +1 -1
- {labfreed-0.0.19 → labfreed-0.0.20}/labfreed/validation.py +8 -2
- labfreed-0.0.19/labfreed/IO/generate_label.py +0 -81
- {labfreed-0.0.19 → labfreed-0.0.20}/.vscode/launch.json +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/.vscode/settings.json +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/LICENSE +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/labfreed/DisplayNameExtension/DisplayNameExtension.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/labfreed/IO/generate_qr.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/labfreed/IO/parse_pac.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/labfreed/PAC_CAT/__init__.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/labfreed/PAC_CAT/data_model.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/labfreed/PAC_ID/__init__.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/labfreed/PAC_ID/data_model.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/labfreed/PAC_ID/extensions.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/labfreed/TREX/UneceUnits.json +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/labfreed/TREX/parse.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/labfreed/TREX/unece_units.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/labfreed/utilities/base36.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/labfreed/utilities/utility_types.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/labfreed/utilities/well_known_keys.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/main.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/publish.ps1 +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/publish.sh +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/publish_commands +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/pyproject.toml +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/pytest.ini +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/tests/test_(de)_serialization_incl_extension/test__parse.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/tests/test_(de)_serialization_incl_extension/test__serialize.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/tests/test_PAC_CAT/test_PAC_CAT_parse.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/tests/test_PAC_CAT/test_PAC_CAT_serialize.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/tests/test_PAC_ID/test_PAC_ID_serialize.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/tests/test_PAC_ID/test_pac_id_parse.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/tests/test_TREX/test_TREX_parse.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/tests/test_TREX/test_TREX_serialize.py +0 -0
- {labfreed-0.0.19 → labfreed-0.0.20}/update_readme.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: labfreed
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.20
|
|
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
|
|
@@ -19,7 +19,7 @@ Requires-Dist: typer>=0.15.2
|
|
|
19
19
|
[](https://github.com/retothuerer/LabFREED/actions/workflows/ci.yml)
|
|
20
20
|
-->
|
|
21
21
|
|
|
22
|
-
This is a Python implementation of [LabFREED](
|
|
22
|
+
This is a Python implementation of [LabFREED](https://labfreed.wega-it.com) building blocks.
|
|
23
23
|
|
|
24
24
|
## Supported Building Blocks
|
|
25
25
|
- PAC-ID
|
|
@@ -60,7 +60,7 @@ Note that the PAC-ID -- while valid -- uses characters which are not recommended
|
|
|
60
60
|
There is a nice function to highlight problems
|
|
61
61
|
|
|
62
62
|
```python
|
|
63
|
-
pac_id.print_validation_messages()
|
|
63
|
+
pac_id.print_validation_messages(target='markdown')
|
|
64
64
|
```
|
|
65
65
|
```text
|
|
66
66
|
>> =======================================
|
|
@@ -68,15 +68,15 @@ pac_id.print_validation_messages()
|
|
|
68
68
|
>> ---------------------------------------
|
|
69
69
|
>>
|
|
70
70
|
>> Recommendation in id segment value bal500
|
|
71
|
-
>> HTTPS://PAC.METTORIUS.COM/-MD
|
|
72
|
-
>> Characters l a
|
|
71
|
+
>> HTTPS://PAC.METTORIUS.COM/-MD/🔸b🔸🔸a🔸🔸l🔸500/@1234
|
|
72
|
+
>> Characters b l a should not be used.
|
|
73
73
|
>>
|
|
74
74
|
>> Recommendation in id segment value @1234
|
|
75
|
-
>> HTTPS://PAC.METTORIUS.COM/-MD/bal500
|
|
75
|
+
>> HTTPS://PAC.METTORIUS.COM/-MD/bal500/🔸@🔸1234
|
|
76
76
|
>> Characters @ should not be used.
|
|
77
77
|
>>
|
|
78
78
|
>> Warning in Category -MD
|
|
79
|
-
>> HTTPS://PAC.METTORIUS.COM
|
|
79
|
+
>> HTTPS://PAC.METTORIUS.COM/🔸-MD🔸/bal500/@1234
|
|
80
80
|
>> Category key -MD is not a well known key. It is recommended to use well known keys only
|
|
81
81
|
```
|
|
82
82
|
### Save as QR Code
|
|
@@ -144,12 +144,12 @@ print(f'WEIGHT = {v}')
|
|
|
144
144
|
from labfreed.PAC_ID.data_model import PACID, IDSegment
|
|
145
145
|
from labfreed.utilities.well_known_keys import WellKnownKeys
|
|
146
146
|
|
|
147
|
-
pac_id = PACID(issuer='METTORIUS
|
|
147
|
+
pac_id = PACID(issuer='METTORIUS.COM', identifier=[IDSegment(key=WellKnownKeys.SERIAL, value='1234')])
|
|
148
148
|
pac_str = pac_id.serialize()
|
|
149
149
|
print(pac_str)
|
|
150
150
|
```
|
|
151
151
|
```text
|
|
152
|
-
>> HTTPS://PAC.METTORIUS
|
|
152
|
+
>> HTTPS://PAC.METTORIUS.COM/21:1234
|
|
153
153
|
```
|
|
154
154
|
#### Create a TREX
|
|
155
155
|
TREX can conveniently be created from a python dictionary.
|
|
@@ -174,7 +174,7 @@ trex.update(
|
|
|
174
174
|
)
|
|
175
175
|
|
|
176
176
|
# Create a table
|
|
177
|
-
table = DataTable(['DURATION', '
|
|
177
|
+
table = DataTable(['DURATION', 'Date', 'OK', 'COMMENT'])
|
|
178
178
|
table.append([Quantity(value=1, unit=Unit(symbol='h', name='hour')), datetime.now(), True, 'FOO'])
|
|
179
179
|
table.append([ 1.1, datetime.now(), True, 'BAR'])
|
|
180
180
|
table.append([ 1.3, datetime.now(), False, 'BLUBB'])
|
|
@@ -182,11 +182,23 @@ table.append([ 1.3, datetime.no
|
|
|
182
182
|
trex.update({'TABLE': table})
|
|
183
183
|
|
|
184
184
|
# Validation also works the same way for TREX
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
trex.print_validation_messages(target='markdown')
|
|
186
|
+
```
|
|
187
|
+
```text
|
|
188
|
+
>> =======================================
|
|
189
|
+
>> Validation Results
|
|
190
|
+
>> ---------------------------------------
|
|
191
|
+
>>
|
|
192
|
+
>> Error in TREX table column Date
|
|
193
|
+
>> DEMO$TREX/STOP$T.D:20240505T1306+TEMP$KEL:10.15+OK$T.B:F+COMMENT$T.A:FOO+COMMENT2$T.T:12G3+TABLE$$DURATION$HUR:D🔸a🔸🔸t🔸🔸e🔸$T.D:OK$T.B:COMMENT$T.A::1:20250409T094048.268:T:FOO::1.1:20250409T094048.268:T:BAR::1.3:20250409T094048.268:F:BLUBB
|
|
194
|
+
>> Column header key contains invalid characters: e,t,a
|
|
195
|
+
```
|
|
196
|
+
```python
|
|
197
|
+
# there is an error. 'Date' uses lower case. Lets fix it
|
|
189
198
|
d = trex.dict()
|
|
199
|
+
d['TABLE'].col_names[1] = 'DATE'
|
|
200
|
+
trex = TREX(name_='DEMO')
|
|
201
|
+
trex.update(d)
|
|
190
202
|
```
|
|
191
203
|
#### Combine PAC-ID and TREX and serialize
|
|
192
204
|
|
|
@@ -198,7 +210,7 @@ pac_str = pac_with_trex.serialize()
|
|
|
198
210
|
print(pac_str)
|
|
199
211
|
```
|
|
200
212
|
```text
|
|
201
|
-
>> HTTPS://PAC.METTORIUS
|
|
213
|
+
>> HTTPS://PAC.METTORIUS.COM/21:1234*DEMO$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:20250409T094048.268:T:FOO::1.1:20250409T094048.268:T:BAR::1.3:20250409T094048.268:F:BLUBB
|
|
202
214
|
```
|
|
203
215
|
<!-- END EXAMPLES -->
|
|
204
216
|
|
|
@@ -206,7 +218,13 @@ print(pac_str)
|
|
|
206
218
|
|
|
207
219
|
## Change Log
|
|
208
220
|
|
|
221
|
+
### v0.0.20
|
|
222
|
+
- bugfix in TREX table to dict conversion
|
|
223
|
+
- markdown compatible validation printing
|
|
224
|
+
|
|
209
225
|
### v0.0.19
|
|
210
226
|
- supports PAC-ID, PAC-CAT, TREX and DisplayName
|
|
211
227
|
- QR generation
|
|
212
228
|
- ok-ish test coverage
|
|
229
|
+
|
|
230
|
+
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://github.com/retothuerer/LabFREED/actions/workflows/ci.yml)
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
|
-
This is a Python implementation of [LabFREED](
|
|
9
|
+
This is a Python implementation of [LabFREED](https://labfreed.wega-it.com) building blocks.
|
|
10
10
|
|
|
11
11
|
## Supported Building Blocks
|
|
12
12
|
- PAC-ID
|
|
@@ -47,7 +47,7 @@ Note that the PAC-ID -- while valid -- uses characters which are not recommended
|
|
|
47
47
|
There is a nice function to highlight problems
|
|
48
48
|
|
|
49
49
|
```python
|
|
50
|
-
pac_id.print_validation_messages()
|
|
50
|
+
pac_id.print_validation_messages(target='markdown')
|
|
51
51
|
```
|
|
52
52
|
```text
|
|
53
53
|
>> =======================================
|
|
@@ -55,15 +55,15 @@ pac_id.print_validation_messages()
|
|
|
55
55
|
>> ---------------------------------------
|
|
56
56
|
>>
|
|
57
57
|
>> Recommendation in id segment value bal500
|
|
58
|
-
>> HTTPS://PAC.METTORIUS.COM/-MD
|
|
59
|
-
>> Characters l a
|
|
58
|
+
>> HTTPS://PAC.METTORIUS.COM/-MD/🔸b🔸🔸a🔸🔸l🔸500/@1234
|
|
59
|
+
>> Characters b l a should not be used.
|
|
60
60
|
>>
|
|
61
61
|
>> Recommendation in id segment value @1234
|
|
62
|
-
>> HTTPS://PAC.METTORIUS.COM/-MD/bal500
|
|
62
|
+
>> HTTPS://PAC.METTORIUS.COM/-MD/bal500/🔸@🔸1234
|
|
63
63
|
>> Characters @ should not be used.
|
|
64
64
|
>>
|
|
65
65
|
>> Warning in Category -MD
|
|
66
|
-
>> HTTPS://PAC.METTORIUS.COM
|
|
66
|
+
>> HTTPS://PAC.METTORIUS.COM/🔸-MD🔸/bal500/@1234
|
|
67
67
|
>> Category key -MD is not a well known key. It is recommended to use well known keys only
|
|
68
68
|
```
|
|
69
69
|
### Save as QR Code
|
|
@@ -131,12 +131,12 @@ print(f'WEIGHT = {v}')
|
|
|
131
131
|
from labfreed.PAC_ID.data_model import PACID, IDSegment
|
|
132
132
|
from labfreed.utilities.well_known_keys import WellKnownKeys
|
|
133
133
|
|
|
134
|
-
pac_id = PACID(issuer='METTORIUS
|
|
134
|
+
pac_id = PACID(issuer='METTORIUS.COM', identifier=[IDSegment(key=WellKnownKeys.SERIAL, value='1234')])
|
|
135
135
|
pac_str = pac_id.serialize()
|
|
136
136
|
print(pac_str)
|
|
137
137
|
```
|
|
138
138
|
```text
|
|
139
|
-
>> HTTPS://PAC.METTORIUS
|
|
139
|
+
>> HTTPS://PAC.METTORIUS.COM/21:1234
|
|
140
140
|
```
|
|
141
141
|
#### Create a TREX
|
|
142
142
|
TREX can conveniently be created from a python dictionary.
|
|
@@ -161,7 +161,7 @@ trex.update(
|
|
|
161
161
|
)
|
|
162
162
|
|
|
163
163
|
# Create a table
|
|
164
|
-
table = DataTable(['DURATION', '
|
|
164
|
+
table = DataTable(['DURATION', 'Date', 'OK', 'COMMENT'])
|
|
165
165
|
table.append([Quantity(value=1, unit=Unit(symbol='h', name='hour')), datetime.now(), True, 'FOO'])
|
|
166
166
|
table.append([ 1.1, datetime.now(), True, 'BAR'])
|
|
167
167
|
table.append([ 1.3, datetime.now(), False, 'BLUBB'])
|
|
@@ -169,11 +169,23 @@ table.append([ 1.3, datetime.no
|
|
|
169
169
|
trex.update({'TABLE': table})
|
|
170
170
|
|
|
171
171
|
# Validation also works the same way for TREX
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
172
|
+
trex.print_validation_messages(target='markdown')
|
|
173
|
+
```
|
|
174
|
+
```text
|
|
175
|
+
>> =======================================
|
|
176
|
+
>> Validation Results
|
|
177
|
+
>> ---------------------------------------
|
|
178
|
+
>>
|
|
179
|
+
>> Error in TREX table column Date
|
|
180
|
+
>> DEMO$TREX/STOP$T.D:20240505T1306+TEMP$KEL:10.15+OK$T.B:F+COMMENT$T.A:FOO+COMMENT2$T.T:12G3+TABLE$$DURATION$HUR:D🔸a🔸🔸t🔸🔸e🔸$T.D:OK$T.B:COMMENT$T.A::1:20250409T094048.268:T:FOO::1.1:20250409T094048.268:T:BAR::1.3:20250409T094048.268:F:BLUBB
|
|
181
|
+
>> Column header key contains invalid characters: e,t,a
|
|
182
|
+
```
|
|
183
|
+
```python
|
|
184
|
+
# there is an error. 'Date' uses lower case. Lets fix it
|
|
176
185
|
d = trex.dict()
|
|
186
|
+
d['TABLE'].col_names[1] = 'DATE'
|
|
187
|
+
trex = TREX(name_='DEMO')
|
|
188
|
+
trex.update(d)
|
|
177
189
|
```
|
|
178
190
|
#### Combine PAC-ID and TREX and serialize
|
|
179
191
|
|
|
@@ -185,7 +197,7 @@ pac_str = pac_with_trex.serialize()
|
|
|
185
197
|
print(pac_str)
|
|
186
198
|
```
|
|
187
199
|
```text
|
|
188
|
-
>> HTTPS://PAC.METTORIUS
|
|
200
|
+
>> HTTPS://PAC.METTORIUS.COM/21:1234*DEMO$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:20250409T094048.268:T:FOO::1.1:20250409T094048.268:T:BAR::1.3:20250409T094048.268:F:BLUBB
|
|
189
201
|
```
|
|
190
202
|
<!-- END EXAMPLES -->
|
|
191
203
|
|
|
@@ -193,7 +205,12 @@ print(pac_str)
|
|
|
193
205
|
|
|
194
206
|
## Change Log
|
|
195
207
|
|
|
208
|
+
### v0.0.20
|
|
209
|
+
- bugfix in TREX table to dict conversion
|
|
210
|
+
- markdown compatible validation printing
|
|
211
|
+
|
|
196
212
|
### v0.0.19
|
|
197
213
|
- supports PAC-ID, PAC-CAT, TREX and DisplayName
|
|
198
214
|
- QR generation
|
|
199
|
-
- ok-ish test coverage
|
|
215
|
+
- ok-ish test coverage
|
|
216
|
+
|
|
@@ -17,7 +17,7 @@ print(f'PAC-ID is valid: {is_valid}')
|
|
|
17
17
|
Note that the PAC-ID -- while valid -- uses characters which are not recommended (results in larger QR code).
|
|
18
18
|
There is a nice function to highlight problems
|
|
19
19
|
'''
|
|
20
|
-
pac_id.print_validation_messages()
|
|
20
|
+
pac_id.print_validation_messages(target='markdown')
|
|
21
21
|
|
|
22
22
|
'''
|
|
23
23
|
### Save as QR Code
|
|
@@ -65,7 +65,7 @@ print(f'WEIGHT = {v}')
|
|
|
65
65
|
from labfreed.PAC_ID.data_model import PACID, IDSegment
|
|
66
66
|
from labfreed.utilities.well_known_keys import WellKnownKeys
|
|
67
67
|
|
|
68
|
-
pac_id = PACID(issuer='METTORIUS
|
|
68
|
+
pac_id = PACID(issuer='METTORIUS.COM', identifier=[IDSegment(key=WellKnownKeys.SERIAL, value='1234')])
|
|
69
69
|
pac_str = pac_id.serialize()
|
|
70
70
|
print(pac_str)
|
|
71
71
|
|
|
@@ -93,7 +93,7 @@ trex.update(
|
|
|
93
93
|
)
|
|
94
94
|
|
|
95
95
|
# Create a table
|
|
96
|
-
table = DataTable(['DURATION', '
|
|
96
|
+
table = DataTable(['DURATION', 'Date', 'OK', 'COMMENT'])
|
|
97
97
|
table.append([Quantity(value=1, unit=Unit(symbol='h', name='hour')), datetime.now(), True, 'FOO'])
|
|
98
98
|
table.append([ 1.1, datetime.now(), True, 'BAR'])
|
|
99
99
|
table.append([ 1.3, datetime.now(), False, 'BLUBB'])
|
|
@@ -101,11 +101,13 @@ table.append([ 1.3, datetime.no
|
|
|
101
101
|
trex.update({'TABLE': table})
|
|
102
102
|
|
|
103
103
|
# Validation also works the same way for TREX
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
# Side Note: The TREX can be turned back into a dict
|
|
104
|
+
trex.print_validation_messages(target='markdown')
|
|
105
|
+
''''''
|
|
106
|
+
# there is an error. 'Date' uses lower case. Lets fix it
|
|
108
107
|
d = trex.dict()
|
|
108
|
+
d['TABLE'].col_names[1] = 'DATE'
|
|
109
|
+
trex = TREX(name_='DEMO')
|
|
110
|
+
trex.update(d)
|
|
109
111
|
|
|
110
112
|
'''
|
|
111
113
|
#### Combine PAC-ID and TREX and serialize
|
|
@@ -436,7 +436,7 @@ class TREX_Table(TREX_Segment):
|
|
|
436
436
|
self.add_validation_message(
|
|
437
437
|
source=f"Table {self.key}",
|
|
438
438
|
type="Error",
|
|
439
|
-
msg=f"Size mismatch: Table header contains {self.
|
|
439
|
+
msg=f"Size mismatch: Table header contains {self.column_names} keys, while most rows have {most_common_len}",
|
|
440
440
|
highlight_pattern = self.key
|
|
441
441
|
)
|
|
442
442
|
expected_row_len = most_common_len
|
|
@@ -527,7 +527,7 @@ class TREX_Table(TREX_Segment):
|
|
|
527
527
|
r.append(Quantity(value=e.value, unit=unit))
|
|
528
528
|
else:
|
|
529
529
|
r.append(e.value_to_python_type())
|
|
530
|
-
|
|
530
|
+
table.append(r)
|
|
531
531
|
return table
|
|
532
532
|
|
|
533
533
|
|
|
@@ -113,7 +113,7 @@ class BaseModelWithValidationMessages(BaseModel):
|
|
|
113
113
|
return filter_warnings(self.get_nested_validation_messages())
|
|
114
114
|
|
|
115
115
|
|
|
116
|
-
def print_validation_messages(self, str_to_highlight_in=None):
|
|
116
|
+
def print_validation_messages(self, str_to_highlight_in=None, target='console'):
|
|
117
117
|
if not str_to_highlight_in:
|
|
118
118
|
str_to_highlight_in = str(self)
|
|
119
119
|
msgs = self.get_nested_validation_messages()
|
|
@@ -133,7 +133,13 @@ class BaseModelWithValidationMessages(BaseModel):
|
|
|
133
133
|
|
|
134
134
|
text = Text.from_markup(f'\n [bold {color}]{m.type} [/bold {color}] in \t {m.source}' )
|
|
135
135
|
print(text)
|
|
136
|
-
|
|
136
|
+
match target:
|
|
137
|
+
case 'markdown':
|
|
138
|
+
formatted_highlight = m.emphazised_highlight.replace('emph', f'🔸').replace('[/', '').replace('[', '').replace(']', '')
|
|
139
|
+
case 'console':
|
|
140
|
+
formatted_highlight = m.emphazised_highlight.replace('emph', f'bold {color}')
|
|
141
|
+
case 'html':
|
|
142
|
+
formatted_highlight = m.emphazised_highlight.replace('emph', f'b').replace('[', '<').replace(']', '>')
|
|
137
143
|
fmtd = str_to_highlight_in.replace(m.highlight, formatted_highlight)
|
|
138
144
|
fmtd = Text.from_markup(fmtd)
|
|
139
145
|
print(fmtd)
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
|
|
3
|
-
from .generate_qr import generate_qr_with_markers_svg
|
|
4
|
-
|
|
5
|
-
from labfreed.PAC_ID.data_model import PACID
|
|
6
|
-
from labfreed.DisplayNameExtension.DisplayNameExtension import DisplayNames
|
|
7
|
-
from labfreed.IO.parse_pac import PACID_With_Extensions
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def generate_label_200_100(pac_url, pac:PACID_With_Extensions):
|
|
14
|
-
title, infos = get_label_fields(pac)
|
|
15
|
-
pac_svg = generate_qr_with_markers_svg(pac_url, height=60, width=100, border=0)
|
|
16
|
-
label = _generate_label(pac_svg, 200, 100, title, infos)
|
|
17
|
-
return label
|
|
18
|
-
|
|
19
|
-
def generate_label_credit_card_size(pac_url, pac:PACID_With_Extensions):
|
|
20
|
-
title, infos = get_label_fields(pac)
|
|
21
|
-
pac_svg = generate_qr_with_markers_svg(pac_url, height=100, width=200, border=0)
|
|
22
|
-
label = _generate_label(pac_svg, 240, 150, title, infos)
|
|
23
|
-
return label
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def _generate_label(qr_svg, width, height, title=None, infos=[]):
|
|
27
|
-
if not qr_svg:
|
|
28
|
-
raise ValueError("no valid qr given")
|
|
29
|
-
env = Environment(
|
|
30
|
-
loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates")),
|
|
31
|
-
autoescape=select_autoescape()
|
|
32
|
-
)
|
|
33
|
-
template = env.get_template("pac_label.jinja.svg")
|
|
34
|
-
svg = template.render(width=width, height= height, pac_qr=qr_svg, title=title, info1=infos[0], info2=infos[1], info3=infos[2])
|
|
35
|
-
|
|
36
|
-
return svg
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def get_label_fields(pac:PACID_With_Extensions) -> tuple[str, list[tuple[str, str]]]:
|
|
41
|
-
'''
|
|
42
|
-
returns a list of exactly length 3. Containing either info tuples (key value) or None
|
|
43
|
-
'''
|
|
44
|
-
if dn_extension := next((e for e in pac.extensions if isinstance(e, DisplayNames)), None): #find extension of type DisplayName
|
|
45
|
-
title = dn_extension.display_names[0]
|
|
46
|
-
else:
|
|
47
|
-
title = ""
|
|
48
|
-
|
|
49
|
-
infos = []
|
|
50
|
-
cat = pac.pac_id.identifier.categories[0]
|
|
51
|
-
for s in cat.segments:
|
|
52
|
-
lbl = pretty_print_segment_label(cat.key, s.key)
|
|
53
|
-
infos.append((lbl, s.value))
|
|
54
|
-
|
|
55
|
-
while len(infos) < 3:
|
|
56
|
-
infos.append(None)
|
|
57
|
-
|
|
58
|
-
if len(infos) > 3:
|
|
59
|
-
infos = infos[0:3]
|
|
60
|
-
|
|
61
|
-
return title,infos
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def pretty_print_segment_label(category:str, segment_key:str):
|
|
65
|
-
if not segment_key:
|
|
66
|
-
return 'no key'
|
|
67
|
-
|
|
68
|
-
cat = CAT_from_category_key(category)
|
|
69
|
-
if cat:
|
|
70
|
-
alias_to_field = {v.alias: k for k, v in cat.model_fields.items() if v.alias}
|
|
71
|
-
segment_label = alias_to_field.get(segment_key, segment_key)
|
|
72
|
-
segment_label = segment_label.replace('_', ' ').title()
|
|
73
|
-
|
|
74
|
-
segment_label = segment_label.replace('Id', 'ID')
|
|
75
|
-
|
|
76
|
-
else:
|
|
77
|
-
segment_label = segment_key
|
|
78
|
-
|
|
79
|
-
return segment_label
|
|
80
|
-
|
|
81
|
-
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{labfreed-0.0.19 → labfreed-0.0.20}/tests/test_(de)_serialization_incl_extension/test__parse.py
RENAMED
|
File without changes
|
{labfreed-0.0.19 → labfreed-0.0.20}/tests/test_(de)_serialization_incl_extension/test__serialize.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|