Skip to content

Commit bf79bca

Browse files
author
Victor
committed
Merge branch 'carze-master'
2 parents 1417d42 + 1ead7c8 commit bf79bca

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

cutlass/VisitAttribute.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,9 @@ def load_visit_attr(attrib_data):
332332
attrib.tags = attrib_data['meta']['tags']
333333

334334
# Handle optional fields
335+
attrib_metadata = attrib_data['meta']
335336
for (propname, spec) in VisitAttribute.__dict.iteritems():
337+
_cls = spec[0]
336338
section = spec[1]
337339

338340
## We need to handle any DiseaseMeta props separately here
@@ -341,26 +343,23 @@ def load_visit_attr(attrib_data):
341343

342344
module_logger.debug("In section %s", section)
343345

344-
# Couple special cases to handle here.
346+
# Handle any special cases that we need too.
345347
if (section == "excercise" or
346348
(propname.startswith('breakfast') or propname.startswith('lunch') or
347349
propname.startswith('dinner'))):
348350
(propbase, propkey) = propname.split('_', 1)
349351

350-
propval = attrib_data['meta'].get(section, {}).get(propbase, {}).get(propkey)
352+
propval = attrib_metadata.get(section, {}).get(propbase, {}).get(propkey)
353+
elif propname == "sixtym_gluc":
354+
propval = attrib_metadata.get(section, {}).get('60m_gluc')
355+
elif propname == "thirtym_gluc":
356+
propval = attrib_metadata.get(section, {}).get('30m_gluc')
351357
else:
352-
if propname == "sixtym_gluc":
353-
propname = "60m_gluc"
354-
elif propname == "thirtym_gluc":
355-
propname = "30m_gluc"
356-
357-
propval = attrib_data['meta'].get(section, {}).get(propname)
358-
359-
module_logger.debug("Prop: %s, value: %s", propname, propval)
358+
propval = attrib_metadata.get(section, {}).get(propname)
360359

361360
if propval:
362361
module_logger.debug("Setting prop %s to %s", propname, propval)
363-
setattr(attrib, propname, propval)
362+
setattr(attrib, propname, _cls(propval))
364363

365364
# If any of the DiseaseMeta props exist we can handle them now
366365
if attrib_data['meta'].get('disease'):
@@ -376,6 +375,7 @@ def load_visit_attr(attrib_data):
376375
map(lambda key: setattr(attrib, key, disease_props.get(key)), disease_props.keys())
377376

378377
module_logger.debug("Returning loaded %s.", __name__)
378+
379379
return attrib
380380

381381
@staticmethod

0 commit comments

Comments
 (0)