labfreed 1.0.0a2__py3-none-any.whl → 1.0.0a3__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 +1 -1
- labfreed/pac_attributes/client/client.py +9 -6
- labfreed/pac_attributes/pythonic/excel_attribute_data_source.py +11 -4
- labfreed/pac_attributes/server/attribute_data_sources.py +10 -4
- {labfreed-1.0.0a2.dist-info → labfreed-1.0.0a3.dist-info}/METADATA +1 -1
- {labfreed-1.0.0a2.dist-info → labfreed-1.0.0a3.dist-info}/RECORD +8 -8
- {labfreed-1.0.0a2.dist-info → labfreed-1.0.0a3.dist-info}/WHEEL +0 -0
- {labfreed-1.0.0a2.dist-info → labfreed-1.0.0a3.dist-info}/licenses/LICENSE +0 -0
labfreed/__init__.py
CHANGED
|
@@ -144,8 +144,9 @@ class AttributeClient():
|
|
|
144
144
|
|
|
145
145
|
|
|
146
146
|
# update cache
|
|
147
|
+
attribute_groups_out = []
|
|
147
148
|
for ag_for_pac in r.pac_attributes:
|
|
148
|
-
|
|
149
|
+
pac_from_response = PAC_ID.from_url(ag_for_pac.pac_id)
|
|
149
150
|
ags = [
|
|
150
151
|
CacheableAttributeGroup(
|
|
151
152
|
key= ag.key,
|
|
@@ -156,13 +157,15 @@ class AttributeClient():
|
|
|
156
157
|
state_of=ag.state_of)
|
|
157
158
|
for ag in ag_for_pac.attribute_groups
|
|
158
159
|
]
|
|
159
|
-
self.cache_store.update(server_url,
|
|
160
|
+
self.cache_store.update(server_url, pac_from_response, ags)
|
|
160
161
|
|
|
161
|
-
|
|
162
|
+
# compare pac_id from response with pac_id we need attributes for.
|
|
163
|
+
# if identical this is the part of the response we care about. other PAC-ID are just for the cache
|
|
164
|
+
if pac_id.to_url() == pac_from_response.to_url():
|
|
162
165
|
attribute_groups_out = ags
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
+
|
|
167
|
+
return attribute_groups_out
|
|
168
|
+
|
|
166
169
|
|
|
167
170
|
|
|
168
171
|
|
|
@@ -10,6 +10,7 @@ from cachetools import TTLCache, cached
|
|
|
10
10
|
from labfreed.pac_attributes.api_data_models.response import AttributeGroup
|
|
11
11
|
from labfreed.pac_attributes.pythonic.py_attributes import pyAttribute, pyAttributes
|
|
12
12
|
from labfreed.pac_attributes.server.server import AttributeGroupDataSource
|
|
13
|
+
from labfreed.pac_cat.pac_cat import PAC_CAT
|
|
13
14
|
|
|
14
15
|
try:
|
|
15
16
|
from openpyxl import load_workbook
|
|
@@ -74,8 +75,9 @@ class _BaseExcelAttributeDataSource(AttributeGroupDataSource):
|
|
|
74
75
|
Subclasses implement `_read_rows_and_last_changed()`.
|
|
75
76
|
"""
|
|
76
77
|
|
|
77
|
-
def __init__(self, *, base_url: str = "", cache_duration_seconds: int = 0, **kwargs):
|
|
78
|
+
def __init__(self, *, base_url: str = "", cache_duration_seconds: int = 0, uses_pac_cat_short_form:bool=True, **kwargs):
|
|
78
79
|
self._base_url = base_url
|
|
80
|
+
self._uses_pac_cat_short_form = uses_pac_cat_short_form
|
|
79
81
|
# allow instance-level TTL override
|
|
80
82
|
try:
|
|
81
83
|
_cache.ttl = int(cache_duration_seconds)
|
|
@@ -96,9 +98,14 @@ class _BaseExcelAttributeDataSource(AttributeGroupDataSource):
|
|
|
96
98
|
return []
|
|
97
99
|
return [self._base_url + r for r in rows[0][1:]]
|
|
98
100
|
|
|
99
|
-
def attributes(self, pac_url:
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
def attributes(self, pac_url:str) -> Optional[AttributeGroup]:
|
|
102
|
+
try:
|
|
103
|
+
p = PAC_CAT.from_url(pac_url)
|
|
104
|
+
pac_url = p.to_url(use_short_notation=self._uses_pac_cat_short_form, include_extensions=self._include_extensions)
|
|
105
|
+
print(f'Lookup in Excel of {pac_url}')
|
|
106
|
+
except:
|
|
107
|
+
... # might as well try to match the original input
|
|
108
|
+
|
|
102
109
|
rows, last_changed = self._read_rows_and_last_changed()
|
|
103
110
|
d = _get_row_by_first_cell(rows, pac_url, self._base_url)
|
|
104
111
|
if not d:
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod, abstractproperty
|
|
2
2
|
from datetime import datetime, timezone
|
|
3
3
|
from labfreed.pac_attributes.api_data_models.response import VALID_FOREVER, AttributeBase, AttributeGroup
|
|
4
|
+
from labfreed.pac_cat.pac_cat import PAC_CAT
|
|
5
|
+
from labfreed.pac_id.pac_id import PAC_ID
|
|
4
6
|
|
|
5
7
|
|
|
6
8
|
class AttributeGroupDataSource(ABC):
|
|
@@ -29,12 +31,13 @@ class AttributeGroupDataSource(ABC):
|
|
|
29
31
|
|
|
30
32
|
|
|
31
33
|
class Dict_DataSource(AttributeGroupDataSource):
|
|
32
|
-
def __init__(self, data:dict[str, list[AttributeBase]], *args, **kwargs):
|
|
34
|
+
def __init__(self, data:dict[str, list[AttributeBase]], uses_pac_cat_short_form=True, *args, **kwargs):
|
|
33
35
|
if not all([isinstance(e, list) for e in data.values()]):
|
|
34
36
|
raise ValueError('Invalid data')
|
|
35
37
|
|
|
36
38
|
self._data = data
|
|
37
39
|
self._state_of = datetime.now(tz=timezone.utc)
|
|
40
|
+
self.uses_pac_cat_short_form = uses_pac_cat_short_form
|
|
38
41
|
|
|
39
42
|
super().__init__(*args, **kwargs)
|
|
40
43
|
|
|
@@ -45,9 +48,12 @@ class Dict_DataSource(AttributeGroupDataSource):
|
|
|
45
48
|
|
|
46
49
|
|
|
47
50
|
def attributes(self, pac_url: str) -> AttributeGroup:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
try:
|
|
52
|
+
p = PAC_CAT.from_url(pac_url)
|
|
53
|
+
pac_url = p.to_url(use_short_notation=self.uses_pac_cat_short_form, include_extensions=self._include_extensions)
|
|
54
|
+
except:
|
|
55
|
+
... # might as well try to match the original input
|
|
56
|
+
|
|
51
57
|
attributes = self._data.get(pac_url)
|
|
52
58
|
if not attributes:
|
|
53
59
|
return None
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
labfreed/__init__.py,sha256=
|
|
1
|
+
labfreed/__init__.py,sha256=feEsSamwMYNQXaiqTt0oe0dEoLnkS-SJ5-YIdMtkerE,338
|
|
2
2
|
labfreed/labfreed_infrastructure.py,sha256=YZmU-kgopyB1tvpTR_k_uIt1Q2ezexMrWvu-HaP65IE,10104
|
|
3
3
|
labfreed/labfreed_extended/app/app_infrastructure.py,sha256=1VMc_Vtjwof9hwzSG95KuIUjT1h7uNsWf_lTORYFFuQ,3981
|
|
4
4
|
labfreed/labfreed_extended/app/formatted_print.py,sha256=DcwWP0ix1e_wYNIdceIp6cETkJdG2DqpU8Gs3aZAL40,1930
|
|
@@ -10,13 +10,13 @@ labfreed/pac_attributes/api_data_models/response.py,sha256=4VliJuKM_r-J-xaLEqfcd
|
|
|
10
10
|
labfreed/pac_attributes/api_data_models/server_capabilities_response.py,sha256=ypDm4f8xZZl036fp8PuIe6lJHNW5Zg1fItgUlnV75V0,178
|
|
11
11
|
labfreed/pac_attributes/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
labfreed/pac_attributes/client/attribute_cache.py,sha256=eWFy7h-T6gd25ENj9pLvSadNFRrzzIineqBoov2cGyw,2688
|
|
13
|
-
labfreed/pac_attributes/client/client.py,sha256=
|
|
13
|
+
labfreed/pac_attributes/client/client.py,sha256=J606oYqcJ98NI0w1bSoahys5t7Wxy4CXjJVGUXyj2Zs,7347
|
|
14
14
|
labfreed/pac_attributes/pythonic/attribute_server_factory.py,sha256=_wasafjBlwvzOaM6-uPgqPethsDQHEpaXoiRW7w9aV0,5759
|
|
15
|
-
labfreed/pac_attributes/pythonic/excel_attribute_data_source.py,sha256=
|
|
15
|
+
labfreed/pac_attributes/pythonic/excel_attribute_data_source.py,sha256=Mvn-uIMWZjQJfSOMVY244yCKpnYeR4btc9Pe4BL8_4M,7313
|
|
16
16
|
labfreed/pac_attributes/pythonic/py_attributes.py,sha256=LoPSH5DWdPTKq-3d2CT-7tTfkqYN9s53sNEeSq_6fHg,5615
|
|
17
17
|
labfreed/pac_attributes/pythonic/py_dict_data_source.py,sha256=nAz6GA7Xx_0IORPPpt_Wl3sFJa1Q5Fnq5vdf1uQiJF8,531
|
|
18
18
|
labfreed/pac_attributes/server/__init__.py,sha256=JvQ2kpQx62OUwP18bGhOWYU9an_nQW59Y8Lh7HyfVxY,301
|
|
19
|
-
labfreed/pac_attributes/server/attribute_data_sources.py,sha256=
|
|
19
|
+
labfreed/pac_attributes/server/attribute_data_sources.py,sha256=gfaERhFrn3SIoSNRiVzchuxpt2ttoe3gw0-fMmv12hU,2448
|
|
20
20
|
labfreed/pac_attributes/server/server.py,sha256=_Rzi_vzX02o0g03lbm-fdg5AJHJnESDWD7cJEKRFs8w,8841
|
|
21
21
|
labfreed/pac_attributes/server/translation_data_sources.py,sha256=axALOqfP840sOSdVCRYtrens97mm-hpfONMUyuVlCrY,2145
|
|
22
22
|
labfreed/pac_cat/__init__.py,sha256=KNPtQzBD1XVohvG_ucOs7RJj-oi6biUTGB1k-T2o6pk,568
|
|
@@ -59,7 +59,7 @@ labfreed/well_known_keys/labfreed/well_known_keys.py,sha256=p-hXwEEIs7p2SKn9DQeL
|
|
|
59
59
|
labfreed/well_known_keys/unece/UneceUnits.json,sha256=kwfQSp_nTuWbADfBBgqTWrvPl6XtM5SedEVLbMJrM7M,898953
|
|
60
60
|
labfreed/well_known_keys/unece/__init__.py,sha256=MSP9lmjg9_D9iqG9Yq2_ajYfQSNS9wIT7FXA1c--59M,122
|
|
61
61
|
labfreed/well_known_keys/unece/unece_units.py,sha256=J20d64H69qKDE3XlGdJoXIIh0G-d0jKoiIDsg9an5pk,1655
|
|
62
|
-
labfreed-1.0.
|
|
63
|
-
labfreed-1.0.
|
|
64
|
-
labfreed-1.0.
|
|
65
|
-
labfreed-1.0.
|
|
62
|
+
labfreed-1.0.0a3.dist-info/licenses/LICENSE,sha256=gHFOv9FRKHxO8cInP3YXyPoJnuNeqrvcHjaE_wPSsQ8,1100
|
|
63
|
+
labfreed-1.0.0a3.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
64
|
+
labfreed-1.0.0a3.dist-info/METADATA,sha256=y5M4I537vHyGZcYkVCEuFrOi4uMVLp74Yz21tne3WQM,19740
|
|
65
|
+
labfreed-1.0.0a3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|