hestia-earth-utils 0.15.14__tar.gz → 0.15.15__tar.gz
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.
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/PKG-INFO +1 -1
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/emission.py +10 -2
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/lookup_utils.py +63 -49
- hestia_earth_utils-0.15.15/hestia_earth/utils/version.py +1 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth_utils.egg-info/PKG-INFO +1 -1
- hestia_earth_utils-0.15.14/hestia_earth/utils/version.py +0 -1
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/MANIFEST.in +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/README.md +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/bin/hestia-format-upload +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/bin/hestia-pivot-csv +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/__init__.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/__init__.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/api.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/blank_node.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/calculation_status.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/cycle.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/date.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/descriptive_stats.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/lookup.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/model.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/pipeline.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/pivot/__init__.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/pivot/_shared.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/pivot/pivot_csv.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/pivot/pivot_json.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/request.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/stats.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/storage/__init__.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/storage/_azure_client.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/storage/_local_client.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/storage/_s3_client.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/storage/_sns_client.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/table.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/term.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/tools.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth_utils.egg-info/SOURCES.txt +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth_utils.egg-info/dependency_links.txt +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth_utils.egg-info/requires.txt +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth_utils.egg-info/top_level.txt +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/setup.cfg +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/setup.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/tests/pivot/__init__.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/tests/pivot/test_pivot_csv.py +0 -0
- {hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/tests/pivot/test_pivot_json.py +0 -0
|
@@ -9,7 +9,11 @@ from .lookup_utils import (
|
|
|
9
9
|
is_product_termType_allowed,
|
|
10
10
|
is_product_id_allowed,
|
|
11
11
|
is_input_termType_allowed,
|
|
12
|
-
is_input_id_allowed
|
|
12
|
+
is_input_id_allowed,
|
|
13
|
+
is_practice_termType_allowed,
|
|
14
|
+
is_practice_id_allowed,
|
|
15
|
+
is_transformation_termType_allowed,
|
|
16
|
+
is_transformation_id_allowed,
|
|
13
17
|
)
|
|
14
18
|
|
|
15
19
|
|
|
@@ -35,7 +39,11 @@ def cycle_emission_is_in_system_boundary(cycle: dict):
|
|
|
35
39
|
is_product_termType_allowed,
|
|
36
40
|
is_product_id_allowed,
|
|
37
41
|
is_input_termType_allowed,
|
|
38
|
-
is_input_id_allowed
|
|
42
|
+
is_input_id_allowed,
|
|
43
|
+
is_practice_termType_allowed,
|
|
44
|
+
is_practice_id_allowed,
|
|
45
|
+
is_transformation_termType_allowed,
|
|
46
|
+
is_transformation_id_allowed,
|
|
39
47
|
]))
|
|
40
48
|
|
|
41
49
|
return filter_term
|
{hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/lookup_utils.py
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from functools import lru_cache
|
|
2
2
|
import json
|
|
3
|
+
from hestia_earth.schema import SchemaType
|
|
3
4
|
|
|
4
5
|
from .lookup import _download_lookup_data, download_lookup, get_table_value, column_name
|
|
5
6
|
from .api import download_hestia
|
|
@@ -35,6 +36,10 @@ def _get_site_measurements(node: dict):
|
|
|
35
36
|
return flatten([non_empty_list(site.get('measurements', [])) for site in sites])
|
|
36
37
|
|
|
37
38
|
|
|
39
|
+
def _blank_node_term_values(blank_nodes: list, key: str = '@id'):
|
|
40
|
+
return non_empty_list([v.get('term', {}).get(key) for v in blank_nodes])
|
|
41
|
+
|
|
42
|
+
|
|
38
43
|
@lru_cache()
|
|
39
44
|
def _allowed_model_mapping(model: str, term_id: str, column: str):
|
|
40
45
|
mapping = _allowed_mapping_data()
|
|
@@ -45,22 +50,23 @@ def _allowed_model_mapping(model: str, term_id: str, column: str):
|
|
|
45
50
|
return (value or _ALLOW_ALL).split(';') if isinstance(value, str) else _ALLOW_ALL
|
|
46
51
|
|
|
47
52
|
|
|
53
|
+
def _is_model_value_allowed(model: str, term_id: str, values: list, lookup_column: str):
|
|
54
|
+
allowed_values = _allowed_model_mapping(model, term_id, lookup_column)
|
|
55
|
+
return any([
|
|
56
|
+
_ALLOW_ALL in allowed_values,
|
|
57
|
+
len(values) == 0
|
|
58
|
+
]) or any([value in allowed_values for value in values])
|
|
59
|
+
|
|
60
|
+
|
|
48
61
|
def is_model_siteType_allowed(model: str, term_id: str, data: dict):
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return True if _ALLOW_ALL in allowed_values or not site_types else any([
|
|
52
|
-
(site_type in allowed_values) for site_type in site_types
|
|
53
|
-
])
|
|
62
|
+
values = _get_site_types(data)
|
|
63
|
+
return _is_model_value_allowed(model, term_id, values, 'siteTypesAllowed')
|
|
54
64
|
|
|
55
65
|
|
|
56
66
|
def is_model_product_id_allowed(model: str, term_id: str, data: dict):
|
|
57
67
|
products = data.get('products', [])
|
|
58
|
-
values =
|
|
59
|
-
|
|
60
|
-
return True if any([
|
|
61
|
-
_ALLOW_ALL in allowed_values,
|
|
62
|
-
len(values) == 0
|
|
63
|
-
]) else any([value in allowed_values for value in values])
|
|
68
|
+
values = _blank_node_term_values(products)
|
|
69
|
+
return _is_model_value_allowed(model, term_id, values, 'productTermIdsAllowed')
|
|
64
70
|
|
|
65
71
|
|
|
66
72
|
@lru_cache()
|
|
@@ -73,68 +79,76 @@ def _allowed_mapping(term_id: str, column: str):
|
|
|
73
79
|
return (value or _ALLOW_ALL).split(';') if isinstance(value, str) else _ALLOW_ALL
|
|
74
80
|
|
|
75
81
|
|
|
82
|
+
def _is_term_value_allowed(term_id: str, values: list, lookup_column: str):
|
|
83
|
+
allowed_values = _allowed_mapping(term_id, lookup_column)
|
|
84
|
+
return any([
|
|
85
|
+
_ALLOW_ALL in allowed_values,
|
|
86
|
+
len(values) == 0
|
|
87
|
+
]) or any([value in allowed_values for value in values])
|
|
88
|
+
|
|
89
|
+
|
|
76
90
|
def is_siteType_allowed(data: dict, term_id: str):
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return True if _ALLOW_ALL in allowed_values or not site_types else any([
|
|
80
|
-
(site_type in allowed_values) for site_type in site_types
|
|
81
|
-
])
|
|
91
|
+
values = _get_site_types(data)
|
|
92
|
+
return _is_term_value_allowed(term_id, values, 'siteTypesAllowed')
|
|
82
93
|
|
|
83
94
|
|
|
84
95
|
def is_site_measurement_id_allowed(data: dict, term_id: str):
|
|
85
96
|
measurements = _get_site_measurements(data)
|
|
86
|
-
values =
|
|
87
|
-
|
|
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])
|
|
97
|
+
values = _blank_node_term_values(measurements, key='@id')
|
|
98
|
+
return _is_term_value_allowed(term_id, values, 'siteMeasurementIdsAllowed')
|
|
92
99
|
|
|
93
100
|
|
|
94
101
|
def is_product_termType_allowed(data: dict, term_id: str):
|
|
95
102
|
products = data.get('products', [])
|
|
96
|
-
values =
|
|
97
|
-
|
|
98
|
-
return True if any([
|
|
99
|
-
_ALLOW_ALL in allowed_values,
|
|
100
|
-
len(values) == 0
|
|
101
|
-
]) else any([value in allowed_values for value in values])
|
|
103
|
+
values = _blank_node_term_values(products, key='termType')
|
|
104
|
+
return _is_term_value_allowed(term_id, values, 'productTermTypesAllowed')
|
|
102
105
|
|
|
103
106
|
|
|
104
107
|
def is_product_id_allowed(data: dict, term_id: str):
|
|
105
108
|
products = data.get('products', [])
|
|
106
|
-
values =
|
|
107
|
-
|
|
108
|
-
return True if any([
|
|
109
|
-
_ALLOW_ALL in allowed_values,
|
|
110
|
-
len(values) == 0
|
|
111
|
-
]) else any([value in allowed_values for value in values])
|
|
109
|
+
values = _blank_node_term_values(products, key='@id')
|
|
110
|
+
return _is_term_value_allowed(term_id, values, 'productTermIdsAllowed')
|
|
112
111
|
|
|
113
112
|
|
|
114
113
|
def is_input_termType_allowed(data: dict, term_id: str):
|
|
115
114
|
inputs = data.get('inputs', [])
|
|
116
|
-
values =
|
|
117
|
-
|
|
118
|
-
return True if any([
|
|
119
|
-
_ALLOW_ALL in allowed_values,
|
|
120
|
-
len(values) == 0
|
|
121
|
-
]) else any([value in allowed_values for value in values])
|
|
115
|
+
values = _blank_node_term_values(inputs, key='termType')
|
|
116
|
+
return _is_term_value_allowed(term_id, values, 'inputTermTypesAllowed')
|
|
122
117
|
|
|
123
118
|
|
|
124
119
|
def is_input_id_allowed(data: dict, term_id: str):
|
|
125
120
|
inputs = data.get('inputs', [])
|
|
126
|
-
values =
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
121
|
+
values = _blank_node_term_values(inputs, key='@id')
|
|
122
|
+
return _is_term_value_allowed(term_id, values, 'inputTermIdsAllowed')
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def is_practice_termType_allowed(data: dict, term_id: str):
|
|
126
|
+
practices = data.get('practices', [])
|
|
127
|
+
values = _blank_node_term_values(practices, key='termType')
|
|
128
|
+
return _is_term_value_allowed(term_id, values, 'practiceTermTypesAllowed')
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def is_practice_id_allowed(data: dict, term_id: str):
|
|
132
|
+
practices = data.get('practices', [])
|
|
133
|
+
values = _blank_node_term_values(practices, key='@id')
|
|
134
|
+
return _is_term_value_allowed(term_id, values, 'practiceTermIdsAllowed')
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def is_transformation_termType_allowed(data: dict, term_id: str):
|
|
138
|
+
is_transformation = data.get('@type', data.get('type')) == SchemaType.TRANSFORMATION.value
|
|
139
|
+
values = non_empty_list([data.get('term', {}).get('termType')])
|
|
140
|
+
return not is_transformation or _is_term_value_allowed(term_id, values, 'transformationTermTypesAllowed')
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def is_transformation_id_allowed(data: dict, term_id: str):
|
|
144
|
+
is_transformation = data.get('@type', data.get('type')) == SchemaType.TRANSFORMATION.value
|
|
145
|
+
values = non_empty_list([data.get('term', {}).get('@id')])
|
|
146
|
+
return not is_transformation or _is_term_value_allowed(term_id, values, 'transformationTermIdsAllowed')
|
|
132
147
|
|
|
133
148
|
|
|
134
149
|
def is_node_type_allowed(data: dict, term_id: str):
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return True if _ALLOW_ALL in allowed_types or not node_type else node_type in allowed_types
|
|
150
|
+
values = non_empty_list([data.get('@type', data.get('type'))])
|
|
151
|
+
return _is_term_value_allowed(term_id, values, 'typesAllowed')
|
|
138
152
|
|
|
139
153
|
|
|
140
154
|
@lru_cache()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = '0.15.15'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
VERSION = '0.15.14'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/calculation_status.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/descriptive_stats.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/pivot/__init__.py
RENAMED
|
File without changes
|
{hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/pivot/_shared.py
RENAMED
|
File without changes
|
{hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/pivot/pivot_csv.py
RENAMED
|
File without changes
|
{hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/pivot/pivot_json.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/storage/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/storage/_s3_client.py
RENAMED
|
File without changes
|
{hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth/utils/storage/_sns_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth_utils.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth_utils.egg-info/requires.txt
RENAMED
|
File without changes
|
{hestia_earth_utils-0.15.14 → hestia_earth_utils-0.15.15}/hestia_earth_utils.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|