labfreed 1.0.0b26__py3-none-any.whl → 1.0.0b28__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/api_data_models/request.py +12 -4
- labfreed/pac_attributes/pythonic/attribute_server_factory.py +5 -3
- labfreed/pac_attributes/pythonic/py_attributes.py +7 -1
- labfreed/pac_id/url_parser.py +1 -1
- {labfreed-1.0.0b26.dist-info → labfreed-1.0.0b28.dist-info}/METADATA +1 -1
- {labfreed-1.0.0b26.dist-info → labfreed-1.0.0b28.dist-info}/RECORD +9 -9
- {labfreed-1.0.0b26.dist-info → labfreed-1.0.0b28.dist-info}/WHEEL +0 -0
- {labfreed-1.0.0b26.dist-info → labfreed-1.0.0b28.dist-info}/licenses/LICENSE +0 -0
labfreed/__init__.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import re
|
|
1
2
|
from typing import Any, Self
|
|
2
3
|
from urllib.parse import unquote
|
|
3
4
|
from werkzeug.datastructures import LanguageAccept
|
|
@@ -27,14 +28,21 @@ class AttributeRequestData(LabFREED_BaseModel):
|
|
|
27
28
|
|
|
28
29
|
@classmethod
|
|
29
30
|
def from_http_request(cls, pac_id:str, params:dict, headers:dict):
|
|
31
|
+
# Azure seems to meddle with double slashes in a path, even if url encoded. This is to rectify this behaviour and add back a second slash if necessary
|
|
32
|
+
pac_id = re.sub('HTTPS:/{1,2}', 'HTTPS://', pac_id, re.IGNORECASE)
|
|
33
|
+
|
|
30
34
|
restrict_to_attribute_groups = params.get(ATTR_GROUPS)
|
|
31
35
|
if restrict_to_attribute_groups == '':
|
|
32
36
|
restrict_to_attribute_groups = None
|
|
33
37
|
if restrict_to_attribute_groups:
|
|
34
38
|
restrict_to_attribute_groups = restrict_to_attribute_groups.split(',')
|
|
35
39
|
|
|
36
|
-
fwd_lkp = params.get(ATTR_GROUPS_FWD_LKP,
|
|
37
|
-
|
|
40
|
+
fwd_lkp = params.get(ATTR_GROUPS_FWD_LKP, True)
|
|
41
|
+
if fwd_lkp is True:
|
|
42
|
+
do_forward_lookup = True
|
|
43
|
+
else:
|
|
44
|
+
do_fwd_lookup = fwd_lkp.lower() not in ['false', 'no', '0', 'n', 'off']
|
|
45
|
+
|
|
38
46
|
lang_hdr = headers.get('Accept-Language')
|
|
39
47
|
language_preferences: LanguageAccept = parse_accept_header(lang_hdr, LanguageAccept)
|
|
40
48
|
out = cls(pac_id=pac_id,
|
|
@@ -80,7 +88,7 @@ class AttributeRequestData(LabFREED_BaseModel):
|
|
|
80
88
|
self._add_validation_message(
|
|
81
89
|
source="pac_id",
|
|
82
90
|
level = ValidationMsgLevel.ERROR,
|
|
83
|
-
msg='{self.pac_id} is not a valid PAC-ID'
|
|
91
|
+
msg=f'{self.pac_id} is not a valid PAC-ID'
|
|
84
92
|
)
|
|
85
93
|
|
|
86
94
|
if not self.is_valid:
|
|
@@ -91,7 +99,7 @@ class AttributeRequestData(LabFREED_BaseModel):
|
|
|
91
99
|
def language_preference_http_header(self) -> dict[str, str]:
|
|
92
100
|
if not self.language_preferences:
|
|
93
101
|
return {}
|
|
94
|
-
headers={'Accept-Language': LanguageAccept(
|
|
102
|
+
headers={'Accept-Language': LanguageAccept(self.language_preferences).to_header()}
|
|
95
103
|
return headers
|
|
96
104
|
|
|
97
105
|
def request_params(self) -> dict[str, Any]:
|
|
@@ -4,7 +4,7 @@ import logging
|
|
|
4
4
|
from typing import Any, Protocol
|
|
5
5
|
from urllib.parse import unquote, unquote_plus
|
|
6
6
|
|
|
7
|
-
from flask import Blueprint, current_app, redirect, url_for
|
|
7
|
+
from flask import Blueprint, current_app, redirect, url_for, send_from_directory
|
|
8
8
|
from labfreed.pac_attributes.api_data_models.request import AttributeRequestData
|
|
9
9
|
from labfreed.pac_attributes.server.server import AttributeGroupDataSource, AttributeServerRequestHandler, InvalidRequestError, TranslationDataSource
|
|
10
10
|
|
|
@@ -76,8 +76,6 @@ class AttributeFlaskApp(Flask):
|
|
|
76
76
|
|
|
77
77
|
@bp.get("/<path:pac_id_url_encoded>", strict_slashes=False)
|
|
78
78
|
def handle_attribute_request(pac_id_url_encoded):
|
|
79
|
-
if pac_id_url_encoded in ['favicon.ico']:
|
|
80
|
-
return ''
|
|
81
79
|
|
|
82
80
|
if authenticator and not authenticator(request):
|
|
83
81
|
return Response(
|
|
@@ -155,6 +153,10 @@ class AttributeFlaskApp(Flask):
|
|
|
155
153
|
'''
|
|
156
154
|
|
|
157
155
|
return response
|
|
156
|
+
|
|
157
|
+
@bp.get("/favicon.<ext>", strict_slashes=False)
|
|
158
|
+
def favicon(ext):
|
|
159
|
+
return send_from_directory("static", f"favicon.{ext}")
|
|
158
160
|
|
|
159
161
|
return bp
|
|
160
162
|
|
|
@@ -5,6 +5,7 @@ import logging
|
|
|
5
5
|
from typing import Literal
|
|
6
6
|
from enum import Enum
|
|
7
7
|
import warnings
|
|
8
|
+
from deprecated import deprecated
|
|
8
9
|
from pydantic import RootModel, field_validator, model_validator
|
|
9
10
|
|
|
10
11
|
from labfreed.labfreed_infrastructure import LabFREED_BaseModel
|
|
@@ -44,6 +45,11 @@ class pyAttribute(LabFREED_BaseModel):
|
|
|
44
45
|
'''helper function to more conveniently iterate over value elements, even if it's scalar'''
|
|
45
46
|
return self.values if isinstance(self.values, list) else [self.values]
|
|
46
47
|
|
|
48
|
+
@property
|
|
49
|
+
@deprecated
|
|
50
|
+
def value(self):
|
|
51
|
+
return self.values
|
|
52
|
+
|
|
47
53
|
@model_validator(mode='before')
|
|
48
54
|
def value_to_values(cls, d:dict):
|
|
49
55
|
value =d.pop('value', None)
|
|
@@ -85,7 +91,7 @@ class pyAttributes(RootModel[list[pyAttribute]]):
|
|
|
85
91
|
items.append(BoolAttributeItemsElement(value=value))
|
|
86
92
|
|
|
87
93
|
elif isinstance(value, datetime | date | time):
|
|
88
|
-
if not value.tzinfo:
|
|
94
|
+
if getattr(value, 'tzinfo', None) and not value.tzinfo:
|
|
89
95
|
warnings.warn(f'No timezone given for {value}. Assuming it is in UTC.')
|
|
90
96
|
value.replace(tzinfo=UTC)
|
|
91
97
|
items.append(DateTimeAttributeItemsElement(value=value))
|
labfreed/pac_id/url_parser.py
CHANGED
|
@@ -82,7 +82,7 @@ class PAC_Parser():
|
|
|
82
82
|
@classmethod
|
|
83
83
|
def _parse_pac_id(cls,id_str:str) -> "PAC_ID":
|
|
84
84
|
# m = re.match('(HTTPS://)?(PAC.)?(?P<issuer>.+?\..+?)/(?P<identifier>.*)', id_str)
|
|
85
|
-
m = re.match('(HTTPS://)?(PAC
|
|
85
|
+
m = re.match('(HTTPS://)?(PAC\.)?(?P<issuer>.+?)/(?P<identifier>.*)', id_str, re.IGNORECASE)
|
|
86
86
|
if not m:
|
|
87
87
|
raise LabFREED_ValidationError(f'{id_str} does not match the pattern expected for PAC-ID')
|
|
88
88
|
d = m.groupdict()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
labfreed/__init__.py,sha256=
|
|
1
|
+
labfreed/__init__.py,sha256=6dNDBc-c9yS4FwmyZWmNsoq8OyAU4tz3HR2lTYcrhQs,339
|
|
2
2
|
labfreed/labfreed_infrastructure.py,sha256=ss1PyJl-7Es-lEcxptmdYI9kDAHmh7HB_tAGkPC6UVs,10173
|
|
3
3
|
labfreed/labfreed_extended/app/app_infrastructure.py,sha256=1867Nq40c8Q4bFyRv48vTIFDXoPeZTfYij9PSog6fkE,4427
|
|
4
4
|
labfreed/labfreed_extended/app/formatted_print.py,sha256=DcwWP0ix1e_wYNIdceIp6cETkJdG2DqpU8Gs3aZAL40,1930
|
|
@@ -36,14 +36,14 @@ labfreed/labfreed_extended/pac_issuer_lib/templates/pac_info/card.jinja.html,sha
|
|
|
36
36
|
labfreed/labfreed_extended/pac_issuer_lib/templates/pac_info/pac_info.jinja.html,sha256=xK0yM_ovRE8QS6N7hiXhGv-ya8C-s19YWhhMqJKYxFM,1518
|
|
37
37
|
labfreed/pac_attributes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
38
|
labfreed/pac_attributes/well_knonw_attribute_keys.py,sha256=Z_QcQdbIil_EMpFqQcBnivEGMDauyoCMW8r62-EN2KM,547
|
|
39
|
-
labfreed/pac_attributes/api_data_models/request.py,sha256=
|
|
39
|
+
labfreed/pac_attributes/api_data_models/request.py,sha256=DhCGuwfRypq5fitZKS9Bvj8AFfCKaakKc-m6IMKj-3s,4410
|
|
40
40
|
labfreed/pac_attributes/api_data_models/response.py,sha256=Hglfcvb7gC7uZrLsGfPewC290vp4qq4WsuM9S3UHQFI,8188
|
|
41
41
|
labfreed/pac_attributes/api_data_models/server_capabilities_response.py,sha256=ypDm4f8xZZl036fp8PuIe6lJHNW5Zg1fItgUlnV75V0,178
|
|
42
42
|
labfreed/pac_attributes/client/client.py,sha256=5d-G-1tHOx2PXW7KP366tWr4k4F1ykGHX9e-bauF6_w,7149
|
|
43
43
|
labfreed/pac_attributes/client/client_attribute_group.py,sha256=lZXbMU_Yp7Q1iKc5WRqS6pzEz_mtwZaQ5fYZqJA6784,375
|
|
44
|
-
labfreed/pac_attributes/pythonic/attribute_server_factory.py,sha256=
|
|
44
|
+
labfreed/pac_attributes/pythonic/attribute_server_factory.py,sha256=VYyVfhTpNQlLtpMBGWcpnoQHIqehr3K44rdUT9dQepE,7774
|
|
45
45
|
labfreed/pac_attributes/pythonic/excel_attribute_data_source.py,sha256=IBBGpHgt-HiZeB6dsLcjtqUPP2JdViLz2QMIDMjzmME,8467
|
|
46
|
-
labfreed/pac_attributes/pythonic/py_attributes.py,sha256=
|
|
46
|
+
labfreed/pac_attributes/pythonic/py_attributes.py,sha256=9ATeMia7PXZjRrpDouC5siDZ-dbDa6EPhyl7xCEDIG8,7552
|
|
47
47
|
labfreed/pac_attributes/pythonic/py_dict_data_source.py,sha256=nAz6GA7Xx_0IORPPpt_Wl3sFJa1Q5Fnq5vdf1uQiJF8,531
|
|
48
48
|
labfreed/pac_attributes/server/__init__.py,sha256=JvQ2kpQx62OUwP18bGhOWYU9an_nQW59Y8Lh7HyfVxY,301
|
|
49
49
|
labfreed/pac_attributes/server/attribute_data_sources.py,sha256=92BiQ2QC00PSXeeb6XI0KNcD7ZF7bdOSZZcOrOwPr_o,2406
|
|
@@ -57,7 +57,7 @@ labfreed/pac_id/__init__.py,sha256=NGMbzkwQ4txKeT5pxdIZordwHO8J3_q84jzPanjKoHg,6
|
|
|
57
57
|
labfreed/pac_id/extension.py,sha256=4_cQ-N3x8bRxboqC44Qnf6rGnYXvsvHOnlBaY7-Hf-8,2264
|
|
58
58
|
labfreed/pac_id/id_segment.py,sha256=r5JU1SJuRXhZJJxy5T3xjrb598wIDTLpivSJhIUAzjQ,4526
|
|
59
59
|
labfreed/pac_id/pac_id.py,sha256=DDcSYJ8DBWqIoW_usOT7eDjHZ9700cTYxeUgenHluOA,5378
|
|
60
|
-
labfreed/pac_id/url_parser.py,sha256=
|
|
60
|
+
labfreed/pac_id/url_parser.py,sha256=mGtC7gjqmaX-rXekoLCVniZMbWJj0c_8DEUYMnbNhwA,5980
|
|
61
61
|
labfreed/pac_id/url_serializer.py,sha256=01LB30pNMBtv2rYHsiE_4Ga2iVA515Boj4ikOIYhiBQ,3511
|
|
62
62
|
labfreed/pac_id_resolver/__init__.py,sha256=RNBlrDOSR42gmSNH9wJVhK_xwEX45cvTKVgWW2bjh7Q,113
|
|
63
63
|
labfreed/pac_id_resolver/cit_v1.py,sha256=JGlEH2d9awEu3HxPW7vu0uj4ZC3B02IdmFg7aJ4axQw,9833
|
|
@@ -90,7 +90,7 @@ labfreed/well_known_keys/labfreed/well_known_keys.py,sha256=p-hXwEEIs7p2SKn9DQeL
|
|
|
90
90
|
labfreed/well_known_keys/unece/UneceUnits.json,sha256=kwfQSp_nTuWbADfBBgqTWrvPl6XtM5SedEVLbMJrM7M,898953
|
|
91
91
|
labfreed/well_known_keys/unece/__init__.py,sha256=MSP9lmjg9_D9iqG9Yq2_ajYfQSNS9wIT7FXA1c--59M,122
|
|
92
92
|
labfreed/well_known_keys/unece/unece_units.py,sha256=J20d64H69qKDE3XlGdJoXIIh0G-d0jKoiIDsg9an5pk,1655
|
|
93
|
-
labfreed-1.0.
|
|
94
|
-
labfreed-1.0.
|
|
95
|
-
labfreed-1.0.
|
|
96
|
-
labfreed-1.0.
|
|
93
|
+
labfreed-1.0.0b28.dist-info/licenses/LICENSE,sha256=gHFOv9FRKHxO8cInP3YXyPoJnuNeqrvcHjaE_wPSsQ8,1100
|
|
94
|
+
labfreed-1.0.0b28.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
95
|
+
labfreed-1.0.0b28.dist-info/METADATA,sha256=xn7Zie9NrWA3Zd1E__IiOsd8-mdnwy2u_IlUbAeTbaE,19858
|
|
96
|
+
labfreed-1.0.0b28.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|