hestia-earth-utils 0.15.9__py3-none-any.whl → 0.15.11__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.
@@ -5,6 +5,7 @@ from .lookup import download_lookup, lookup_term_ids
5
5
  from .lookup_utils import (
6
6
  is_in_system_boundary,
7
7
  is_siteType_allowed,
8
+ is_site_measurement_id_allowed,
8
9
  is_product_termType_allowed,
9
10
  is_product_id_allowed,
10
11
  is_input_termType_allowed,
@@ -30,6 +31,7 @@ def cycle_emission_is_in_system_boundary(cycle: dict):
30
31
  def filter_term(term_id: str):
31
32
  return is_in_system_boundary(term_id) and all(map(lambda check: check(cycle, term_id), [
32
33
  is_siteType_allowed,
34
+ is_site_measurement_id_allowed,
33
35
  is_product_termType_allowed,
34
36
  is_product_id_allowed,
35
37
  is_input_termType_allowed,
@@ -3,7 +3,7 @@ import json
3
3
 
4
4
  from .lookup import _download_lookup_data, download_lookup, get_table_value, column_name
5
5
  from .api import download_hestia
6
- from .tools import non_empty_list
6
+ from .tools import non_empty_list, flatten
7
7
 
8
8
  _ALLOW_ALL = 'all'
9
9
 
@@ -30,6 +30,11 @@ def _get_site_types(node: dict):
30
30
  return non_empty_list([site.get('siteType') for site in sites])
31
31
 
32
32
 
33
+ def _get_site_measurements(node: dict):
34
+ sites = [node] if _is_site(node) else _get_sites(node)
35
+ return flatten([non_empty_list(site.get('measurements', [])) for site in sites])
36
+
37
+
33
38
  @lru_cache()
34
39
  def _allowed_model_mapping(model: str, term_id: str, column: str):
35
40
  mapping = _allowed_mapping_data()
@@ -76,6 +81,16 @@ def is_siteType_allowed(data: dict, term_id: str):
76
81
  ])
77
82
 
78
83
 
84
+ def is_site_measurement_id_allowed(data: dict, term_id: str):
85
+ measurements = _get_site_measurements(data)
86
+ values = non_empty_list([v.get('term', {}).get('@id') for v in measurements])
87
+ allowed_values = _allowed_mapping(term_id, 'siteMeasurementIdsAllowed')
88
+ return True if any([
89
+ _ALLOW_ALL in allowed_values,
90
+ len(values) == 0
91
+ ]) else any([value in allowed_values for value in values])
92
+
93
+
79
94
  def is_product_termType_allowed(data: dict, term_id: str):
80
95
  products = data.get('products', [])
81
96
  values = non_empty_list([p.get('term', {}).get('termType') for p in products])
@@ -1 +1 @@
1
- VERSION = '0.15.9'
1
+ VERSION = '0.15.11'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hestia-earth-utils
3
- Version: 0.15.9
3
+ Version: 0.15.11
4
4
  Summary: HESTIA's utils library
5
5
  Home-page: https://gitlab.com/hestia-earth/hestia-utils
6
6
  Author: HESTIA Team
@@ -6,9 +6,9 @@ hestia_earth/utils/calculation_status.py,sha256=X7lbgVMD9luH1gj9lEcxd3_P2-u7e8ZP
6
6
  hestia_earth/utils/cycle.py,sha256=rFLRL9X4KQ1UrE6fEPA_gV8KmwzrZpR3Ce56zg41lRk,1326
7
7
  hestia_earth/utils/date.py,sha256=SPQ69uxHiv1o3BqIkBKkM5XX_CmS20CB7g6u2rhsdh8,1807
8
8
  hestia_earth/utils/descriptive_stats.py,sha256=EMVwFvg2OnZgKRAfireAoWY2EbrSvqR0V0bK9B53p28,1583
9
- hestia_earth/utils/emission.py,sha256=crHAJOQRI0NRHht0fFOFjEqcarsFqzbV4pDgk90dfME,1595
9
+ hestia_earth/utils/emission.py,sha256=Dk99fpfGhVH3Azebqt7KAldWzVkEtsW5Yr1Ggfse8ho,1675
10
10
  hestia_earth/utils/lookup.py,sha256=0RLqy3HPzkbhkRaO7fYoHU0jKhAYzI6QHMptMEbqTlg,10344
11
- hestia_earth/utils/lookup_utils.py,sha256=9pkJUKo3NEBspoN9yRPoDCzkxcbpnbLpC7Z0I6HiP7I,5369
11
+ hestia_earth/utils/lookup_utils.py,sha256=DXjxrgb6ETnFnzgQpDdhAoja2YuI7b-5QyomJDFr5Qc,5985
12
12
  hestia_earth/utils/model.py,sha256=uUcrF07XmBzqLni8VSaP0HoebJnQ57kk0EOmhwYMbfI,4637
13
13
  hestia_earth/utils/pipeline.py,sha256=O-6DPtK0U1lJ51LFGa1gM6pjkBJUfxOjNjY8LxQPXV0,9588
14
14
  hestia_earth/utils/request.py,sha256=bu7hkWKmFdXl2_Feawiam_x32whlclA9oP0asJyC69k,626
@@ -16,7 +16,7 @@ hestia_earth/utils/stats.py,sha256=4t3op10xDJbGxWJEY1Jtyl302PYWyMFwLpsSkMlzQn8,3
16
16
  hestia_earth/utils/table.py,sha256=RrTt-KF_QzjKiCpaAueoG6La1FG-Iusxw5NMDpoRBpQ,2861
17
17
  hestia_earth/utils/term.py,sha256=6LiUSc6KX3IOkfWF6fYkQ2tENCO8ENljcdDypxU6WtA,1060
18
18
  hestia_earth/utils/tools.py,sha256=eCppZ0gFR6RPF7TEraMLwLJnUCJb93xP0iEzFPcYpK0,4685
19
- hestia_earth/utils/version.py,sha256=bYJDMWJ5fpHePjK8_SqlY-xcn41Nz654Q1jc3TykHC8,19
19
+ hestia_earth/utils/version.py,sha256=qRcvn3GMIawuLKmMfJA7N1zkiyrTpl49n8THxVSnnVg,20
20
20
  hestia_earth/utils/pivot/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
21
  hestia_earth/utils/pivot/_shared.py,sha256=MB9074xkgKO9D_B6tWM-pdOlpjP_9itWpAHAzkA_1to,914
22
22
  hestia_earth/utils/pivot/pivot_csv.py,sha256=Ed-sCKEqVIFJu71AncS7zlMkHbw5V15QLd5c5B_uxiE,12296
@@ -26,12 +26,12 @@ hestia_earth/utils/storage/_azure_client.py,sha256=sevCZni04eknMql2DgUsWG23f7u0K
26
26
  hestia_earth/utils/storage/_local_client.py,sha256=IbzziUKY0QS3ybHFfgEpELqvafa7hQnZ-DdGdjQuypE,515
27
27
  hestia_earth/utils/storage/_s3_client.py,sha256=aWt4i_vObcTDWcwyzOOnBBnMv1rxPZV3AJZQMn96Hok,2975
28
28
  hestia_earth/utils/storage/_sns_client.py,sha256=LowUatj78Egu6_Id6Rr7hZjfZx1WguS3lozB3yAwSps,347
29
- hestia_earth_utils-0.15.9.data/scripts/hestia-format-upload,sha256=IhLAHHPJqRgUcht-M_EUEsRMbRbMfshig07o488zscM,703
30
- hestia_earth_utils-0.15.9.data/scripts/hestia-pivot-csv,sha256=0YBuGuyPO8rytod6iwWEKiQdSlr9JLuD001k6U5t6no,1163
29
+ hestia_earth_utils-0.15.11.data/scripts/hestia-format-upload,sha256=IhLAHHPJqRgUcht-M_EUEsRMbRbMfshig07o488zscM,703
30
+ hestia_earth_utils-0.15.11.data/scripts/hestia-pivot-csv,sha256=0YBuGuyPO8rytod6iwWEKiQdSlr9JLuD001k6U5t6no,1163
31
31
  tests/pivot/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  tests/pivot/test_pivot_csv.py,sha256=aYni7o3QDPSgtVxVCspEetotgpYHY7Lz5VHf-DR89gw,8131
33
33
  tests/pivot/test_pivot_json.py,sha256=UYTAN4AZhzVicIYsU1A2VgJcctUXohjHppg6s-pqwcg,8287
34
- hestia_earth_utils-0.15.9.dist-info/METADATA,sha256=4jCktvV_bF4-K0KgGIb-i9wQk2T6CrgzMY7jAJxrZaw,1757
35
- hestia_earth_utils-0.15.9.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
36
- hestia_earth_utils-0.15.9.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
37
- hestia_earth_utils-0.15.9.dist-info/RECORD,,
34
+ hestia_earth_utils-0.15.11.dist-info/METADATA,sha256=yjwNXw4Pz9CNmnusIzhScYklZWFrmSpyahc7a11K6nI,1758
35
+ hestia_earth_utils-0.15.11.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
36
+ hestia_earth_utils-0.15.11.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
37
+ hestia_earth_utils-0.15.11.dist-info/RECORD,,