.. _operation2modelchains-py:
####################
operationmapping.py
####################
**************************************
class OperationMappingDef(XmlObject):
**************************************
def __init__(self, typedef, schema, xmldata):
=============================================
Initializes the operation mapping by processing the schema and xml documents::
>>> from simo.builder.importers.operation2modelchains import \
... OperationMappingDef
>>> tdf = open('../../simulator/xml/schemas/Typedefs_SIMO.xsd')
>>> typedef = tdf.read()
>>> tdf.close()
>>> sf = open('../../simulator/xml/schemas/operation2modelchains.xsd')
>>> schema = sf.read()
>>> sf.close()
>>> xml = u'''
...
...
... thinning
...
...
... Calculate thinning limits
... Forced low thinning
...
...
...
...
... first_thinning
...
...
... Calculate thinning limits
...
...
... '''
>>> class Lexicon(object):
... def level_ind(self, level):
... return 1
... def variable_ind(self, level, var, active=False):
... return (None, None)
>>> omd = OperationMappingDef(typedef)
>>> omd.schema = schema
>>> try:
... omd.xml = ('testxml', xml, Lexicon())
... except ValueError, e:
... print e
>>> omd.errors
set([])
>>> omd.xml['testxml'][:23]
u'>> om = omd.obj['testxml']
>>> from pprint import pprint
>>> pprint(om.operation_mapping)
{'first_thinning': ['Calculate thinning limits'],
'thinning': ['Calculate thinning limits', 'Forced low thinning']}
>>> om.forced_op_chains
set(['Calculate thinning limits', 'Forced low thinning'])
>>> omd.errors
set([])
>>> omd.warnings
[]