labfreed 0.3.1a5__tar.gz → 0.3.1a6__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.
Potentially problematic release.
This version of labfreed might be problematic. Click here for more details.
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/PKG-INFO +1 -1
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/__init__.py +1 -1
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/labfreed_extended/app/app_infrastructure.py +5 -14
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/labfreed_extended/app/pac_info.py +29 -6
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/client/client.py +4 -2
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/pythonic/attribute_server_factory.py +2 -2
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/pythonic/py_attributes.py +12 -3
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_id_resolver/resolver.py +2 -2
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/.github/workflows/pypi-publish.yml +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/.github/workflows/run-tests.yml +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/CHANGELOG.md +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/LICENSE +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/README.md +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/labfreed_extended/app/formatted_print.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/labfreed_infrastructure.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/__init__.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/api_data_models/request.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/api_data_models/response.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/api_data_models/server_capabilities_response.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/client/__init__.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/client/attribute_cache.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/pythonic/excel_attribute_data_source.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/pythonic/py_dict_data_source.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/server/__init__.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/server/attribute_data_sources.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/server/server.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/server/translation_data_sources.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/well_knonw_attribute_keys.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_cat/__init__.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_cat/category_base.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_cat/pac_cat.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_cat/predefined_categories.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_id/__init__.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_id/extension.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_id/id_segment.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_id/pac_id.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_id/url_parser.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_id/url_serializer.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_id_resolver/__init__.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_id_resolver/cit_common.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_id_resolver/cit_v1.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_id_resolver/cit_v2.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_id_resolver/services.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/qr/__init__.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/qr/generate_qr.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/trex/__init__.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/trex/pythonic/__init__.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/trex/pythonic/data_table.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/trex/pythonic/pyTREX.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/trex/pythonic/quantity.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/trex/table_segment.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/trex/trex.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/trex/trex_base_models.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/trex/value_segments.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/utilities/base36.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/utilities/ensure_utc_time.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/utilities/translations.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/well_known_extensions/__init__.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/well_known_extensions/default_extension_interpreters.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/well_known_extensions/display_name_extension.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/well_known_extensions/trex_extension.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/well_known_keys/gs1/__init__.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/well_known_keys/gs1/gs1_ai_enum_sorted.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/well_known_keys/labfreed/well_known_keys.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/well_known_keys/unece/UneceUnits.json +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/well_known_keys/unece/__init__.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/well_known_keys/unece/unece_units.py +0 -0
- {labfreed-0.3.1a5 → labfreed-0.3.1a6}/pyproject.toml +0 -0
|
@@ -6,6 +6,7 @@ import requests
|
|
|
6
6
|
from labfreed.labfreed_extended.app.pac_info import PacInfo
|
|
7
7
|
from labfreed.pac_attributes.client.attribute_cache import MemoryAttributeCache
|
|
8
8
|
from labfreed.pac_attributes.client.client import AttributeClient, attribute_request_default_callback_factory
|
|
9
|
+
from labfreed.pac_attributes.pythonic.py_attributes import pyAttributeGroup
|
|
9
10
|
from labfreed.pac_attributes.well_knonw_attribute_keys import MetaAttributeKeys
|
|
10
11
|
from labfreed.well_known_extensions.display_name_extension import DisplayNameExtension
|
|
11
12
|
|
|
@@ -63,25 +64,15 @@ class Labfreed_App_Infrastructure():
|
|
|
63
64
|
pac_info.user_handovers = sg_user_handovers
|
|
64
65
|
|
|
65
66
|
# Attributes
|
|
66
|
-
attribute_groups =
|
|
67
|
+
attribute_groups = {}
|
|
67
68
|
for sg in service_groups:
|
|
68
69
|
attributes_urls = [s.url for s in sg.services if s.service_type == 'attributes-generic']
|
|
69
70
|
for url in attributes_urls:
|
|
70
|
-
ags = self._attribute_client.get_attributes(url, pac_id=pac.to_url(include_extensions=False), language_preferences=self._language_preferences)
|
|
71
|
+
ags = {ag.key: pyAttributeGroup.from_attribute_group(ag) for ag in self._attribute_client.get_attributes(url, pac_id=pac.to_url(include_extensions=False), language_preferences=self._language_preferences)}
|
|
71
72
|
if ags:
|
|
72
|
-
attribute_groups.
|
|
73
|
+
attribute_groups.update(ags)
|
|
73
74
|
pac_info.attributes = attribute_groups
|
|
74
|
-
|
|
75
|
-
if dn := pac.get_extension('N'):
|
|
76
|
-
dn = DisplayNameExtension.from_extension(dn)
|
|
77
|
-
pac_info.display_name = dn.display_name or ""
|
|
78
|
-
# there can be a display name in attributes, too
|
|
79
|
-
if meta := [ag for ag in pac_info.attributes if ag.key == MetaAttributeKeys.GROUPKEY.value]:
|
|
80
|
-
dn_attr = [a for a in meta[0].attributes if a.key == MetaAttributeKeys.DISPLAYNAME.value]
|
|
81
|
-
if dn_attr:
|
|
82
|
-
dn = dn_attr[0].value
|
|
83
|
-
pac_info.display_name += f' ( aka {dn} )'
|
|
84
|
-
|
|
75
|
+
|
|
85
76
|
return pac_info
|
|
86
77
|
|
|
87
78
|
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
from pydantic import BaseModel, Field
|
|
4
|
-
from labfreed.pac_attributes.pythonic.py_attributes import pyAttribute, pyAttributes
|
|
4
|
+
from labfreed.pac_attributes.pythonic.py_attributes import pyAttribute, pyAttributeGroup, pyAttributes
|
|
5
|
+
from labfreed.pac_attributes.well_knonw_attribute_keys import MetaAttributeKeys
|
|
5
6
|
from labfreed.pac_cat.pac_cat import PAC_CAT
|
|
6
7
|
from labfreed.pac_id.pac_id import PAC_ID
|
|
7
8
|
from labfreed.pac_id_resolver.services import ServiceGroup
|
|
8
9
|
from labfreed.labfreed_extended.app.formatted_print import StringIOLineBreak
|
|
10
|
+
from labfreed.well_known_extensions.display_name_extension import DisplayNameExtension
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
class PacInfo(BaseModel):
|
|
12
14
|
"""A convenient collection of information about a PAC-ID"""
|
|
13
15
|
pac_id:PAC_ID
|
|
14
|
-
display_name:str|None = None
|
|
15
16
|
user_handovers: list[ServiceGroup] = Field(default_factory=list)
|
|
16
|
-
attributes:
|
|
17
|
+
attributes:dict[str, pyAttributeGroup] = Field(default_factory=dict)
|
|
17
18
|
|
|
18
19
|
@property
|
|
19
20
|
def pac_url(self):
|
|
@@ -34,6 +35,29 @@ class PacInfo(BaseModel):
|
|
|
34
35
|
def summary(self):
|
|
35
36
|
return self.pac_id.get_extension('SUM')
|
|
36
37
|
|
|
38
|
+
@property
|
|
39
|
+
def image_url(self) -> str:
|
|
40
|
+
if meta := self.attributes.get(MetaAttributeKeys.GROUPKEY.value):
|
|
41
|
+
image_attr = meta.attributes.get(MetaAttributeKeys.IMAGE.value)
|
|
42
|
+
return image_attr.value
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def display_name(self) -> str|None:
|
|
47
|
+
display_name = None
|
|
48
|
+
pac = self.pac_id
|
|
49
|
+
if dn := pac.get_extension('N'):
|
|
50
|
+
dn = DisplayNameExtension.from_extension(dn)
|
|
51
|
+
display_name = dn.display_name or ""
|
|
52
|
+
# there can be a display name in attributes, too
|
|
53
|
+
if meta := self.attributes.get(MetaAttributeKeys.GROUPKEY.value):
|
|
54
|
+
dn_attr = meta.attributes.get(MetaAttributeKeys.DISPLAYNAME.value)
|
|
55
|
+
if dn_attr:
|
|
56
|
+
dn = dn_attr.value
|
|
57
|
+
display_name += f' ( aka {dn} )'
|
|
58
|
+
return display_name
|
|
59
|
+
|
|
60
|
+
|
|
37
61
|
|
|
38
62
|
|
|
39
63
|
def format_for_print(self, markup:str='rich') -> str:
|
|
@@ -62,10 +86,9 @@ class PacInfo(BaseModel):
|
|
|
62
86
|
|
|
63
87
|
|
|
64
88
|
printout.title1("Attributes")
|
|
65
|
-
for ag in self.attributes:
|
|
89
|
+
for ag in self.attributes.values():
|
|
66
90
|
printout.title2(f'{ag.label} (from {ag.origin})')
|
|
67
|
-
|
|
68
|
-
for k, v in attributes.items():
|
|
91
|
+
for v in ag.attributes.values():
|
|
69
92
|
v:pyAttribute
|
|
70
93
|
#print(f'{k}: ({v.label}) :: {v.value} ')
|
|
71
94
|
printout.key_value(v.label, v.value)
|
|
@@ -49,7 +49,7 @@ def attribute_request_default_callback_factory(session: requests.Session = None)
|
|
|
49
49
|
|
|
50
50
|
def callback(url: str, attribute_request_body: str) -> tuple[int, str]:
|
|
51
51
|
try:
|
|
52
|
-
resp = session.post(url, data=attribute_request_body, headers={'Content-Type': 'application/json'})
|
|
52
|
+
resp = session.post(url, data=attribute_request_body, headers={'Content-Type': 'application/json'}, timeout=10)
|
|
53
53
|
return resp.status_code, resp.text
|
|
54
54
|
except requests.exceptions.RequestException as e:
|
|
55
55
|
return 500, str(e)
|
|
@@ -140,7 +140,9 @@ class AttributeClient():
|
|
|
140
140
|
|
|
141
141
|
if pac_id == pac:
|
|
142
142
|
attribute_groups_out = ags
|
|
143
|
-
|
|
143
|
+
return attribute_groups_out
|
|
144
|
+
else:
|
|
145
|
+
return []
|
|
144
146
|
|
|
145
147
|
|
|
146
148
|
|
{labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/pythonic/attribute_server_factory.py
RENAMED
|
@@ -68,7 +68,7 @@ class AttributeFlaskApp(Flask):
|
|
|
68
68
|
) -> Blueprint:
|
|
69
69
|
bp = Blueprint("attribute", __name__)
|
|
70
70
|
|
|
71
|
-
@bp.route("/", methods=["POST"])
|
|
71
|
+
@bp.route("/", methods=["POST"], strict_slashes=False)
|
|
72
72
|
def handle_attribute_request():
|
|
73
73
|
if authenticator and not authenticator(request):
|
|
74
74
|
return Response(
|
|
@@ -86,7 +86,7 @@ class AttributeFlaskApp(Flask):
|
|
|
86
86
|
return "The request was valid, but the server encountered an error", 500
|
|
87
87
|
return response_body
|
|
88
88
|
|
|
89
|
-
@bp.route("/capabilities", methods=["GET"])
|
|
89
|
+
@bp.route("/capabilities", methods=["GET"], strict_slashes=False)
|
|
90
90
|
def capabilities():
|
|
91
91
|
return request_handler.capabilities()
|
|
92
92
|
|
|
@@ -6,7 +6,8 @@ import warnings
|
|
|
6
6
|
from pydantic import RootModel
|
|
7
7
|
|
|
8
8
|
from labfreed.labfreed_infrastructure import LabFREED_BaseModel
|
|
9
|
-
from labfreed.pac_attributes.api_data_models.response import AttributeBase, BoolAttribute, DateTimeAttribute, NumericAttribute, NumericValue, ObjectAttribute, ReferenceAttribute, TextAttribute
|
|
9
|
+
from labfreed.pac_attributes.api_data_models.response import AttributeBase, AttributeGroup, BoolAttribute, DateTimeAttribute, NumericAttribute, NumericValue, ObjectAttribute, ReferenceAttribute, TextAttribute
|
|
10
|
+
from labfreed.pac_attributes.client.attribute_cache import CacheableAttributeGroup
|
|
10
11
|
from labfreed.pac_id.pac_id import PAC_ID
|
|
11
12
|
from labfreed.trex.pythonic.quantity import Quantity
|
|
12
13
|
|
|
@@ -87,7 +88,7 @@ class pyAttributes(RootModel[list[pyAttribute]]):
|
|
|
87
88
|
|
|
88
89
|
@staticmethod
|
|
89
90
|
def from_payload_attributes(attributes:list[AttributeBase]) -> 'pyAttributes':
|
|
90
|
-
out =
|
|
91
|
+
out = list()
|
|
91
92
|
for a in attributes:
|
|
92
93
|
match a:
|
|
93
94
|
|
|
@@ -117,8 +118,16 @@ class pyAttributes(RootModel[list[pyAttribute]]):
|
|
|
117
118
|
# valid_until=datetime(**_parse_date_time_str(a.valid_until)),
|
|
118
119
|
# observed_at=datetime(**_parse_date_time_str(a.value))
|
|
119
120
|
)
|
|
120
|
-
out.
|
|
121
|
+
out.append(attr )
|
|
121
122
|
return out
|
|
122
123
|
|
|
123
124
|
|
|
124
125
|
|
|
126
|
+
class pyAttributeGroup(CacheableAttributeGroup):
|
|
127
|
+
attributes:dict[str,pyAttribute]
|
|
128
|
+
|
|
129
|
+
@staticmethod
|
|
130
|
+
def from_attribute_group(attribute_group:AttributeGroup):
|
|
131
|
+
data = vars(attribute_group).copy()
|
|
132
|
+
data["attributes"] = {a.key: a for a in pyAttributes.from_payload_attributes(attribute_group.attributes)}
|
|
133
|
+
return pyAttributeGroup(**data)
|
|
@@ -67,10 +67,10 @@ class PAC_ID_Resolver():
|
|
|
67
67
|
def resolve(self, pac_id:PAC_ID|str, check_service_status=True, use_issuer_cit=True) -> list[ServiceGroup]:
|
|
68
68
|
'''Resolve a PAC-ID'''
|
|
69
69
|
if isinstance(pac_id, str):
|
|
70
|
-
pac_id = PAC_CAT.from_url(pac_id)
|
|
71
70
|
pac_id_catless = PAC_ID.from_url(pac_id, try_pac_cat=False)
|
|
71
|
+
pac_id = PAC_CAT.from_url(pac_id)
|
|
72
72
|
|
|
73
|
-
# it's likely to
|
|
73
|
+
# it's likely to
|
|
74
74
|
if isinstance(pac_id, PAC_ID):
|
|
75
75
|
pac_id_catless = PAC_ID.from_url(pac_id.to_url(), try_pac_cat=False)
|
|
76
76
|
else:
|
|
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.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/pythonic/py_dict_data_source.py
RENAMED
|
File without changes
|
|
File without changes
|
{labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/server/attribute_data_sources.py
RENAMED
|
File without changes
|
|
File without changes
|
{labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/pac_attributes/server/translation_data_sources.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
|
|
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
|
|
File without changes
|
|
File without changes
|
{labfreed-0.3.1a5 → labfreed-0.3.1a6}/labfreed/well_known_extensions/display_name_extension.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
|
|
File without changes
|