openepd 4.8.0__py3-none-any.whl → 4.9.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 = "4.8.0"
16
+ VERSION = "4.9.0"
@@ -16,12 +16,13 @@
16
16
  from enum import StrEnum
17
17
 
18
18
  from openepd.compat.pydantic import pyd
19
- from openepd.model.base import BaseDocumentFactory, OpenEpdDoctypes
19
+ from openepd.model.base import BaseDocumentFactory, BaseOpenEpdSchema, OpenEpdDoctypes
20
20
  from openepd.model.common import WithAltIdsMixin, WithAttachmentsMixin
21
21
  from openepd.model.declaration import BaseDeclaration
22
22
  from openepd.model.geography import Geography
23
23
  from openepd.model.lcia import WithLciaMixin
24
24
  from openepd.model.org import Org
25
+ from openepd.model.validation.common import ReferenceStr
25
26
  from openepd.model.versioning import OpenEpdVersions, Version
26
27
 
27
28
 
@@ -46,7 +47,28 @@ class LicenseTerms(StrEnum):
46
47
  """
47
48
 
48
49
 
49
- class GenericEstimatePreviewV0(WithAttachmentsMixin, BaseDeclaration, title="Generic Estimate (preview)"):
50
+ class GenericEstimateRef(BaseOpenEpdSchema, title="Generic Estimate (Ref)"):
51
+ """Reference (short) version of Generic Estimate object."""
52
+
53
+ id: str | None = pyd.Field(
54
+ description="The unique ID for this document. To ensure global uniqueness, should be registered at "
55
+ "open-xpd-uuid.cqd.io/register or a coordinating registry.",
56
+ example="1u7zsed8",
57
+ default=None,
58
+ )
59
+
60
+ name: str | None = pyd.Field(max_length=200, description="Name of the generic estimate", default=None)
61
+
62
+ ref: ReferenceStr | None = pyd.Field(
63
+ default=None,
64
+ example="https://openepd.buildingtransparency.org/api/generic_estimates/EC300001",
65
+ description="Reference to this GenericEstimate JSON object",
66
+ )
67
+
68
+
69
+ class GenericEstimatePreviewV0(
70
+ WithAttachmentsMixin, GenericEstimateRef, BaseDeclaration, title="Generic Estimate (preview)"
71
+ ):
50
72
  """
51
73
  Generic Estimate preview, used in API list responses and where there is no need for a full object.
52
74
 
@@ -58,8 +80,6 @@ class GenericEstimatePreviewV0(WithAttachmentsMixin, BaseDeclaration, title="Gen
58
80
  default="openGenericEstimate",
59
81
  )
60
82
 
61
- name: str | None = pyd.Field(max_length=200, description="Name of the generic estimate", default=None)
62
-
63
83
  description: str | None = pyd.Field(
64
84
  max_length=2000,
65
85
  description="1-paragraph description of the Generic Estimate. Supports plain text or github flavored markdown.",
openepd/model/lcia.py CHANGED
@@ -195,7 +195,34 @@ class ScopeSet(BaseOpenEpdSchema):
195
195
  )
196
196
 
197
197
 
198
- class ImpactSet(BaseOpenEpdSchema):
198
+ class ScopesetByNameBase(BaseOpenEpdSchema):
199
+ """Base class for the data structures presented as typed name:scopeset mapping ."""
200
+
201
+ def get_scopeset_names(self) -> list[str]:
202
+ """
203
+ Get the names of scopesets which have been set by model (not defaults).
204
+
205
+ :return: set of names, for example ['gwp', 'odp]
206
+ """
207
+ return [self.__fields__[f].alias or f for f in self.__fields_set__]
208
+
209
+ def get_scopeset_by_name(self, name: str) -> ScopeSet | None:
210
+ """
211
+ Get scopeset by name.
212
+
213
+ :param name: The name of the scopeset.
214
+ :return: A scopeset if found, None otherwise
215
+ """
216
+ for f_name, f in self.__fields__.items():
217
+ if f.alias == name:
218
+ return getattr(self, f_name)
219
+ if f_name == name:
220
+ return getattr(self, f_name)
221
+
222
+ return None
223
+
224
+
225
+ class ImpactSet(ScopesetByNameBase):
199
226
  """A set of impacts, such as GWP, ODP, AP, EP, POCP, EP-marine, EP-terrestrial, EP-freshwater, etc."""
200
227
 
