.. _messagetranslationtable-py:
##########################
messagetranslationtable.py
##########################
**********************************
class MsgTransTableDef(XmlObject):
**********************************
Provides log message translations.
def __init__(self, typedef, schema, xmldata):
=============================================
Initializes the translation by processing the schema and xml documents for the message translation definitions.
>>> from simo.builder.translation.messagetranslationtable import MsgTransTableDef
>>> tdf = open('../../simulator/xml/schemas/Typedefs_SIMO.xsd')
>>> typedef = tdf.read()
>>> tdf.close()
>>> sf = open('../../simulator/xml/schemas/message_translation_table.xsd')
>>> schema = sf.read()
>>> sf.close()
>>> xml = u'''
...
...
...
... Variable (.+)
...
... Muuttuja $1
... Och det samma på svenska
...
...
...
...
...
... something
...
... jotakin
... någonting
... etwas
...
...
...
...
... '''
>>> mtd = MsgTransTableDef(typedef)
>>> mtd.schema = schema
>>> mtd.xml = ('testxml', xml, None)
>>> mtd.xml['testxml'][:26]
u'>> mt = mtd.obj['testxml']
>>> mt.translation['test']['optimization'][0] # doctest: +ELLIPSIS
[(<_sre.SRE_Pattern object at 0x...>, 'something')]
>>> mt.translation['test']['optimization'][1]
{'something': {'fi': u'jotakin', 'de': u'etwas', 'se': u'n\xc3\xa5gonting'}}
****************************
class MsgTransTable(object):
****************************
Log message translation definitions
Attributes:
- translation: dictionary keyed by log message level, has
- dictionary keyed by log message origin, has
- a tuple of:
- list of tuples of: regular expression patters (index 0) matching the original message (index)
- dictionary keyed by the original message has
- dictionary keyed by the language code has the translated message as data
def __init__(self, ns, elem):
=============================
Parses the XML data into a class instance