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/trex/__init__.py
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
from .trex import TREX
|
|
2
|
-
from .value_segments import NumericSegment, DateSegment, BoolSegment, AlphanumericSegment, TextSegment, ErrorSegment
|
|
3
|
-
from .table_segment import TableSegment, ColumnHeader, TableRow
|
|
4
|
-
|
|
5
|
-
__all__ = [
|
|
6
|
-
"TREX",
|
|
7
|
-
"NumericSegment",
|
|
8
|
-
"DateSegment",
|
|
9
|
-
"BoolSegment",
|
|
10
|
-
"AlphanumericSegment",
|
|
11
|
-
"TextSegment",
|
|
12
|
-
"ErrorSegment",
|
|
13
|
-
"TableSegment",
|
|
14
|
-
"ColumnHeader",
|
|
15
|
-
"TableRow"
|
|
16
|
-
]
|
|
1
|
+
from .trex import TREX
|
|
2
|
+
from .value_segments import NumericSegment, DateSegment, BoolSegment, AlphanumericSegment, TextSegment, ErrorSegment
|
|
3
|
+
from .table_segment import TableSegment, ColumnHeader, TableRow
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"TREX",
|
|
7
|
+
"NumericSegment",
|
|
8
|
+
"DateSegment",
|
|
9
|
+
"BoolSegment",
|
|
10
|
+
"AlphanumericSegment",
|
|
11
|
+
"TextSegment",
|
|
12
|
+
"ErrorSegment",
|
|
13
|
+
"TableSegment",
|
|
14
|
+
"ColumnHeader",
|
|
15
|
+
"TableRow"
|
|
16
|
+
]
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
from .pyTREX import pyTREX # noqa: F401
|
|
2
|
-
from .data_table import DataTable # noqa: F401
|
|
3
|
-
from .quantity import Quantity # noqa: F401
|
|
1
|
+
from .pyTREX import pyTREX # noqa: F401
|
|
2
|
+
from .data_table import DataTable # noqa: F401
|
|
3
|
+
from .quantity import Quantity # noqa: F401
|
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
from datetime import date, datetime, time
|
|
4
|
-
from typing import Union
|
|
5
|
-
from pydantic import BaseModel, Field, PrivateAttr, model_validator
|
|
6
|
-
|
|
7
|
-
from labfreed.utilities.base36 import base36
|
|
8
|
-
from labfreed.trex.python_convenience.quantity import Quantity
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class DataTable(BaseModel):
|
|
12
|
-
_row_template:list[str, Quantity | datetime | time | date | bool | str | base36] = PrivateAttr(default_factory=list)
|
|
13
|
-
col_names: list[str] = Field(default_factory=list)
|
|
14
|
-
data:list[list[Union[Quantity, datetime, time, date, bool, str, base36, None]]] = Field(default_factory=list)
|
|
15
|
-
|
|
16
|
-
@property
|
|
17
|
-
def row_template(self):
|
|
18
|
-
return self._row_template
|
|
19
|
-
|
|
20
|
-
@model_validator(mode='after')
|
|
21
|
-
def get_row_template(self):
|
|
22
|
-
if not self.data: # data not initialized during construction. This is valid
|
|
23
|
-
return self
|
|
24
|
-
|
|
25
|
-
for r in self.data:
|
|
26
|
-
if all([e is not None for e in r]):
|
|
27
|
-
self._row_template = r.copy()
|
|
28
|
-
break
|
|
29
|
-
if not self._row_template:
|
|
30
|
-
raise ValueError('All columns contained at least one None. This is invalid')
|
|
31
|
-
return self
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def append(self, row:list, validate=True):
|
|
35
|
-
if not isinstance(row, list):
|
|
36
|
-
raise ValueError('row must be a list of values')
|
|
37
|
-
if not self._row_template:
|
|
38
|
-
self._row_template = row.copy()
|
|
39
|
-
if not len(row) == len(self._row_template):
|
|
40
|
-
raise ValueError('row is not of same length as the row template.')
|
|
41
|
-
if not self.col_names:
|
|
42
|
-
self.col_names = [f"Col{i}" for i in range(len(self._row_template))]
|
|
43
|
-
|
|
44
|
-
# make sure int and float have a unit, if the row_tempalet has one
|
|
45
|
-
for i, e in enumerate(row):
|
|
46
|
-
if isinstance(e, float|int) and isinstance(self._row_template[i], Quantity):
|
|
47
|
-
unit = self._row_template[i].unit
|
|
48
|
-
row[i] = Quantity(value=e, unit=unit)
|
|
49
|
-
self.data.append(row)
|
|
50
|
-
if validate:
|
|
51
|
-
self.model_rebuild()
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def extend(self, iterable):
|
|
55
|
-
for item in iterable:
|
|
56
|
-
if not len(item) == len(self._row_template):
|
|
57
|
-
raise ValueError('row is not of same length as the row template.')
|
|
58
|
-
self.append(item, validate=False)
|
|
59
|
-
self.model_rebuild()
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def get_column(self, col:str|int) -> list:
|
|
63
|
-
if isinstance(col, str):
|
|
64
|
-
col_index = self.col_names.index(col)
|
|
65
|
-
else:
|
|
66
|
-
col_index = col
|
|
67
|
-
col_data = [row[col_index] for row in self.data]
|
|
68
|
-
return col_data
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
def get_row(self, row_index:int) -> list:
|
|
72
|
-
return self.data[row_index]
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def get_row_as_dict(self, row_index:int) -> dict:
|
|
76
|
-
d = {k:v for k, v in zip(self.col_names, self.data[row_index])}
|
|
77
|
-
return d
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def get_cell(self, row_index:int, col:str|int):
|
|
81
|
-
if isinstance(col, str):
|
|
82
|
-
col_index = self.col_names.index(col)
|
|
83
|
-
else:
|
|
84
|
-
col_index = col
|
|
85
|
-
return self.data[row_index][col_index]
|
|
86
|
-
|
|
87
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
from datetime import date, datetime, time
|
|
4
|
+
from typing import Union
|
|
5
|
+
from pydantic import BaseModel, Field, PrivateAttr, model_validator
|
|
6
|
+
|
|
7
|
+
from labfreed.utilities.base36 import base36
|
|
8
|
+
from labfreed.trex.python_convenience.quantity import Quantity
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class DataTable(BaseModel):
|
|
12
|
+
_row_template:list[str, Quantity | datetime | time | date | bool | str | base36] = PrivateAttr(default_factory=list)
|
|
13
|
+
col_names: list[str] = Field(default_factory=list)
|
|
14
|
+
data:list[list[Union[Quantity, datetime, time, date, bool, str, base36, None]]] = Field(default_factory=list)
|
|
15
|
+
|
|
16
|
+
@property
|
|
17
|
+
def row_template(self):
|
|
18
|
+
return self._row_template
|
|
19
|
+
|
|
20
|
+
@model_validator(mode='after')
|
|
21
|
+
def get_row_template(self):
|
|
22
|
+
if not self.data: # data not initialized during construction. This is valid
|
|
23
|
+
return self
|
|
24
|
+
|
|
25
|
+
for r in self.data:
|
|
26
|
+
if all([e is not None for e in r]):
|
|
27
|
+
self._row_template = r.copy()
|
|
28
|
+
break
|
|
29
|
+
if not self._row_template:
|
|
30
|
+
raise ValueError('All columns contained at least one None. This is invalid')
|
|
31
|
+
return self
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def append(self, row:list, validate=True):
|
|
35
|
+
if not isinstance(row, list):
|
|
36
|
+
raise ValueError('row must be a list of values')
|
|
37
|
+
if not self._row_template:
|
|
38
|
+
self._row_template = row.copy()
|
|
39
|
+
if not len(row) == len(self._row_template):
|
|
40
|
+
raise ValueError('row is not of same length as the row template.')
|
|
41
|
+
if not self.col_names:
|
|
42
|
+
self.col_names = [f"Col{i}" for i in range(len(self._row_template))]
|
|
43
|
+
|
|
44
|
+
# make sure int and float have a unit, if the row_tempalet has one
|
|
45
|
+
for i, e in enumerate(row):
|
|
46
|
+
if isinstance(e, float|int) and isinstance(self._row_template[i], Quantity):
|
|
47
|
+
unit = self._row_template[i].unit
|
|
48
|
+
row[i] = Quantity(value=e, unit=unit)
|
|
49
|
+
self.data.append(row)
|
|
50
|
+
if validate:
|
|
51
|
+
self.model_rebuild()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def extend(self, iterable):
|
|
55
|
+
for item in iterable:
|
|
56
|
+
if not len(item) == len(self._row_template):
|
|
57
|
+
raise ValueError('row is not of same length as the row template.')
|
|
58
|
+
self.append(item, validate=False)
|
|
59
|
+
self.model_rebuild()
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def get_column(self, col:str|int) -> list:
|
|
63
|
+
if isinstance(col, str):
|
|
64
|
+
col_index = self.col_names.index(col)
|
|
65
|
+
else:
|
|
66
|
+
col_index = col
|
|
67
|
+
col_data = [row[col_index] for row in self.data]
|
|
68
|
+
return col_data
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def get_row(self, row_index:int) -> list:
|
|
72
|
+
return self.data[row_index]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def get_row_as_dict(self, row_index:int) -> dict:
|
|
76
|
+
d = {k:v for k, v in zip(self.col_names, self.data[row_index])}
|
|
77
|
+
return d
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def get_cell(self, row_index:int, col:str|int):
|
|
81
|
+
if isinstance(col, str):
|
|
82
|
+
col_index = self.col_names.index(col)
|
|
83
|
+
else:
|
|
84
|
+
col_index = col
|
|
85
|
+
return self.data[row_index][col_index]
|
|
86
|
+
|
|
87
|
+
|
|
88
88
|
|