openepd 7.4.0__py3-none-any.whl → 7.6.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/model/lcia.py +2 -0
- openepd/model/org.py +26 -0
- openepd/utils/__init__.py +15 -0
- openepd/utils/mapping/__init__.py +15 -0
- openepd/utils/mapping/common.py +192 -0
- {openepd-7.4.0.dist-info → openepd-7.6.0.dist-info}/METADATA +1 -1
- {openepd-7.4.0.dist-info → openepd-7.6.0.dist-info}/RECORD +10 -7
- {openepd-7.4.0.dist-info → openepd-7.6.0.dist-info}/LICENSE +0 -0
- {openepd-7.4.0.dist-info → openepd-7.6.0.dist-info}/WHEEL +0 -0
openepd/__version__.py
CHANGED
openepd/model/lcia.py
CHANGED
@@ -512,10 +512,12 @@ class LCIAMethod(StrEnum):
|
|
512
512
|
"""A list of available LCA methods."""
|
513
513
|
|
514
514
|
UNKNOWN = "Unknown LCIA"
|
515
|
+
TRACI_2_2 = "TRACI 2.2"
|
515
516
|
TRACI_2_1 = "TRACI 2.1"
|
516
517
|
TRACI_2_0 = "TRACI 2.0"
|
517
518
|
TRACI_1_0 = "TRACI 1.0"
|
518
519
|
IPCC_AR5 = "IPCC AR5"
|
520
|
+
IPCC_AR6 = "IPCC AR6"
|
519
521
|
EF_3_0 = "EF 3.0"
|
520
522
|
EF_3_1 = "EF 3.1"
|
521
523
|
EF_2_0 = "EF 2.0"
|
openepd/model/org.py
CHANGED
@@ -91,6 +91,32 @@ class Org(WithAttachmentsMixin, WithAltIdsMixin, OrgRef):
|
|
91
91
|
|
92
92
|
return value
|
93
93
|
|
94
|
+
description: str | None = pydantic.Field(
|
95
|
+
default=None,
|
96
|
+
max_length=2000,
|
97
|
+
description=(
|
98
|
+
"Text that describes the company, its products, or its sustainability commitments, "
|
99
|
+
'similar to "about us" or "sustainability commitment" text on a corporate website. '
|
100
|
+
"Typically used for publication in EPDs and for viewing by users. "
|
101
|
+
"Supports plain text or github flavored markdown."
|
102
|
+
),
|
103
|
+
examples=[
|
104
|
+
(
|
105
|
+
"# Our Mission\n"
|
106
|
+
"Driven by the mission to design and make the world's best products in the most sustainable way, "
|
107
|
+
"MillerKnoll's sustainability strategy focuses on three key areas:\n"
|
108
|
+
"* Carbon : Design the lowest carbon footprint products "
|
109
|
+
"and commit to achieving net-zero carbon emissions by 20501.\n"
|
110
|
+
"* Materials : Use sustainable, 100% bio-based or recycled materials by 2050.\n"
|
111
|
+
"* Circularity : Design timeless, durable products with zero waste by 2050.\n"
|
112
|
+
"# Supplier Support\n"
|
113
|
+
"At MillerKnoll, we are committed to working closely with our suppliers "
|
114
|
+
"to reduce our collective impact on the environment. "
|
115
|
+
"We encourage our suppliers to minimize their operations' environmental impacts "
|
116
|
+
"and require they assist us in decreasing our facilities' environmental effects."
|
117
|
+
)
|
118
|
+
],
|
119
|
+
)
|
94
120
|
hq_location: Location | None = pydantic.Field(
|
95
121
|
default=None,
|
96
122
|
description="Location of a place of business, preferably the corporate headquarters.",
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2025 by C Change Labs Inc. www.c-change-labs.com
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2025 by C Change Labs Inc. www.c-change-labs.com
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
@@ -0,0 +1,192 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2025 by C Change Labs Inc. www.c-change-labs.com
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
__all__ = (
|
17
|
+
"BaseDataMapper",
|
18
|
+
"KeyValueMapper",
|
19
|
+
"ReferenceMapper",
|
20
|
+
"RegexMapper",
|
21
|
+
"SimpleDataMapper",
|
22
|
+
)
|
23
|
+
|
24
|
+
import abc
|
25
|
+
from collections.abc import Mapping
|
26
|
+
import re
|
27
|
+
from typing import Generic, TypeAlias, TypeVar, assert_never, cast
|
28
|
+
|
29
|
+
T = TypeVar("T")
|
30
|
+
K = TypeVar("K")
|
31
|
+
|
32
|
+
|
33
|
+
class BaseDataMapper(Generic[T, K], abc.ABC):
|
34
|
+
"""
|
35
|
+
Base class for all data mappers.
|
36
|
+
|
37
|
+
Data mappers are objects used to map some input values to output values of different types.
|
38
|
+
|
39
|
+
Typical use case is mapping between different aliases of impact names with OpenEpd naming conventions.
|
40
|
+
"""
|
41
|
+
|
42
|
+
@abc.abstractmethod
|
43
|
+
def map(self, input_value: T, default_value: K | None, *, raise_if_missing: bool = False) -> K | None:
|
44
|
+
"""
|
45
|
+
Map the input value to the output value.
|
46
|
+
|
47
|
+
:param input_value: The input value to map.
|
48
|
+
:param default_value: The default value to return if there is no mapping for the input value.
|
49
|
+
:param raise_if_missing: Whether to raise an exception if there is no mapping for the input value.
|
50
|
+
|
51
|
+
:raise ValueError: If there is no mapping for the input value and raise_if_missing is True.
|
52
|
+
"""
|
53
|
+
pass
|
54
|
+
|
55
|
+
|
56
|
+
class SimpleDataMapper(BaseDataMapper[T, T], Generic[T]):
|
57
|
+
"""A data mapper that does not change the type of the input value."""
|
58
|
+
|
59
|
+
DATABASE: Mapping[T, T] = {}
|
60
|
+
|
61
|
+
def map(self, input_value: T, default_value: T | None, *, raise_if_missing: bool = False) -> T | None:
|
62
|
+
"""
|
63
|
+
Map the input value to the output value.
|
64
|
+
|
65
|
+
:param input_value: The input value to map.
|
66
|
+
:param default_value: The default value to return if there is no mapping for the input value.
|
67
|
+
:param raise_if_missing: Whether to raise an exception if there is no mapping for the input value.
|
68
|
+
|
69
|
+
:raise ValueError: If there is no mapping for the input value and raise_if_missing is True.
|
70
|
+
"""
|
71
|
+
if raise_if_missing and input_value not in self.DATABASE:
|
72
|
+
msg = f"No mapping for input value: {input_value}"
|
73
|
+
raise ValueError(msg)
|
74
|
+
|
75
|
+
return self.DATABASE.get(input_value, default_value)
|
76
|
+
|
77
|
+
|
78
|
+
class KeyValueMapper(BaseDataMapper[str, T], Generic[T]):
|
79
|
+
"""
|
80
|
+
A data mapper that maps input values to output values using keywords.
|
81
|
+
|
82
|
+
List of values is expected to be a list string object or a list of objects easily castable to string.
|
83
|
+
"""
|
84
|
+
|
85
|
+
KV: Mapping[str, list[T]] = {}
|
86
|
+
|
87
|
+
def map(self, input_value: str, default_value: T | None, *, raise_if_missing: bool = False) -> T | None:
|
88
|
+
"""
|
89
|
+
Map the input value to the output value using keywords.
|
90
|
+
|
91
|
+
:param input_value: The input value to map.
|
92
|
+
:param default_value: The default value to return if there is no mapping for input value.
|
93
|
+
:param raise_if_missing: Whether to raise an exception if there is no mapping for the input value.
|
94
|
+
|
95
|
+
:raise ValueError: If there is no mapping for the input value and raise_if_missing is True.
|
96
|
+
"""
|
97
|
+
for impact_name, keywords in self.KV.items():
|
98
|
+
for keyword in keywords:
|
99
|
+
if str(keyword).strip().lower() in input_value.strip().lower():
|
100
|
+
return cast(T, impact_name)
|
101
|
+
|
102
|
+
if raise_if_missing:
|
103
|
+
msg = f"No mapping for input value: {input_value}"
|
104
|
+
raise ValueError(msg)
|
105
|
+
|
106
|
+
return default_value
|
107
|
+
|
108
|
+
|
109
|
+
class RegexMapper(BaseDataMapper[str, T], Generic[T]):
|
110
|
+
"""A data mapper that maps input values to output values using regex."""
|
111
|
+
|
112
|
+
PATTERNS: dict[str, str] = {}
|
113
|
+
_compiled_patterns: dict[str, re.Pattern]
|
114
|
+
|
115
|
+
def __init__(self) -> None:
|
116
|
+
self._compiled_patterns: dict[str, re.Pattern] = {
|
117
|
+
key: re.compile(pattern, re.IGNORECASE) for key, pattern in self.PATTERNS.items()
|
118
|
+
}
|
119
|
+
|
120
|
+
def map(self, input_value: str, default_value: T | None, *, raise_if_missing: bool = False) -> T | None:
|
121
|
+
"""
|
122
|
+
Map the input value to the output value using regex.
|
123
|
+
|
124
|
+
:param input_value: The input value to map.
|
125
|
+
:param default_value: The default value to return if there is no mapping for an input value.
|
126
|
+
|
127
|
+
:param raise_if_missing: Whether to raise an exception if there is no mapping for the input value.
|
128
|
+
|
129
|
+
:raise ValueError: If there is no mapping for the input value and raise_if_missing is True.
|
130
|
+
"""
|
131
|
+
for impact_name, pattern in self._compiled_patterns.items():
|
132
|
+
if pattern.search(input_value.strip().lower()):
|
133
|
+
return cast(T, impact_name)
|
134
|
+
|
135
|
+
if raise_if_missing:
|
136
|
+
msg = f"No mapping for input value: {input_value}"
|
137
|
+
raise ValueError(msg)
|
138
|
+
|
139
|
+
return default_value
|
140
|
+
|
141
|
+
|
142
|
+
_TRmRules: TypeAlias = str | re.Pattern | list[str | re.Pattern]
|
143
|
+
|
144
|
+
|
145
|
+
class ReferenceMapper(BaseDataMapper[str, _TRmRules]):
|
146
|
+
"""
|
147
|
+
A mapper that maps input values of any form to the expected value format.
|
148
|
+
|
149
|
+
Expected values may be a value or a list of values. Values are expected to be a string object, regular expressions,
|
150
|
+
or objects easily castable to string.
|
151
|
+
"""
|
152
|
+
|
153
|
+
def map(self, input_value: str, default_value: str | None, *, raise_if_missing: bool = False) -> str | None: # type: ignore[override]
|
154
|
+
"""
|
155
|
+
Return specified key as a value if any of the values in the list matches the input value.
|
156
|
+
|
157
|
+
:param input_value: value to be checked against the list of specified rules
|
158
|
+
:param default_value: default value to return if no match is found
|
159
|
+
:param raise_if_missing: whether to raise an exception if no match is found
|
160
|
+
|
161
|
+
:return: mapped value if find any match, else default value
|
162
|
+
|
163
|
+
:raise ValueError: if no match is found and raise_if_missing is True
|
164
|
+
"""
|
165
|
+
for key, value in self.MAPPING.items():
|
166
|
+
if not self._is_applied(input_value, value):
|
167
|
+
continue
|
168
|
+
return key
|
169
|
+
|
170
|
+
if raise_if_missing:
|
171
|
+
msg = f"No mapping for input value: {input_value}"
|
172
|
+
raise ValueError(msg)
|
173
|
+
|
174
|
+
return default_value
|
175
|
+
|
176
|
+
def _is_applied(self, input_value: str, rules: _TRmRules) -> bool:
|
177
|
+
if isinstance(rules, str | re.Pattern):
|
178
|
+
return self._is_applied_to_item(input_value, rules)
|
179
|
+
elif isinstance(rules, list):
|
180
|
+
return any(self._is_applied_to_item(input_value, rule) for rule in rules)
|
181
|
+
else:
|
182
|
+
assert_never(rules)
|
183
|
+
|
184
|
+
def _is_applied_to_item(self, input_value: str, rule: str | re.Pattern) -> bool:
|
185
|
+
if isinstance(rule, str):
|
186
|
+
return input_value.strip().lower() == rule.strip().lower()
|
187
|
+
elif isinstance(rule, re.Pattern):
|
188
|
+
return bool(rule.search(input_value.strip().lower()))
|
189
|
+
else:
|
190
|
+
assert_never(rule)
|
191
|
+
|
192
|
+
MAPPING: Mapping[str, _TRmRules] = {}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
openepd/__init__.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9Dvvtd4,620
|
2
|
-
openepd/__version__.py,sha256=
|
2
|
+
openepd/__version__.py,sha256=SIlr9JF7DMOxJeLOuOMUaby5LJ18vD9hLPBZxuEJy_w,638
|
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=mjTT8eGtfj6Fgp-wcs0cCWA7DJo1KL_iQ75rgKkaY3c,8037
|
@@ -48,8 +48,8 @@ openepd/model/factory.py,sha256=UWSGpfCr3GiMTP4rzBkwqxzbXB6GKZ_5Okb1Dqa_4aA,2701
|
|
48
48
|
openepd/model/generic_estimate.py,sha256=_R18Uz-hvxtSBl53D0_OkwVCWvoa2nIDjBdec6vEPDE,4304
|
49
49
|
openepd/model/geography.py,sha256=Jx7NIDdk_sIvwyh-7YxnIjAwIHW2HCQK7UtFGM2xKtw,42095
|
50
50
|
openepd/model/industry_epd.py,sha256=Cqn01IUNSZqRkyU05TwtOLXDKlg0YnGzqvKL8A__zbI,4061
|
51
|
-
openepd/model/lcia.py,sha256=
|
52
|
-
openepd/model/org.py,sha256=
|
51
|
+
openepd/model/lcia.py,sha256=Sx6SAwRTlkxqjKq-QEkPEUihgIS04jUndhOi4oHP5vw,27824
|
52
|
+
openepd/model/org.py,sha256=1O3MM2y4nEEQ8V2WsJCK4cvQumcadZ6sgwSM1sRbGkY,8012
|
53
53
|
openepd/model/pcr.py,sha256=cu3EakCAjBCkcb_AaLXB-xEjY0mlG-wJe74zGc5tdS0,5637
|
54
54
|
openepd/model/specs/README.md,sha256=UGhSiFJ9hOxT1mZl-5ZrhkOrPKf1W_gcu5CI9hzV7LU,2430
|
55
55
|
openepd/model/specs/__init__.py,sha256=RMLxvwD-_N5qaU0U2o5LxMKmP_W0_yssl72uTTC2tJg,3904
|
@@ -146,7 +146,10 @@ openepd/model/validation/numbers.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9
|
|
146
146
|
openepd/model/validation/quantity.py,sha256=M9dz3byTK6Lrys43I0Gq7n2b0aE8WYys-idxi6bKCII,21755
|
147
147
|
openepd/model/versioning.py,sha256=LldrNjPjVBsVTWyJrBe6VoI19B0d47QXbHk_6omXPxc,4561
|
148
148
|
openepd/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
149
|
-
openepd
|
150
|
-
openepd
|
151
|
-
openepd
|
152
|
-
openepd-7.
|
149
|
+
openepd/utils/__init__.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9Dvvtd4,620
|
150
|
+
openepd/utils/mapping/__init__.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9Dvvtd4,620
|
151
|
+
openepd/utils/mapping/common.py,sha256=WphCzwQQlzX11tUk88Ubyq3QPBLvH0tBPSIuH0kmiug,7339
|
152
|
+
openepd-7.6.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
153
|
+
openepd-7.6.0.dist-info/METADATA,sha256=P3nO_EP7rA_3qyoV3RCC-_wDURAPDyebRetk0YLUc14,9810
|
154
|
+
openepd-7.6.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
155
|
+
openepd-7.6.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|