openepd 7.10.0__py3-none-any.whl → 7.11.1__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.
openepd/__version__.py CHANGED
@@ -13,4 +13,4 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
- VERSION = "7.10.0"
16
+ VERSION = "7.11.1"
openepd/model/common.py CHANGED
@@ -87,7 +87,7 @@ class Measurement(BaseOpenEpdSchema):
87
87
  """A scientific value with units and uncertainty."""
88
88
 
89
89
  mean: float = pydantic.Field(description="Mean (expected) value of the measurement")
90
- unit: str | None = pydantic.Field(description="Measurement unit")
90
+ unit: str | None = pydantic.Field(description="Measurement unit", default=None)
91
91
  rsd: pydantic.PositiveFloat | None = pydantic.Field(
92
92
  description="Relative standard deviation, i.e. standard_deviation/mean",
93
93
  default=None,
@@ -16,11 +16,14 @@
16
16
  import abc
17
17
  import datetime
18
18
  from enum import StrEnum
19
+ import math
20
+ import re
21
+ from typing import Final
19
22
 
20
23
  import pydantic
21
24
 
22
25
  from openepd.model.base import BaseOpenEpdSchema, OpenXpdUUID, RootDocument
23
- from openepd.model.common import Amount
26
+ from openepd.model.common import DATA_URL_REGEX, Amount
24
27
  from openepd.model.geography import Geography
25
28
  from openepd.model.org import Org
26
29
  from openepd.model.pcr import Pcr
@@ -33,6 +36,14 @@ DEVELOPER_DESCRIPTION = "The organization responsible for the underlying LCA (an
33
36
  PROGRAM_OPERATOR_DESCRIPTION = "JSON object for program operator Org"
34
37
  THIRD_PARTY_VERIFIER_DESCRIPTION = "JSON object for Org that performed a critical review of the EPD data"
35
38
 
39
+ PRODUCT_IMAGE_MAX_LENGTH: Final[int] = math.ceil(32 * 1024 * 4 / 3)
40
+ """
41
+ Maximum length for product_image, product_image_small fields.
42
+
43
+ Image file size must be less than 32KB. Base64 encoding overhead (approximately 33%) requires
44
+ limiting the encoded string length to 4/3 of the file size limit.
45
+ """
46
+
36
47
 
37
48
  class BaseDeclaration(RootDocument, abc.ABC):
38
49
  """Base class for declaration-related documents (EPDs, Industry-wide EPDs, Generic Estimates)."""
@@ -138,11 +149,11 @@ class BaseDeclaration(RootDocument, abc.ABC):
138
149
  )
139
150
 
140
151
  product_image_small: pydantic.AnyUrl | None = pydantic.Field(
141
- description="Pointer to image illustrating the product, which is no more than 200x200 pixels",
152
+ description="URL referencing an image illustrating the product. May be a dataURL of up to 32kb. 200x200 or smaller.",
142
153
  default=None,
143
154
  )
144
155
  product_image: pydantic.AnyUrl | pydantic.FileUrl | None = pydantic.Field(
145
- description="pointer to image illustrating the product no more than 10MB",
156
+ description="URL referencing an image illustrating the product, of no more than 10MB. May be a dataURL of up to 32KB.",
146
157
  default=None,
147
158
  )
