labfreed 1.0.0a17__py3-none-any.whl → 1.0.0a18__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 CHANGED
@@ -2,7 +2,7 @@
2
2
  Python implementation of LabFREED building blocks
3
3
  '''
4
4
 
5
- __version__ = "1.0.0a17"
5
+ __version__ = "1.0.0a18"
6
6
 
7
7
  from labfreed.pac_id import * # noqa: F403
8
8
  from labfreed.pac_cat import * # noqa: F403
@@ -44,7 +44,7 @@ class Labfreed_App_Infrastructure():
44
44
  self._resolver._resolver_configs.discard(resolver_config)
45
45
 
46
46
 
47
- def process_pac(self, pac_url, markup=None):
47
+ def process_pac(self, pac_url) -> PacInfo:
48
48
  if not isinstance(pac_url, PAC_ID):
49
49
  pac = PAC_ID.from_url(pac_url)
50
50
  else:
@@ -38,7 +38,7 @@ class DateTimeAttribute(AttributeBase):
38
38
  type: Literal["datetime"]
39
39
  value: datetime
40
40
 
41
- @field_validator('value', mode='before')
41
+ @field_validator('value', mode='after')
42
42
  def set_utc__if_naive(cls, value):
43
43
  if isinstance(value, datetime):
44
44
  return ensure_utc(value)
@@ -49,14 +49,15 @@ class DateTimeListAttribute(AttributeBase):
49
49
  type: Literal["datetime-list"]
50
50
  value: list[datetime]
51
51
 
52
- @field_validator('value', mode='before')
52
+ @field_validator('value', mode='after')
53
53
  def set_utc__if_naive(cls, value):
54
54
  value_out = []
55
55
  for v in value:
56
56
  if isinstance(v, datetime):
57
57
  value_out.append(ensure_utc(v))
58
58
  else:
59
- return ValueError(f'{v} is of type {type(v)}. It must be datetime')
59
+ raise ValueError(f'{v} is of type {type(v)}. It must be datetime')
60
+ return value_out
60
61
 
61
62
 
62
63
 
@@ -51,7 +51,7 @@ def http_attribute_request_default_callback_factory(session: requests.Session =
51
51
 
52
52
  def callback(url: str, attribute_request_body: str) -> tuple[int, str]:
53
53
  try:
54
- resp = session.post(url, data=attribute_request_body, headers={'Content-Type': 'application/json'}, timeout=10)
54
+ resp = session.post(url, data=attribute_request_body, headers={'Content-Type': 'application/json; ; charset=utf-8'}, timeout=10)
55
55
  return resp.status_code, resp.text
56
56
  except requests.exceptions.RequestException as e:
57
57
  return 500, str(e)
@@ -86,7 +86,7 @@ class AttributeFlaskApp(Flask):
86
86
  except Exception as e:
87
87
  print(e)
88
88
  return "The request was valid, but the server encountered an error", 500
89
- return (response_body, 200, {"Content-Type": "application/json"})
89
+ return (response_body, 200, {"Content-Type": "application/json; charset=utf-8"})
90
90
 
91
91
  @bp.route("/", methods=["GET"], strict_slashes=False)
92
92
  def capabilities():
@@ -6,7 +6,7 @@ import warnings
6
6
  from pydantic import RootModel, field_validator
7
7
 
8
8
  from labfreed.labfreed_infrastructure import LabFREED_BaseModel
9
- from labfreed.pac_attributes.api_data_models.response import AttributeBase, AttributeGroup, BoolAttribute, BoolListAttribute, DateTimeAttribute, DateTimeListAttribute, NumericAttribute, NumericListAttribute, NumericValue, ObjectAttribute, ReferenceAttribute, ReferenceListAttribute, ResourceAttribute, ResourceListAttribute, TextAttribute, TextListAttribute
9
+ from labfreed.pac_attributes.api_data_models.response import AttributeBase, AttributeGroup, BoolAttribute, BoolListAttribute, DateTimeAttribute, DateTimeListAttribute, NumericAttribute, NumericListAttribute, NumericValue, ObjectAttribute,ObjectListAttribute, ReferenceAttribute, ReferenceListAttribute, ResourceAttribute, ResourceListAttribute, TextAttribute, TextListAttribute
10
10
  from labfreed.pac_attributes.client.attribute_cache import CacheableAttributeGroup
11
11
  from labfreed.pac_id.pac_id import PAC_ID
12
12
  from labfreed.trex.pythonic.quantity import Quantity
@@ -141,7 +141,10 @@ class pyAttributes(RootModel[list[pyAttribute]]):
141
141
  else: #this covers the last resort case of arbitrary objects. Must be json serializable.
142
142
  try :
143
143
  values = [json.loads(json.dumps(v)) for v in value_list]
144
- return ObjectAttribute(value=values, **common_args)
144
+ if len(values) == 1:
145
+ return ObjectAttribute(value=values[0], **common_args)
146
+ else:
147
+ return ObjectListAttribute(value=values, **common_args)
145
148
  except TypeError as e: # noqa: F841
146
149
  raise ValueError(f'Invalid Type: {type(first_value)} cannot be converted to attribute. You may want to use ObjectAttribute, but would have to implement the conversion from your python type yourself.')
147
150
 
@@ -162,16 +165,16 @@ class pyAttributes(RootModel[list[pyAttribute]]):
162
165
  case NumericAttribute() | NumericListAttribute():
163
166
  values = [ Quantity.from_str_value(value=v.numerical_value, unit=v.unit) for v in value_list]
164
167
 
165
- case BoolAttribute() | BoolAttribute():
168
+ case BoolAttribute() | BoolListAttribute():
166
169
  values = value_list
167
170
 
168
171
  case TextAttribute() | TextListAttribute():
169
172
  values = value_list
170
173
 
171
- case DateTimeAttribute() | DateTimeAttribute():
174
+ case DateTimeAttribute() | DateTimeListAttribute():
172
175
  values = value_list
173
176
 
174
- case ObjectAttribute() | ObjectAttribute():
177
+ case ObjectAttribute() | ObjectListAttribute():
175
178
  values = value_list
176
179
 
177
180
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: labfreed
3
- Version: 1.0.0a17
3
+ Version: 1.0.0a18
4
4
  Summary: Python implementation of LabFREED building blocks
5
5
  Author-email: Reto Thürer <thuerer.r@buchi.com>
6
6
  Requires-Python: >=3.11
@@ -1,6 +1,6 @@
1
- labfreed/__init__.py,sha256=sobB_PG2qoDQWufbzxqtQjolcmyFZBRPKqk3tCd5gb0,339
1
+ labfreed/__init__.py,sha256=o7OHFa2ahWFKs04v_mdkRZvcJYtKnxywhiyK3pKLkgA,339
2
2
  labfreed/labfreed_infrastructure.py,sha256=ss1PyJl-7Es-lEcxptmdYI9kDAHmh7HB_tAGkPC6UVs,10173
3
- labfreed/labfreed_extended/app/app_infrastructure.py,sha256=yfxPBDPatxHPrIPmpzdhQB7Yd3lIxGsm8ZXUM04N8nQ,4583
3
+ labfreed/labfreed_extended/app/app_infrastructure.py,sha256=z3pxqYPgH8MFZJB2pR2mblpB7VrawQbXWJmz2nrZ6ZA,4581
4
4
  labfreed/labfreed_extended/app/formatted_print.py,sha256=DcwWP0ix1e_wYNIdceIp6cETkJdG2DqpU8Gs3aZAL40,1930
5
5
  labfreed/labfreed_extended/app/pac_info/pac_info.py,sha256=9Wre1wAmMZObeh7Ed46KA38nBWcXhqGD0m9vTHfkkS8,8397
6
6
  labfreed/labfreed_extended/app/pac_info/html_renderer/external-link.svg,sha256=H5z9s4VvHq09UnHdqfrYNsx-Whljc0gE4qKJ6-3kfgQ,1158
@@ -11,14 +11,14 @@ labfreed/labfreed_extended/app/pac_info/html_renderer/pac_info_card.jinja.html,s
11
11
  labfreed/pac_attributes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  labfreed/pac_attributes/well_knonw_attribute_keys.py,sha256=axE81MeJ3G_Wy1PbmNAXH6SfPtl96NXvQJMyrvK10t4,324
13
13
  labfreed/pac_attributes/api_data_models/request.py,sha256=N-kXlJWYqh-F1TzNunCwHUPhme3bSLJMgb9aAHWGOy4,1880
14
- labfreed/pac_attributes/api_data_models/response.py,sha256=tdiWHgB8q10S4i2G6urNli6yNE1EMyP620_pdLKeTYM,8496
14
+ labfreed/pac_attributes/api_data_models/response.py,sha256=-oiRn_NifnnQ464NlDDPhp_SrU1ZIK9p7fhXCNI0iSY,8519
15
15
  labfreed/pac_attributes/api_data_models/server_capabilities_response.py,sha256=ypDm4f8xZZl036fp8PuIe6lJHNW5Zg1fItgUlnV75V0,178
16
16
  labfreed/pac_attributes/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  labfreed/pac_attributes/client/attribute_cache.py,sha256=ThUadWqQ5oM8DnAnvZuY4jeA3Mg06ePNEcRP5wCsadc,2222
18
- labfreed/pac_attributes/client/client.py,sha256=FjvyEpZEGYrZkuaQoqH9QFstrwHmrsIdaymxz8uQjwQ,7510
19
- labfreed/pac_attributes/pythonic/attribute_server_factory.py,sha256=3OeFjBdlMR4DMIzHVo5-A_y935e2_lOqvFCLKgxjsEY,6159
18
+ labfreed/pac_attributes/client/client.py,sha256=AgOrk4tnn5txO50LCmJlhniazxkfeH8U-8yytGB58AM,7527
19
+ labfreed/pac_attributes/pythonic/attribute_server_factory.py,sha256=t3ARmsXdbdQ0QAgRkdHT_ScmpZhXzz3lZkN0WovzygQ,6174
20
20
  labfreed/pac_attributes/pythonic/excel_attribute_data_source.py,sha256=wHvw6oGdGT_IxdC7MbHmtQKb5jDPJggQ1UvvFPAEpHo,8349
21
- labfreed/pac_attributes/pythonic/py_attributes.py,sha256=vjRNjg-PpsQSaidpPtkiyQL_10dcD-9JAz89gAYMFJA,8307
21
+ labfreed/pac_attributes/pythonic/py_attributes.py,sha256=omC17WRvqouUYXp1i-hMQ8g9UUDMXjXUQvP6KPIMzMI,8484
22
22
  labfreed/pac_attributes/pythonic/py_dict_data_source.py,sha256=nAz6GA7Xx_0IORPPpt_Wl3sFJa1Q5Fnq5vdf1uQiJF8,531
23
23
  labfreed/pac_attributes/server/__init__.py,sha256=JvQ2kpQx62OUwP18bGhOWYU9an_nQW59Y8Lh7HyfVxY,301
24
24
  labfreed/pac_attributes/server/attribute_data_sources.py,sha256=7-YQeBcn5ndsZWeeW_-YgG7obF5qvXoH-AFPpmXWn1I,2337
@@ -65,7 +65,7 @@ labfreed/well_known_keys/labfreed/well_known_keys.py,sha256=p-hXwEEIs7p2SKn9DQeL
65
65
  labfreed/well_known_keys/unece/UneceUnits.json,sha256=kwfQSp_nTuWbADfBBgqTWrvPl6XtM5SedEVLbMJrM7M,898953
66
66
  labfreed/well_known_keys/unece/__init__.py,sha256=MSP9lmjg9_D9iqG9Yq2_ajYfQSNS9wIT7FXA1c--59M,122
67
67
  labfreed/well_known_keys/unece/unece_units.py,sha256=J20d64H69qKDE3XlGdJoXIIh0G-d0jKoiIDsg9an5pk,1655
68
- labfreed-1.0.0a17.dist-info/licenses/LICENSE,sha256=gHFOv9FRKHxO8cInP3YXyPoJnuNeqrvcHjaE_wPSsQ8,1100
69
- labfreed-1.0.0a17.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
70
- labfreed-1.0.0a17.dist-info/METADATA,sha256=Jar31mke8Tfi0VLd8eijEh-HM3FRqp55qgYwTk-BOKE,19775
71
- labfreed-1.0.0a17.dist-info/RECORD,,
68
+ labfreed-1.0.0a18.dist-info/licenses/LICENSE,sha256=gHFOv9FRKHxO8cInP3YXyPoJnuNeqrvcHjaE_wPSsQ8,1100
69
+ labfreed-1.0.0a18.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
70
+ labfreed-1.0.0a18.dist-info/METADATA,sha256=38cmc9zGdqbVvzJ-xzd_WzAqPxr8tyknB-ti5fPUBV0,19775
71
+ labfreed-1.0.0a18.dist-info/RECORD,,