Skip to content
Snippets Groups Projects
Commit 7c72afde authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

BF: Handle present but empty elements

parent e3f6c86f
No related branches found
No related tags found
No related merge requests found
......@@ -521,28 +521,19 @@ class AtlasDescription(object):
if self.atlasType == 'statistic':
statistic = header.find('statistic')
units = header.find('units')
lower = header.find('lower')
upper = header.find('upper')
precision = header.find('precision')
if statistic is None: statistic = ''
else: statistic = statistic.text.strip()
if units is None: units = ''
else: units = units.text.strip()
if lower is None: lower = 0
else: lower = float(lower.text.strip())
if upper is None: upper = 100
else: upper = float(upper.text.strip())
if precision is None: precision = 2
else: precision = float(precision.text.strip())
self.statistic = statistic
self.units = units
self.lower = lower
self.upper = upper
self.precision = precision
fields = ['statistic', 'units', 'lower', 'upper', 'precision']
values = {}
for field in fields:
elem = header.find(field)
if elem is not None and elem.text is not None:
values[field] = elem.text.strip()
self.statistic = values.get('statistic', '')
self.units = values.get('units', '')
self.lower = float(values.get('lower', 0))
self.upper = float(values.get('upper', 100))
self.precision = int( values.get('precision', 2))
elif self.atlasType == 'probabilistic':
self.statistic = ''
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment