openepd 6.13.1__py3-none-any.whl → 6.13.2__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.13.1"
16
+ VERSION = "6.13.2"
openepd/m49/__init__.py CHANGED
@@ -13,3 +13,5 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
+
17
+ from . import utils as geo_converter # for backwards compatibility
openepd/m49/const.py CHANGED
@@ -13,8 +13,8 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
-
17
16
  from typing import NamedTuple
17
+ import warnings
18
18
 
19
19
  M49_CODE_WORLD = "001"
20
20
  M49_CODE_AFRICA = "002"
@@ -1169,4 +1169,7 @@ def is_m49_code(to_check: str) -> bool:
1169
1169
  :param to_check: any string
1170
1170
  :return: `True` if passed string is M49 code, `False` otherwise
1171
1171
  """
1172
- return to_check in M49_AREAS or to_check in M49_TO_ISO3166_ALPHA2
1172
+ warnings.warn("Use m49.utils.is_m49_code instead.", DeprecationWarning)
1173
+ from . import utils
1174
+
1175
+ return utils.is_m49_code(to_check)
@@ -13,11 +13,21 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
+ __all__ = [
17
+ "iso_to_m49",
18
+ "m49_to_iso",
19
+ "region_and_country_names_to_m49",
20
+ "m49_to_region_and_country_names",
21
+ "openepd_to_m49",
22
+ "m49_to_openepd",
23
+ "is_m49_code",
24
+ ]
16
25
  from typing import Collection
17
26
 
18
27
  from openepd.m49.const import (
19
28
  COUNTRY_VERBOSE_NAME_TO_M49,
20
29
  ISO3166_ALPHA2_TO_M49,
30
+ M49_AREAS,
21
31
  M49_TO_COUNTRY_VERBOSE_NAME,
22
32
  M49_TO_ISO3166_ALPHA2,
23
33
  M49_TO_REGION_VERBOSE_NAME,
@@ -122,10 +132,10 @@ def openepd_to_m49(regions: Collection[str]) -> set[str]:
122
132
  Convert OpenEPD geography definitions to pure M49 region codes.
123
133
 
124
134
  :param regions: list of OpenEPD geography definitions including letter codes and aliases
125
- like "EU27" or "NAFTA" (e.g., ["EU27", "NAFTA"], ["US", "CA, MX"])
135
+ like "EU27" or "NAFTA" (e.g., ["EU27", "NAFTA"], ["US", "CA, MX"], ["NAFTA", "051"])
126
136
  :return: Set of M49 region codes (e.g., {"040", "056", "100", "191", "196", "203", "208", "233", "246", "250",
127
137
  "276", "300", "348", "372", "380", "428", "440", "442", "470", "528", "616", "620", "642", "703", "705", "724",
128
- "752", "840", "124", "484"}, {"840", "124", "484"})
138
+ "752", "840", "124", "484"}, {"840", "124", "484"}, {"840", "124", "484", "051"})
129
139
  :raises ValueError: If a region or country name is not found in ISO3166 or OpenEPD special regions.
130
140
  """
131
141
 
@@ -140,6 +150,8 @@ def openepd_to_m49(regions: Collection[str]) -> set[str]:
140
150
  m49_code = ISO3166_ALPHA2_TO_M49.get(region.upper())
141
151
  if m49_code:
142
152
  result.add(m49_code)
153
+ elif is_m49_code(region):
154
+ result.add(region)
143
155
  else:
144
156
  raise ValueError(f"Region '{region}' not found in ISO3166 or OpenEPD special regions.")
145
157
  return result
@@ -176,3 +188,13 @@ def m49_to_openepd(regions: list[str]) -> set[str]:
176
188
  raise ValueError(f"Region code '{code}' not found in ISO3166 or OpenEPD special regions.")
177
189
 
178
190
  return result
