openepd 6.26.0__py3-none-any.whl → 6.28.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/common.py +23 -0
- openepd/model/epd.py +1 -0
- openepd/model/org.py +26 -2
- {openepd-6.26.0.dist-info → openepd-6.28.0.dist-info}/METADATA +1 -1
- {openepd-6.26.0.dist-info → openepd-6.28.0.dist-info}/RECORD +9 -9
- {openepd-6.26.0.dist-info → openepd-6.28.0.dist-info}/LICENSE +0 -0
- {openepd-6.26.0.dist-info → openepd-6.28.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/common.py
CHANGED
@@ -13,13 +13,24 @@
|
|
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 Callable, Generator
|
16
17
|
from enum import StrEnum
|
18
|
+
import re
|
17
19
|
from typing import Annotated, Any
|
18
20
|
|
19
21
|
from openepd.compat.pydantic import pyd
|
20
22
|
from openepd.model.base import BaseOpenEpdSchema
|
21
23
|
from openepd.model.validation.numbers import RatioFloat
|
22
24
|
|
25
|
+
DATA_URL_REGEX = r"^data:([-\w]+\/[-+\w.]+)?(;?\w+=[-\w]+)*(;base64)?,.*$"
|
26
|
+
"""
|
27
|
+
Regular expression pattern for matching Data URLs.
|
28
|
+
|
29
|
+
A Data URL is a URI scheme that allows you to embed small data items inline
|
30
|
+
in web pages as if they were external resources.
|
31
|
+
The pattern matches the following format: data:[<media-type>][;base64],<data>
|
32
|
+
"""
|
33
|
+
|
23
34
|
|
24
35
|
class Amount(BaseOpenEpdSchema):
|
25
36
|
"""A value-and-unit pairing for amounts that do not have an uncertainty."""
|
@@ -313,3 +324,15 @@ class EnumGroupingAware:
|
|
313
324
|
def get_groupings(cls) -> list[list]:
|
314
325
|
"""Return logical groupings of the values."""
|
315
326
|
return []
|
327
|
+
|
328
|
+
|
329
|
+
class DataUrl(str):
|
330
|
+
@classmethod
|
331
|
+
def __get_validators__(cls) -> Generator[Callable[[str], str], None, None]:
|
332
|
+
def validator(v: str) -> str:
|
333
|
+
if re.compile(DATA_URL_REGEX).match(v):
|
334
|
+
return v
|
335
|
+
msg = "Value must be a valid dataUrl"
|
336
|
+
raise ValueError(msg)
|
337
|
+
|
338
|
+
yield validator
|
openepd/model/epd.py
CHANGED
openepd/model/org.py
CHANGED
@@ -13,15 +13,24 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
|
-
|
16
|
+
import math
|
17
|
+
from typing import Annotated, Final, Optional
|
17
18
|
|
18
19
|
from openlocationcode import openlocationcode
|
19
20
|
|
20
21
|
from openepd.compat.pydantic import pyd
|
21
22
|
from openepd.model.base import BaseOpenEpdSchema
|
22
|
-
from openepd.model.common import Location, WithAltIdsMixin, WithAttachmentsMixin
|
23
|
+
from openepd.model.common import DataUrl, Location, WithAltIdsMixin, WithAttachmentsMixin
|
23
24
|
from openepd.model.validation.common import ReferenceStr
|
24
25
|
|
26
|
+
ORG_LOGO_MAX_LENGTH: Final[int] = math.ceil(32 * 1024 * 4 / 3)
|
27
|
+
"""
|
28
|
+
Maximum length of Org.logo field.
|
29
|
+
|
30
|
+
Logo file size must be less than 32KB. Base64 encoding overhead (approximately 33%) requires
|
31
|
+
limiting the encoded string length to 4/3 of the file size limit.
|
32
|
+
"""
|
33
|
+
|
25
34
|
|
26
35
|
class OrgRef(BaseOpenEpdSchema):
|
27
36
|
"""Represents Organisation with minimal data."""
|
@@ -85,6 +94,21 @@ class Org(WithAttachmentsMixin, WithAltIdsMixin, OrgRef):
|
|
85
94
|
default=None,
|
86
95
|
description="Location of a place of business, preferably the corporate headquarters.",
|
87
96
|
)
|
97
|
+
logo: pyd.AnyUrl | DataUrl | None = pyd.Field(
|
98
|
+
default=None,
|
99
|
+
description=(
|
100
|
+
"URL pointer to, or dataURL, for a square logo for the company, preferably 300x300 pixels."
|
101
|
+
"A logo of the type used on social media platforms such as LinkedIn is recommended."
|
102
|
+
),
|
103
|
+
example="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
|
104
|
+
)
|
105
|
+
|
106
|
+
@pyd.validator("logo")
|
107
|
+
def validate_logo(cls, v: str | None) -> str | None:
|
108
|
+
if v and len(v) > ORG_LOGO_MAX_LENGTH:
|
109
|
+
msg = f"Logo URL must not exceed {ORG_LOGO_MAX_LENGTH} characters"
|
110
|
+
raise ValueError(msg)
|
111
|
+
return v
|
88
112
|
|
89
113
|
|
90
114
|
class PlantRef(BaseOpenEpdSchema):
|
@@ -1,5 +1,5 @@
|
|
1
1
|
openepd/__init__.py,sha256=fhxfEyEurLvSfvQci-vb3njzl_lvhcLXiZrecCOaMU8,794
|
2
|
-
openepd/__version__.py,sha256=
|
2
|
+
openepd/__version__.py,sha256=IUCrF_atrQRdHN3rso9BDfVu8IPQGot8f1SiPEB8L9Y,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
|
@@ -46,15 +46,15 @@ openepd/m49/utils.py,sha256=vQl0wMXtYS2b7NeLIWilDNUopq3MATmLnhEFcMYTeZA,7256
|
|
46
46
|
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
|
-
openepd/model/common.py,sha256=
|
49
|
+
openepd/model/common.py,sha256=WM6ankkeZazVzKwbn4s5FHwENMTIKWsgdRJkX7DYmpg,13875
|
50
50
|
openepd/model/declaration.py,sha256=1WXTRlSRIUXTJJhL_e7BkoFyZ9gJKZH7c8pFVxihGFU,13980
|
51
|
-
openepd/model/epd.py,sha256=
|
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
|
55
55
|
openepd/model/industry_epd.py,sha256=QZr7OhgGkzqZ8H5p6dCIVk9zSHEYtK3y9Nk-DvkFMyk,4011
|
56
56
|
openepd/model/lcia.py,sha256=PdaSZz02PMBJl_t2B_dmkcbzIFjA7iACrWj1fllHfw0,26230
|
57
|
-
openepd/model/org.py,sha256=
|
57
|
+
openepd/model/org.py,sha256=zxBt-c2f1nhJUqygUzhsq6AEEwfNiYGquhgYvcUfvSo,7771
|
58
58
|
openepd/model/pcr.py,sha256=7nf6ATofdrlPt81vdU6p0E8n_ftFEuCEIKxtYlFwclw,5476
|
59
59
|
openepd/model/specs/README.md,sha256=UGhSiFJ9hOxT1mZl-5ZrhkOrPKf1W_gcu5CI9hzV7LU,2430
|
60
60
|
openepd/model/specs/__init__.py,sha256=toVWd8_jxmAf7gRwpoXQpLfZW6Cl-NwveoduMXhECms,3903
|
@@ -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.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,,
|
File without changes
|
File without changes
|