hestia-earth-utils 0.16.2__py3-none-any.whl → 0.16.4__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.
@@ -26,12 +26,10 @@ def _text_to_csv(csv_content: str):
26
26
 
27
27
 
28
28
  def _csv_reader_converter(field_str_bytes):
29
- field_str = field_str_bytes if isinstance(field_str_bytes, str) else field_str_bytes.decode('utf-8')
30
- reader = _text_to_csv(field_str)
31
-
32
29
  try:
33
- return _replace_missing_values(next(reader)[0].strip())
34
- except StopIteration:
30
+ field_str = field_str_bytes if isinstance(field_str_bytes, str) else field_str_bytes.decode('utf-8')
31
+ return _replace_missing_values(field_str)
32
+ except Exception:
35
33
  return str(_MISSING)
36
34
 
37
35
 
@@ -2,7 +2,6 @@ from functools import reduce
2
2
  from typing import Union
3
3
  import requests
4
4
  import numpy
5
- import traceback
6
5
 
7
6
  from .storage import _load_from_storage
8
7
  from .request import request_url, web_url
@@ -92,8 +91,6 @@ def download_lookup(filename: str, keep_in_memory: bool = True, build_index: boo
92
91
  try:
93
92
  return _memory_wrapper(filename, load) if keep_in_memory else load()
94
93
  except Exception:
95
- stack = traceback.format_exc()
96
- print(stack)
97
94
  return None
98
95
 
99
96
 
@@ -142,7 +139,7 @@ def _get_multiple_table_values(data: Union[dict, numpy.recarray], col_match: str
142
139
  return reduce(reducer, enumerate(col_match), data)[col_val][0]
143
140
 
144
141
 
145
- def get_table_value(lookup: Union[dict, numpy.recarray], col_match: str, col_match_with, col_val):
142
+ def get_table_value(lookup: Union[dict, numpy.recarray], col_match: str, col_match_with, col_val, default_value=''):
146
143
  """
147
144
  Get a value matched by one or more columns from a `numpy.recarray`.
148
145
 
@@ -158,6 +155,8 @@ def get_table_value(lookup: Union[dict, numpy.recarray], col_match: str, col_mat
158
155
  Can be a single `str` or a list of `str`. If a list is used, must be the same length as `col_match`.
159
156
  col_val: str
160
157
  The column which contains the value to look for.
158
+ default_value : Any
159
+ A value to return when none if found in the data.
161
160
 
162
161
  Returns
163
162
  -------
@@ -170,7 +169,7 @@ def get_table_value(lookup: Union[dict, numpy.recarray], col_match: str, col_mat
170
169
  _get_single_table_value(lookup, col_match, col_match_with, col_val) if single else
171
170
  _get_multiple_table_values(lookup, col_match, col_match_with, col_val)
172
171
  )
173
- return None if is_missing_value(value) else _parse_value(value)
172
+ return default_value if is_missing_value(value) else _parse_value(value)
174
173
  except Exception:
175
174
  return None
176
175
 
@@ -1 +1 @@
1
- VERSION = '0.16.2'
1
+ VERSION = '0.16.4'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hestia_earth_utils
3
- Version: 0.16.2
3
+ Version: 0.16.4
4
4
  Summary: HESTIA's utils library
5
5
  Home-page: https://gitlab.com/hestia-earth/hestia-utils
6
6
  Author: HESTIA Team
@@ -2,12 +2,12 @@ hestia_earth/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
2
2
  hestia_earth/utils/api.py,sha256=y0gw5pCCHNnFIhM62Hok_5eDtH3QDAZdkye_1mANMNs,9654
3
3
  hestia_earth/utils/blank_node.py,sha256=1wc9zUkOvFhJS-YmuKexfIdYxfsp5KyJczLmHlW559Q,7375
4
4
  hestia_earth/utils/calculation_status.py,sha256=X7lbgVMD9luH1gj9lEcxd3_P2-u7e8ZPGCvX1czPZUo,2238
5
- hestia_earth/utils/csv_utils.py,sha256=nb_ihJaTj3K5hO7cxXO1xjTLVGVX1P13m9SgquO5-XY,1990
5
+ hestia_earth/utils/csv_utils.py,sha256=MXE8ZqLo02aGaGVebEVWR_hPBP8ADINcJixn_RgDlxs,1938
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
9
  hestia_earth/utils/emission.py,sha256=BhBitooLTxZSh82S982v2QfPxxTF1kmGClG_uHyWdz4,1981
10
- hestia_earth/utils/lookup.py,sha256=NoEv0Hd496I9kf-shYXYUwNabatjc_uO9Ade8J98oBI,9490
10
+ hestia_earth/utils/lookup.py,sha256=XKmxFEH9o1Rhi4oTLteQnMAwNXiObjSX7pMfrUw8q1I,9522
11
11
  hestia_earth/utils/lookup_utils.py,sha256=_k3RZ1pK-gw7jq8wn9HrPWfDl4FlEWRb8bXmgaARu0w,6716
12
12
  hestia_earth/utils/model.py,sha256=uUcrF07XmBzqLni8VSaP0HoebJnQ57kk0EOmhwYMbfI,4637
13
13
  hestia_earth/utils/pipeline.py,sha256=O-6DPtK0U1lJ51LFGa1gM6pjkBJUfxOjNjY8LxQPXV0,9588
@@ -16,7 +16,7 @@ hestia_earth/utils/stats.py,sha256=4t3op10xDJbGxWJEY1Jtyl302PYWyMFwLpsSkMlzQn8,3
16
16
  hestia_earth/utils/table.py,sha256=MOJDo5fQPRDogAty_UXbO9-EXFwz97m0f7--mOM17lQ,2363
17
17
  hestia_earth/utils/term.py,sha256=6LiUSc6KX3IOkfWF6fYkQ2tENCO8ENljcdDypxU6WtA,1060
18
18
  hestia_earth/utils/tools.py,sha256=9GaUJwxL-CTzEOGnRFkUQDVFelPevQSxXrf25vssCVo,4990
19
- hestia_earth/utils/version.py,sha256=8a5HJaemwtN_jTS8fGe4SSrLufF3bwMJrcS4e735nPY,19
19
+ hestia_earth/utils/version.py,sha256=7beGZMTXE5jj-oFnFWj3G6qwJ6yzFEAre86VzGZDUvU,19
20
20
  hestia_earth/utils/pivot/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
21
  hestia_earth/utils/pivot/_shared.py,sha256=JnyIOzpans45DE2hSa9-4yvNhq8t08lx1IAWGJi6WPQ,1397
22
22
  hestia_earth/utils/pivot/pivot_csv.py,sha256=7f6kMqeb1b3RKANLGeDgVu8G5WC-vXIijHnsJhO-CjI,12022
@@ -26,9 +26,9 @@ 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=B2yTsf-VfHcRLCKTMes4S_nCXxrZad9umyZx3b5Pu_c,3181
28
28
  hestia_earth/utils/storage/_sns_client.py,sha256=LowUatj78Egu6_Id6Rr7hZjfZx1WguS3lozB3yAwSps,347
29
- hestia_earth_utils-0.16.2.data/scripts/hestia-format-upload,sha256=IhLAHHPJqRgUcht-M_EUEsRMbRbMfshig07o488zscM,703
30
- hestia_earth_utils-0.16.2.data/scripts/hestia-pivot-csv,sha256=0YBuGuyPO8rytod6iwWEKiQdSlr9JLuD001k6U5t6no,1163
31
- hestia_earth_utils-0.16.2.dist-info/METADATA,sha256=mz11GR2ctUEK-YYl0x2s4f1UVFwUAKb4rt-L-MHnItA,2030
32
- hestia_earth_utils-0.16.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
- hestia_earth_utils-0.16.2.dist-info/top_level.txt,sha256=q0QxKEYx9uLpAD5ZtC7Ypq29smEPfOzEAn7Xv8XHGOQ,13
34
- hestia_earth_utils-0.16.2.dist-info/RECORD,,
29
+ hestia_earth_utils-0.16.4.data/scripts/hestia-format-upload,sha256=IhLAHHPJqRgUcht-M_EUEsRMbRbMfshig07o488zscM,703
30
+ hestia_earth_utils-0.16.4.data/scripts/hestia-pivot-csv,sha256=0YBuGuyPO8rytod6iwWEKiQdSlr9JLuD001k6U5t6no,1163
31
+ hestia_earth_utils-0.16.4.dist-info/METADATA,sha256=_bUWrWyGlmLGQ0xS5jBrcbLWYxIlaXf7Eo2UMBk4RBs,2030
32
+ hestia_earth_utils-0.16.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
+ hestia_earth_utils-0.16.4.dist-info/top_level.txt,sha256=q0QxKEYx9uLpAD5ZtC7Ypq29smEPfOzEAn7Xv8XHGOQ,13
34
+ hestia_earth_utils-0.16.4.dist-info/RECORD,,