191
+
192
+
193
+ def is_m49_code(to_check: str) -> bool:
194
+ """
195
+ Check if passed string is M49 code.
196
+
197
+ :param to_check: any string
198
+ :return: `True` if passed string is M49 code, `False` otherwise
199
+ """
200
+ return to_check in M49_AREAS or to_check in M49_TO_ISO3166_ALPHA2
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openepd
3
- Version: 6.13.1
3
+ Version: 6.13.2
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=fhxfEyEurLvSfvQci-vb3njzl_lvhcLXiZrecCOaMU8,794
2
- openepd/__version__.py,sha256=sgmt6cETSc5fqwbwM-ICVdVetdp89fDLgd8mFB7w4go,639
2
+ openepd/__version__.py,sha256=qONobSZDRb30xeK087DIv0mIqy0n-JQXVGDOZraUG1I,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=KHCmSKMOJTQct6vhdhAatAENoouStc_yVRza5AFNoIo,7953
@@ -32,9 +32,9 @@ openepd/bundle/writer.py,sha256=gHK1D-F-td2C18QFWerg666JUTLaGUkTUSQURJi9o74,8136
32
32
  openepd/compat/__init__.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9Dvvtd4,620
33
33
  openepd/compat/compat_functional_validators.py,sha256=aWg3a80fqT8zjN0S260N-Ad2WFKAaB8ByN7ArBW3NMA,834
34
34
  openepd/compat/pydantic.py,sha256=dNwPXK1X5xq9sdkd0kcbKQAUIter1GAfcxXOl6hmITQ,1146
35
- openepd/m49/__init__.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9Dvvtd4,620
36
- openepd/m49/const.py,sha256=O31VJ5_sR4GAOvJnFsi3An2YMaMa96H7XBqaQ0kNwnw,31734
37
- openepd/m49/geo_converter.py,sha256=mRamQTVwd35kwn5-23N3E8cxqpYG7l9eW787SJYM7nw,6515
35
+ openepd/m49/__init__.py,sha256=vkXC6i8OeCl5K88JUIRN_NKfsAIpNIaN-fyPmmd-Lfk,689
36
+ openepd/m49/const.py,sha256=buspTHOOWhkBXWUIS0oqvQ0y1L7y70Y_PXilkiBIKD4,31819
37
+ openepd/m49/utils.py,sha256=Qm8HvxAZlQncsyUYDO0lG0feMFFnT4HQPNSMp78W4zU,7111
38
38
  openepd/model/__init__.py,sha256=9THJcV3LT7JDBOMz1px-QFf_sdJ0LOqJ5dmA9Dvvtd4,620
39
39
  openepd/model/base.py,sha256=1GeaEDn-ppy94GaOaZI1y6Yew_0eBBho1COaxfzzLCw,9834
40
40
  openepd/model/category.py,sha256=reeOVRDuZPYU77EMwG0K5VjnK2H9yOGxT0PJXXqrjEk,1639
@@ -139,7 +139,7 @@ openepd/model/validation/quantity.py,sha256=vfSe-3DGQf84bCp_sMIU0ZPAA1wIilodpTjL
139
139
  openepd/model/versioning.py,sha256=cm3LaAUODnbbu3W3pC6baJzxKusTQ1kZH-PwwScCj3c,4473
140
140
  openepd/patch_pydantic.py,sha256=LVqDMKn723VYYf_V-RgTLxIb1xiUtYOfPYCQP6-7RoM,4122
141
141
  openepd/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
142
- openepd-6.13.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
143
- openepd-6.13.1.dist-info/METADATA,sha256=T7QapSryr1s5pRrcSY-TBnm6HauXRFkEOD-_If1ZfpI,9039
144
- openepd-6.13.1.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
145
- openepd-6.13.1.dist-info/RECORD,,
142
+ openepd-6.13.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
143
+ openepd-6.13.2.dist-info/METADATA,sha256=mJIwK2tPktGs8i7uVmk6xqRuMpSg3AWA5H3RELYtypo,9039
144
+ openepd-6.13.2.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
145
+ openepd-6.13.2.dist-info/RECORD,,