openepd 6.26.0__py3-none-any.whl → 6.27.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.26.0"
16
+ VERSION = "6.27.0"
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/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
- from typing import Annotated, Optional
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,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: openepd
3
- Version: 6.26.0
3
+ Version: 6.27.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=QKzyjy31-5ATfvNMXjjiW14NUCNwqK2LRcIIk6cIt0s,639
2
+ openepd/__version__.py,sha256=HmKYYpYPt8TvWu0Hh2PXVwOFCv8fcayILaKwQX8TeWk,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
@@ -46,7 +46,7 @@ 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=jblgVf_ASMelxe_-mk6fnOIyM4n0TY4PJ8MeLX8O92c,13134
49
+ openepd/model/common.py,sha256=WM6ankkeZazVzKwbn4s5FHwENMTIKWsgdRJkX7DYmpg,13875
50
50
  openepd/model/declaration.py,sha256=1WXTRlSRIUXTJJhL_e7BkoFyZ9gJKZH7c8pFVxihGFU,13980
51
51
  openepd/model/epd.py,sha256=_1P9-etXfLAVmg44pglnBUvoEyQ50odNBsUrv_OeS9M,12308
52
52
  openepd/model/factory.py,sha256=UWSGpfCr3GiMTP4rzBkwqxzbXB6GKZ_5Okb1Dqa_4aA,2701
@@ -54,7 +54,7 @@ openepd/model/generic_estimate.py,sha256=zLGTyf4Uzmp2C0m-J1ePWItSz2RGdZ0OiGPWC5n
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=AAyXx42phVn3fZN0_Ga8CJb2iKh_dfVXsvO1lEtDovM,6832
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.26.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
160
- openepd-6.26.0.dist-info/METADATA,sha256=jCPbtt_A2IWHV85XvL4yLOyvkxsz9xE4PYOF7KlPSpc,9827
161
- openepd-6.26.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
162
- openepd-6.26.0.dist-info/RECORD,,
159
+ openepd-6.27.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
160
+ openepd-6.27.0.dist-info/METADATA,sha256=1qocBkldct5oXEPyBq3C6KN9M9OErubIul8X68L_M1U,9827
161
+ openepd-6.27.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
162
+ openepd-6.27.0.dist-info/RECORD,,