openepd 6.28.0__py3-none-any.whl → 6.29.0__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 = "6.28.0"
16
+ VERSION = "6.29.0"
@@ -16,10 +16,12 @@
16
16
  import abc
17
17
  import datetime
18
18
  from enum import StrEnum
19
+ import math
20
+ from typing import Final
19
21
 
20
22
  from openepd.compat.pydantic import pyd
21
23
  from openepd.model.base import BaseOpenEpdSchema, OpenXpdUUID, RootDocument
22
- from openepd.model.common import Amount
24
+ from openepd.model.common import Amount, DataUrl
23
25
  from openepd.model.geography import Geography
24
26
  from openepd.model.org import Org
25
27
  from openepd.model.pcr import Pcr
@@ -32,6 +34,14 @@ DEVELOPER_DESCRIPTION = "The organization responsible for the underlying LCA (an
32
34
  PROGRAM_OPERATOR_DESCRIPTION = "JSON object for program operator Org"
33
35
  THIRD_PARTY_VERIFIER_DESCRIPTION = "JSON object for Org that performed a critical review of the EPD data"
34
36
 
37
+ PRODUCT_IMAGE_MAX_LENGTH: Final[int] = math.ceil(32 * 1024 * 4 / 3)
38
+ """
39
+ Maximum length for product_image, product_image_small fields.
40
+
41
+ Image file size must be less than 32KB. Base64 encoding overhead (approximately 33%) requires
42
+ limiting the encoded string length to 4/3 of the file size limit.
43
+ """
44
+
35
45
 
36
46
  class BaseDeclaration(RootDocument, abc.ABC):
37
47
  """Base class for declaration-related documents (EPDs, Industry-wide EPDs, Generic Estimates)."""
@@ -128,11 +138,13 @@ class BaseDeclaration(RootDocument, abc.ABC):
128
138
  """,
129
139
  )
130
140
 
131
- product_image_small: pyd.AnyUrl | None = pyd.Field(
132
- description="Pointer to image illustrating the product, which is no more than 200x200 pixels", default=None
141
+ product_image_small: pyd.AnyUrl | DataUrl | None = pyd.Field(
142
+ description="URL referencing an image illustrating the product. May be a dataURL of up to 32kb. 200x200 or smaller.",
143
+ default=None,
133
144
  )
134
- product_image: pyd.AnyUrl | pyd.FileUrl | None = pyd.Field(
135
- description="pointer to image illustrating the product no more than 10MB", default=None
145
+ product_image: pyd.AnyUrl | pyd.FileUrl | DataUrl | None = pyd.Field(
146
+ description="URL referencing an image illustrating the product, of no more than 10MB. May be a dataURL of up to 32KB.",
147
+ default=None,
136
148
  )
137
149
  declaration_url: str | None = pyd.Field(
138
150
  description="Link to data object on original registrar's site",
@@ -161,6 +173,13 @@ class BaseDeclaration(RootDocument, abc.ABC):
161
173
  example=50.0,
162
174
  )
163
175
 
176
+ @pyd.validator("product_image", "product_image_small")
177
+ def validate_product_image(cls, v: str | None) -> str | None:
178
+ if v and len(v) > PRODUCT_IMAGE_MAX_LENGTH:
179
+ msg = f"URL must not exceed {PRODUCT_IMAGE_MAX_LENGTH} characters"
180
+ raise ValueError(msg)
181
+ return v
182
+
164
183
 
165
184
  class AverageDatasetMixin(pyd.BaseModel, title="Average Dataset"):
166
185
  """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: 6.28.0
3
+ Version: 6.29.0
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=fhxfEyEurLvSfvQci-vb3njzl_lvhcLXiZrecCOaMU8,794
2
- openepd/__version__.py,sha256=IUCrF_atrQRdHN3rso9BDfVu8IPQGot8f1SiPEB8L9Y,639
2
+ openepd/__version__.py,sha256=f1EqCXZyrdckHTfegrNJZFywP0vyKz9n0lRUc01uG7Q,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=_eZt_jGVL1a3p9cr-EF39Ve9Vl5sB8zwzTc_slnRL50,7975
@@ -47,7 +47,7 @@ openepd/model/__init__.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9Dvvtd4,620
47
47
  openepd/model/base.py,sha256=6rP6r-7NwKC6JLFB24v2w4Z-_f_w6ZSNLte5zyj5o70,9928
48
48
  openepd/model/category.py,sha256=reeOVRDuZPYU77EMwG0K5VjnK2H9yOGxT0PJXXqrjEk,1639
49
49
  openepd/model/common.py,sha256=WM6ankkeZazVzKwbn4s5FHwENMTIKWsgdRJkX7DYmpg,13875
50
- openepd/model/declaration.py,sha256=1WXTRlSRIUXTJJhL_e7BkoFyZ9gJKZH7c8pFVxihGFU,13980
50
+ openepd/model/declaration.py,sha256=F7LEMeZSJndtvO0AqnvTS43MeRxI3MO1IWLyF1SlwPU,14744
51
51
  openepd/model/epd.py,sha256=SGAgEEAuvRGsIlgIUI60UqV1alhb5kouOvp8fAC0VPg,12320
52
52
  openepd/model/factory.py,sha256=UWSGpfCr3GiMTP4rzBkwqxzbXB6GKZ_5Okb1Dqa_4aA,2701
53
53
  openepd/model/generic_estimate.py,sha256=zLGTyf4Uzmp2C0m-J1ePWItSz2RGdZ0OiGPWC5nhKHk,3992
@@ -156,7 +156,7 @@ openepd/utils/__init__.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9Dvvtd4,620
156
156
  openepd/utils/functional.py,sha256=sm7od2_UE-cNToezBlwFQ1TCUJub1tz6VykA1X8XH-I,1274
157
157
  openepd/utils/mapping/__init__.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9Dvvtd4,620
158
158
  openepd/utils/mapping/common.py,sha256=WphCzwQQlzX11tUk88Ubyq3QPBLvH0tBPSIuH0kmiug,7339
159
- openepd-6.28.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
160
- openepd-6.28.0.dist-info/METADATA,sha256=Csp45UMu54luUAHWZ46DFe4gAYhvLt4m0J0lUikNfaY,9827
161
- openepd-6.28.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
162
- openepd-6.28.0.dist-info/RECORD,,
159
+ openepd-6.29.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
160
+ openepd-6.29.0.dist-info/METADATA,sha256=aG_2eWHAirqdTxeIkvWDcQw_ShvNo6OgvjWq28RUiM0,9827
161
+ openepd-6.29.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
162
+ openepd-6.29.0.dist-info/RECORD,,