.. _lexicontranslationtable-py: ########################## lexicontranslationtable.py ########################## ************************************** class LexiconTransTableDef(XmlObject): ************************************** Provides lexicon data level and variable name translations for log messages. def __init__(self, typedef, schema, xmldata): ============================================= Initializes the translation by processing the schema and xml documents for the lexicon translation definitions:: >>> from simo.builder.translation.lexicontranslationtable import LexiconTransTableDef >>> tdf = open('../../simulator/xml/schemas/Typedefs_SIMO.xsd') >>> typedef = tdf.read() >>> tdf.close() >>> sf = open('../../simulator/xml/schemas/lexicon_translation_table.xsd') >>> schema = sf.read() >>> sf.close() >>> xml = u''' ... ... ... comp_unit ... ... kuvio ... nånting ... ... ... ... ... ... DEVEL_CLASS ... ... kehitysluokka ... ... ... ... ... Open regeneration site ... ... aukea ... ... ... ... Young seedling stand (less than 1,3 m) ... ... pieni taimikko ... ... ... ... ... ... ... INVENTORY_METHOD ... ... inventointitapa ... så ska det vara ... ... ... ... ... some method ... ... joku inventointi ... ju inventering ja ... ... ... ... ... ... ... ''' >>> ltd = LexiconTransTableDef(typedef) >>> ltd.schema = schema >>> ltd.xml = ('testxml',xml, None) >>> ltd.xml['testxml'][:26] u'>> lt = ltd.obj['testxml'] >>> lt.level_table["'comp_unit'"]['fi'] u"'kuvio'" The data level variable table is similar dictionary yielding unicode translation strings:: >>> lt.var_table["'DEVEL_CLASS'"]['fi'] u"'kehitysluokka'" ******************************** class LexiconTransTable(object): ******************************** Lexicon translation definitions. Attributes: - level_table: dictionary, level name as key, dictionary of language code: level name translation as data - var_table: dictionary, variable as key, dictionary of language code: variable name translation as data def __init__(self, ns, elem): ============================= Parses the XML data into a class instance