Table Of Contents

Previous topic

lexiconlevel.py

Next topic

aggregationmodel.py

This Page

lexiconvariable.py

class LexiconVariable(object):

Class for defining a single variable in the lexicon

def __init__(self, ns, elem, validator):

Parse an xml snippet containing variable definition and construct a variable instance:

>>> from simo.builder.lexicon.lexiconvariable import LexiconVariable
>>> from lxml import etree
>>> xml = u'''<variable>
...             <name>assortment</name>
...             <unit>NA</unit>
...             <min_value>1</min_value>
...             <max_value>2</max_value>
...             <description>Timber assortment</description>
...             <values>
...                 <enum>
...                     <value>1</value>
...                     <description>Log</description>
...                 </enum>
...                 <enum>
...                     <value>2</value>
...                     <description>Pulp</description>
...                 </enum>
...             </values>
...         </variable>'''
>>> elem = etree.fromstring(xml)
>>> lvar = LexiconVariable('', elem, None)
>>> lvar.name
'assortment'
>>> lvar.unit
'NA'
>>> lvar.minimum
1.0
>>> lvar.maximum
2.0
>>> lvar.desc
'Timber assortment'
>>> lvar.values
{1.0: 'Log', 2.0: 'Pulp'}