Skip to content

Commit 210e03a

Browse files
Merge pull request #371 from HXLStandard/dev
Release 5.2.1
2 parents cc34c0c + e1b745c commit 210e03a

5 files changed

Lines changed: 20 additions & 14 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2024-02-05 Release 5.2.1
2+
- make logup log level configurable via environment variable
3+
14
2024-01-10 Release 5.2
25
- update URLs for test files on GitHub
36
- fixed bug in aggregators that excluded tag patterns ending in "!"

hxl/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
if sys.version_info < (3,):
8282
raise RuntimeError("libhxl requires Python 3 or higher")
8383

84-
__version__="5.2"
84+
__version__="5.2.1"
8585
"""Module version number
8686
see https://www.python.org/dev/peps/pep-0396/
8787
"""

hxl/filters.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def evaluate_row(self, row):
467467
# Numbers only for sum and average
468468
datatype = hxl.datatypes.typeof(value, self.pattern)
469469
if self.type in ['sum', 'average'] and datatype != 'number':
470-
logup("Cannot use as a numeric value for aggregation; skipping.", {"value": value}, level='info')
470+
logup("Cannot use as a numeric value for aggregation; skipping.", {"value": value})
471471
logger.warning("Cannot use %s as a numeric value for aggregation; skipping.", value)
472472
return
473473

@@ -1181,7 +1181,7 @@ def _clean_value(self, value, column):
11811181
if self.date_format is not None:
11821182
value = dateutil.parser.parse(value).strftime(self.date_format)
11831183
except ValueError:
1184-
logup("Cannot use as a date", {"value": value}, level='info')
1184+
logup("Cannot use as a date", {"value": value})
11851185
logger.warning('Cannot parse %s as a date', str(value))
11861186
if self.purge:
11871187
value = ''
@@ -1210,7 +1210,7 @@ def try_number(s):
12101210
if n is not None:
12111211
value = n
12121212
else:
1213-
logup('Cannot parse as a number', {"value": value}, level='info')
1213+
logup('Cannot parse as a number', {"value": value})
12141214
logger.warning('Cannot parse %s as a number', str(value))
12151215
if self.purge:
12161216
value = ''
@@ -1222,7 +1222,7 @@ def try_number(s):
12221222
if lat is not None:
12231223
value = format(lat, '0.4f')
12241224
else:
1225-
logup('Cannot parse as a latitude', {"value": value}, level='info')
1225+
logup('Cannot parse as a latitude', {"value": value})
12261226
logger.warning('Cannot parse %s as a latitude', str(value))
12271227
if self.purge:
12281228
value = ''
@@ -1231,7 +1231,7 @@ def try_number(s):
12311231
if lon is not None:
12321232
value = format(lon, '0.4f')
12331233
else:
1234-
logup('Cannot parse as a longitude', {"value": value}, level='info')
1234+
logup('Cannot parse as a longitude', {"value": value})
12351235
logger.warning('Cannot parse %s as a longitude', str(value))
12361236
if self.purge:
12371237
value = ''
@@ -1240,7 +1240,7 @@ def try_number(s):
12401240
if coord is not None:
12411241
value = '{:.4f},{:.4f}'.format(coord[0], coord[1])
12421242
else:
1243-
logup('Cannot parse as geographical coordinates', {"value": value}, level='info')
1243+
logup('Cannot parse as geographical coordinates', {"value": value})
12441244
logger.warning('Cannot parse %s as geographical coordinates', str(value))
12451245
if self.purge:
12461246
value = ''
@@ -1882,7 +1882,7 @@ def process(self):
18821882
"pattern": self.label_pattern,
18831883
"tag": self.source.columns[self.label_index].display_tag,
18841884
"header": self.source.columns[self.label_index].header
1885-
}, level='info')
1885+
})
18861886
logger.warning(
18871887
"[Implode filter] multiple columns match label pattern %s; using first match %s (%s)",
18881888
self.label_pattern,
@@ -1895,7 +1895,7 @@ def process(self):
18951895
else:
18961896
logup('[Implode filter] multiple columns match value pattern; using first match', {
18971897
"pattern": self.label_pattern
1898-
}, level='info')
1898+
})
18991899
logger.warning(
19001900
"[Implode filter] multiple columns match value pattern %s; using first match",
19011901
self.value_pattern
@@ -1934,7 +1934,7 @@ def process(self):
19341934
if key not in self.rows:
19351935
self.rows[key] = {}
19361936
if label in self.rows[key]:
1937-
logup('Multiple values in implode filter; using first match', {"value": label, "value_used": self.rows[key][label]}, level='info')
1937+
logup('Multiple values in implode filter; using first match', {"value": label, "value_used": self.rows[key][label]})
19381938
logger.error("Multiple values for %s in implode filter; using %s", label, self.rows[key][label])
19391939
else:
19401940
self.rows[key][label] = value
@@ -2256,7 +2256,7 @@ def filter_row(self, row):
22562256
else:
22572257
values[i] = hxl.datatypes.flatten(results, self.use_json)
22582258
except (ValueError, TypeError,) as e:
2259-
logup('Skipping invalid JSON expression', {"expression": str(values[i])}, level='info')
2259+
logup('Skipping invalid JSON expression', {"expression": str(values[i])})
22602260
logger.warning("Skipping invalid JSON expression '%s'", values[i])
22612261

22622262
return values
@@ -2420,7 +2420,7 @@ def sub(self, value):
24202420
@param value: the cell value
24212421
@returns: the new value if changed; False otherwise
24222422
"""
2423-
2423+
24242424
if self.is_regex:
24252425
result = re.subn(self.original, self.replacement, str(value))
24262426
if result[1] > 0:

hxl/util.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
"""
33

44
import logging
5+
import os
56
import sys
67
import structlog
78

8-
def logup(msg, props={}, level="info"):
9+
def logup(msg, props={}, level="notset"):
910
"""
1011
Adds the function name on the fly for the log
1112
@@ -14,6 +15,8 @@ def logup(msg, props={}, level="info"):
1415
props: additional properties for the log
1516
1617
"""
18+
if level == 'notset':
19+
level = os.getenv('LOGGING_LEVEL', 'INFO').lower()
1720
input_logger = structlog.wrap_logger(logging.getLogger('hxl.REMOTE_ACCESS'))
1821
props['function'] = sys._getframe(1).f_code.co_name
1922
levels = {

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
setup(
1313
name='libhxl',
14-
version="5.2",
14+
version="5.2.1",
1515
description='Python support library for the Humanitarian Exchange Language (HXL). See http://hxlstandard.org and https://github.com/HXLStandard/libhxl-python',
1616
long_description=long_description,
1717
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)