Created
September 14, 2016 16:13
-
-
Save ehermes/6aefc20a8689de1ebfa48012a2c3f5cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
elif elem.tag == 'parameters': | |
to_bool = lambda b: True if b == 'T' else False | |
to_type = {'int': int, | |
'logical': to_bool, | |
'string': str, | |
'float': float, | |
} | |
for par in elem.getiterator(): | |
if par.tag in ['v', 'i']: | |
name = par.attrib['name'].lower() | |
text = par.text | |
if text is None: | |
text = '' | |
# Floats don't have a 'type' attrib | |
my_type = to_type[par.attrib.get('type', 'float')] | |
if par.tag == 'v': | |
parameters[name] = map(my_type, text.split()) | |
else: | |
parameters[name] = my_type(text.strip()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment