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): ...@@ -521,28 +521,19 @@ class AtlasDescription(object):
if self.atlasType == 'statistic': if self.atlasType == 'statistic':
statistic = header.find('statistic') fields = ['statistic', 'units', 'lower', 'upper', 'precision']
units = header.find('units') values = {}
lower = header.find('lower')
upper = header.find('upper') for field in fields:
precision = header.find('precision') elem = header.find(field)
if elem is not None and elem.text is not None:
if statistic is None: statistic = '' values[field] = elem.text.strip()
else: statistic = statistic.text.strip()
if units is None: units = '' self.statistic = values.get('statistic', '')
else: units = units.text.strip() self.units = values.get('units', '')
if lower is None: lower = 0 self.lower = float(values.get('lower', 0))
else: lower = float(lower.text.strip()) self.upper = float(values.get('upper', 100))
if upper is None: upper = 100 self.precision = int( values.get('precision', 2))
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
elif self.atlasType == 'probabilistic': elif self.atlasType == 'probabilistic':
self.statistic = '' 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