201
228
  gwp: ScopeSet | None = pyd.Field(
@@ -345,7 +372,7 @@ class Impacts(pyd.BaseModel):
345
372
  return self.__root__
346
373
 
347
374
 
348
- class ResourceUseSet(BaseOpenEpdSchema):
375
+ class ResourceUseSet(ScopesetByNameBase):
349
376
  """A set of resource use indicators, such as RPRec, RPRm, etc."""
350
377
 
351
378
  RPRec: ScopeSet | None = pyd.Field(
@@ -418,7 +445,7 @@ class ResourceUseSet(BaseOpenEpdSchema):
418
445
  )
419
446
 
420
447
 
421
- class OutputFlowSet(BaseOpenEpdSchema):
448
+ class OutputFlowSet(ScopesetByNameBase):
422
449
  """A set of output flows, such as waste, emissions, etc."""
423
450
 
424
451
  twd: ScopeSet | None = pyd.Field(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openepd
3
- Version: 4.8.0
3
+ Version: 4.9.0
4
4
  Summary: Python library to work with OpenEPD format
5
5
  Home-page: https://github.com/cchangelabs/openepd
6
6
  License: Apache-2.0
@@ -1,5 +1,5 @@
1
1
  openepd/__init__.py,sha256=Shkfh0Kun0YRhmRDw7LkUj2eQL3X-HnP55u2THOEALw,794
2
- openepd/__version__.py,sha256=lqIyRxgSO7rqieyIF-IlWuLQnc58Z9-7vPOWqBlK4os,638
2
+ openepd/__version__.py,sha256=A3iFx_kUtK0dkVs7itV9wiL0foJSKpYp8kZwKq3fk2I,638
3
3
  openepd/api/__init__.py,sha256=UGmZGEyMnASrYwEBPHuXmVzHiuCUskUsJEPoHTIo-lg,620
4
4
  openepd/api/base_sync_client.py,sha256=jviqtQgsOVdRq5x7_Yh_Tg8zIdWtVTIUqNCgebf6YDg,20925
5
5
  openepd/api/category/__init__.py,sha256=UGmZGEyMnASrYwEBPHuXmVzHiuCUskUsJEPoHTIo-lg,620
@@ -36,9 +36,9 @@ openepd/model/common.py,sha256=aa_bfotPybPoYyzHtwj5E5X1T-fCEyznMfVUWvpUhiM,5460
36
36
  openepd/model/declaration.py,sha256=5mzX24KpsezqBuGFAr-InsgB4FFNqI7HPJeDHQ93ZCI,5322
37
37
  openepd/model/epd.py,sha256=bhmPNWQQ28uhaoxE7sW8_mxyswSCEvGovQ2tH69jzUo,10324
38
38
  openepd/model/factory.py,sha256=StQUH7GNmRqskMnnRYkr_PLCl5X5sSLEPiYZOIQI9eo,2541
39
- openepd/model/generic_estimate.py,sha256=RSpQ4F4uVpwLg7NeymoX-V7c4vw3vbR5O4oObFON62A,4764
39
+ openepd/model/generic_estimate.py,sha256=cAgZDiYjqNaGXKc6fR8o9380zqgQMB38F0YTQJo__Lo,5508
40
40
  openepd/model/geography.py,sha256=OngHXz-Dkg-NrVPIwNPP53xu4-HkQ_fnEfX5fYIVEfA,37417
41
- openepd/model/lcia.py,sha256=Cw4dwEy5Fb13XyYxpqQyGNhkuZNdjsjucAC7L1TAn7I,17560
41
+ openepd/model/lcia.py,sha256=sDZIxyggqHIISCUocgvIEgkmqPLGNSEA3-zUd7TEgsw,18430
42
42
  openepd/model/org.py,sha256=FHcYh2WOOQrCMyzm0Ow-iP79jMTBPcneidjH6NXIklA,3760
43
43
  openepd/model/pcr.py,sha256=SwqLWMj9k_jqIzxz5mh6ttqvtLCspKSpywF5YTBOMsA,5397
44
44
  openepd/model/specs/README.md,sha256=W5LSMpZuW5x36cKS4HRfeFsClsRf8J9yHMMICghdc0s,862
@@ -91,7 +91,7 @@ openepd/model/validation/quantity.py,sha256=kzug0MZ3Ao0zeVzN-aleyxUg5hA_7D5tNOOe
91
91
  openepd/model/versioning.py,sha256=R_zm6rCrgF3vlJQYbpyWhirdS_Oek16cv_mvZmpuE8I,4473
92
92
  openepd/patch_pydantic.py,sha256=xrkzblatmU9HBzukWkp1cPq9ZSuohoz1p0pQqVKSlKs,4122
93
93
  openepd/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
94
- openepd-4.8.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
95
- openepd-4.8.0.dist-info/METADATA,sha256=nPib2wxgzIhOrrjVOQdEUihZ3r2ARyCo17UoY4LUllI,8534
96
- openepd-4.8.0.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
97
- openepd-4.8.0.dist-info/RECORD,,
94
+ openepd-4.9.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
95
+ openepd-4.9.0.dist-info/METADATA,sha256=pgDKp3QMBRUOSfTtKsczMpMjOO7n_OEuFwaOz0LR6JI,8534
96
+ openepd-4.9.0.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
97
+ openepd-4.9.0.dist-info/RECORD,,