148
159
  declaration_url: str | None = pydantic.Field(
@@ -181,6 +192,16 @@ class BaseDeclaration(RootDocument, abc.ABC):
181
192
  return value.strip()
182
193
  return value
183
194
 
195
+ @pydantic.field_validator("product_image", "product_image_small")
196
+ def validate_product_image(cls, v: pydantic.AnyUrl | None) -> pydantic.AnyUrl | None:
197
+ if v and len(v) > PRODUCT_IMAGE_MAX_LENGTH:
198
+ msg = f"URL must not exceed {PRODUCT_IMAGE_MAX_LENGTH} characters"
199
+ raise ValueError(msg)
200
+ if v and v.scheme == "data" and not re.compile(DATA_URL_REGEX).match(str(v)):
201
+ msg = "Invalid data URL format"
202
+ raise ValueError(msg)
203
+ return v
204
+
184
205
 
185
206
  class AverageDatasetMixin(pydantic.BaseModel, title="Average Dataset"):
186
207
  """Fields common for average dataset (Industry-wide EPDs, Generic Estimates)."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: openepd
3
- Version: 7.10.0
3
+ Version: 7.11.1
4
4
  Summary: Python library to work with OpenEPD format
5
5
  License: Apache-2.0
6
6
  Author: C-Change Labs
@@ -1,5 +1,5 @@
1
1
  openepd/__init__.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9Dvvtd4,620
2
- openepd/__version__.py,sha256=A_q9rcTFYq13WDk7bIUKJZzeX5llV-alCEOuzu5ADlg,639
2
+ openepd/__version__.py,sha256=1vquf4mm-jZnqSUJcQPR6JgTjyeY7p1E7jsrt15-KEs,639
3
3
  openepd/api/__init__.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9Dvvtd4,620
4
4
  openepd/api/average_dataset/__init__.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9Dvvtd4,620
5
5
  openepd/api/average_dataset/generic_estimate_sync_api.py,sha256=mjTT8eGtfj6Fgp-wcs0cCWA7DJo1KL_iQ75rgKkaY3c,8037
@@ -43,8 +43,8 @@ openepd/m49/utils.py,sha256=0UvdtC9gtvRA5WT_hJDIuQR0RSrnx-S34wwwBRM_tsM,7807
43
43
  openepd/model/__init__.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9Dvvtd4,620
44
44
  openepd/model/base.py,sha256=4D8BaSoNeY8RZfjkmJOSyfg0B34dKzM76lZbQT9AIXg,13622
45
45
  openepd/model/category.py,sha256=iyzzAsiVwW4zJ61oYsm9Sy-sEBA71-aMFXcJP1Y-dPI,1734
46
- openepd/model/common.py,sha256=a4FFM5moxEyOTAQuf0eZTbWb3vz2deGh37j1nLg3f0k,15002
47
- openepd/model/declaration.py,sha256=n55PqeIsBGT4UGHjGyb92txuoPB_S0eZ3lcmUAuS4NQ,14843
46
+ openepd/model/common.py,sha256=r6VbqOaMAAqEEbXJ0l-_kLDFQJZW_qv5XdZFyOFEFW8,15016
47
+ openepd/model/declaration.py,sha256=ryB0QmbdtufUEwUDZqzudlEAnJ_-4wPR9dwfC8i4zUc,15785
48
48
  openepd/model/epd.py,sha256=cS3ZT_72v0gFcEhuDQrF_Zs8-Cob3FjyipUbBpc-xFM,12760
49
49
  openepd/model/factory.py,sha256=UWSGpfCr3GiMTP4rzBkwqxzbXB6GKZ_5Okb1Dqa_4aA,2701
50
50
  openepd/model/generic_estimate.py,sha256=_R18Uz-hvxtSBl53D0_OkwVCWvoa2nIDjBdec6vEPDE,4304
@@ -154,7 +154,7 @@ openepd/utils/mapping/__init__.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9Dv
154
154
  openepd/utils/mapping/common.py,sha256=hxfN-WW2WLwE_agQzf_mhvz6OHq5WWlr24uZ1S81k4Y,8426
155
155
  openepd/utils/mapping/geography.py,sha256=1_-dvLk11Hqn-K58yUI5pQ5X5gsnJPFlFT7JK2Rdoeg,2396
156
156
  openepd/utils/markdown.py,sha256=RQmudPhb4QU1I4-S-VV2WFbzzq2Po09kbpjjKbwkA9E,1830
157
- openepd-7.10.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
158
- openepd-7.10.0.dist-info/METADATA,sha256=9Pw7b7swT8988umoBB0OJAN2YCxYmzuKRm_2e-aYb-w,9811
159
- openepd-7.10.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
160
- openepd-7.10.0.dist-info/RECORD,,
157
+ openepd-7.11.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
158
+ openepd-7.11.1.dist-info/METADATA,sha256=q52RNUOrhHSCeossTQIOqMjDEeOU-WPcqdkhxxx3hm4,9811
159
+ openepd-7.11.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
160
+ openepd-7.11.1.dist-info/RECORD,,