openepd 6.27.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 +1 -1
- openepd/api/epd/sync_api.py +6 -3
- openepd/model/declaration.py +24 -5
- openepd/model/epd.py +1 -0
- {openepd-6.27.0.dist-info → openepd-6.29.0.dist-info}/METADATA +1 -1
- {openepd-6.27.0.dist-info → openepd-6.29.0.dist-info}/RECORD +8 -8
- {openepd-6.27.0.dist-info → openepd-6.29.0.dist-info}/LICENSE +0 -0
- {openepd-6.27.0.dist-info → openepd-6.29.0.dist-info}/WHEEL +0 -0
openepd/__version__.py
CHANGED
openepd/api/epd/sync_api.py
CHANGED
@@ -13,6 +13,7 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
|
+
from collections.abc import Collection
|
16
17
|
from typing import Literal, overload
|
17
18
|
|
18
19
|
from requests import Response
|
@@ -27,15 +28,17 @@ from openepd.model.epd import Epd
|
|
27
28
|
class EpdApi(BaseApiMethodGroup):
|
28
29
|
"""API methods for EPDs."""
|
29
30
|
|
30
|
-
def get_by_openxpd_uuid(self, uuid: str) -> Epd:
|
31
|
+
def get_by_openxpd_uuid(self, uuid: str, *, fields: Collection[str] | None = None) -> Epd:
|
31
32
|
"""
|
32
33
|
Get EPD by OpenEPD UUID.
|
33
34
|
|
34
35
|
:param uuid: OpenEPD UUID
|
35
|
-
:
|
36
|
+
:param fields: Optional collection of field names to include in the response
|
37
|
+
:return: EPD, Response, or tuple of EPD and Response depending on return_type
|
36
38
|
:raise ObjectNotFound: if EPD is not found
|
37
39
|
"""
|
38
|
-
|
40
|
+
params = {"fields": ",".join(set(fields))} if fields else None
|
41
|
+
content = self._client.do_request("get", f"/epds/{uuid}", params=params).json()
|
39
42
|
return Epd.parse_obj(content)
|
40
43
|
|
41
44
|
def find_raw(self, omf: str, page_num: int = 1, page_size: int = 10) -> EpdSearchResponse:
|
openepd/model/declaration.py
CHANGED
@@ -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="
|
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="
|
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)."""
|
openepd/model/epd.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
openepd/__init__.py,sha256=fhxfEyEurLvSfvQci-vb3njzl_lvhcLXiZrecCOaMU8,794
|
2
|
-
openepd/__version__.py,sha256=
|
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
|
@@ -17,7 +17,7 @@ openepd/api/dto/mf.py,sha256=59YvIrH5teHlpxINihxryFyCjs7jBZZuqYIO1K-daA8,1994
|
|
17
17
|
openepd/api/dto/params.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9Dvvtd4,620
|
18
18
|
openepd/api/epd/__init__.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9Dvvtd4,620
|
19
19
|
openepd/api/epd/dto.py,sha256=MqhHjaNdtOc-KT2zNI88EB9-1d2a6CS2zzSus8HefBo,4874
|
20
|
-
openepd/api/epd/sync_api.py,sha256=
|
20
|
+
openepd/api/epd/sync_api.py,sha256=WD0Hq15oiEPyrE1uW8ta30sUjPcy7LMcPeo6uYfnilQ,7659
|
21
21
|
openepd/api/errors.py,sha256=BgZeNfMNAKVPfhpuiVapCXNBSsXygAOWql-gy7m9j7E,2868
|
22
22
|
openepd/api/org/__init__.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9Dvvtd4,620
|
23
23
|
openepd/api/org/sync_api.py,sha256=VzOrd3eB1xPVLyrKlZl3OwXIQ5nT3808sA6N7MNBu7w,3167
|
@@ -47,8 +47,8 @@ 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=
|
51
|
-
openepd/model/epd.py,sha256=
|
50
|
+
openepd/model/declaration.py,sha256=F7LEMeZSJndtvO0AqnvTS43MeRxI3MO1IWLyF1SlwPU,14744
|
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
|
54
54
|
openepd/model/geography.py,sha256=Jx7NIDdk_sIvwyh-7YxnIjAwIHW2HCQK7UtFGM2xKtw,42095
|
@@ -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.
|
160
|
-
openepd-6.
|
161
|
-
openepd-6.
|
162
|
-
openepd-6.
|
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,,
|
File without changes
|
File without changes
|