NetMsgs.NetMsgsXmlParser
index
/prj/rnr-sdk/netmsgs/nmPython/modules/NetMsgs/NetMsgsXmlParser.py

NetMsgs XML parser module.

 
Modules
       
xml.parsers.expat
NetMsgs.NetMsgsBase
os
time

 
Classes
       
NetMsgsXmlParser
exceptions.Exception(exceptions.BaseException)
NetMsgsXmlParserError

 
class NetMsgsXmlParser
    RoadNarrows Net Messages XML Parser Class.
 
The NetMsgsXmlParser class parses a RoadNarrows netmsgs XML specification.
The parsed information is available to the calling program.
 
XML Syntax:
<netmsgs>
  <meta>
  ...
  </meta>
  <field_types>
  ...
  </field_types>
  <msg_types>
  ...
  </msg_types>
</netmsgs>
 
  Methods defined here:
Debug(self, level, *args)
Print debugging info.
 
Parameters:
  level   - Debugging level.
  *args   - List of debug message arguments.
Error(self, *args)
Raise XML parser error on general error.
 
Parameters:
  *args   - List of error message arguments.
ExpatError(self, *args)
Raise XML parser error on expat parser error.
 
Parameters:
  *args   - List of error message arguments.
GetDBData(self, dbkey)
Get database entry.
 
Parameters:
  dbkey   - Parsed data key.
 
Return Value:
  Database data.
GetDBDict(self)
Get full database dictionary.
 
Return Value:
  Dictionary.
GetDBList(self)
Get the full list of database keys.
 
Return Value:
  List of pnames.
GetElemList(self)
Get the full list of XML element names.
 
The list is in preferred output order.
 
Return Value:
  List of element names.
GetParentElem(self)
Get the parent element of current top element.
GetParentElemName(self)
Get the parent element's name of current top element.
GetXMLFileName(self)
Get the NetMsgs XML file name.
 
Return Value:
  String.
IsSimple(self, ftype)
Returns True (False) is field type is (not) simple.
 
Parameters:
  ftype   - (Derived) field type.
Parse(self)
Parse the Xml XML data listed in the current file.
ParseFile(self, filename)
Parse the Xml XML data specified in the given file.
 
Parameters:
  filename    - README XML file name.
PopElem(self)
Pop element from stack of elements.
PopFieldDict(self)
Pop field definitions dictionary from top of stack.
PostParse(self)
Post-parse configuration and validation.
PrettyPrintDB(self, comment=None)
Pretty print database dictionary of parsed XML values.
PrettyPrintDBFieldDef(self, indent, fname, fielddef)
Pretty print database fielddef sub-dictionary of parsed XML values.
 
Parameters:
  indent      - Indentation.
  fields      - mDB[...]['fields'] sub-dictionary.
PrettyPrintDBFields(self, indent, fields)
Pretty print database fields sub-dictionary of parsed XML values.
 
Parameters:
  indent      - Indentation.
  fields      - mDB[...]['fields'] sub-dictionary.
PrettyPrintVal(self, indent, name, val)
Pretty print value.
 
Parameters:
  indent    - Indentation
  name      - name
  value     - dictionary or other value type.
PushElem(self, elem, attrs)
Push element name on stack of elements.
 
Parameters:
  elem    - Element name.
  attrs   - Element attributes.
PushFieldDict(self, fielddict)
Push field definitions dictionary on top of stack."
 
Parameters:
  fielddict    - Field definitions dictionary.
Reset(self)
Reset the XML parser.
WriteXml(self, fp, comment=None)
Create a Product XML file from the given parsed or set data.
 
Parameters:
  fp          - Opened for writing file pointer.
  comment     - Comment string.
WriteXmlFile(self, filename, comment=None)
Create a Product XML file from the given parsed or set data.
 
Parameters:
  filename    - Product XML file name.
  comment     - Comment string.
WriteXmlTree(self, fp, level, elemParent, elemList)
Write out XML tree.
 
Parameters:
  fp        - Opened for writing file pointer.
  level     - element level (depth)
  elemList  - element level (depth)
XmlCbEndFTypeDef(self, elem, data, **attrs)
End-Of-Element callback for the 'ftypedef' element.
 
The associated XML parser database entries are updated with the current
parsed data.
 
Parameters:
  elem    - Element name.
  data    - Element data.
  attrs   - Element attributes.
XmlCbEndFieldDef(self, elem, data, **attrs)
End-Of-Element callback for the 'fielddef' element.
 
The associated XML parser database entries are updated with the current
parsed data.
 
Parameters:
  elem    - Element name.
  data    - Element data.
  attrs   - Element attributes.
XmlCbEndFieldDefConst(self, elem, data, **attrs)
End-Of-Element callback for the 'fielddef' 'const' sub-element.
 
The associated XML parser database entries are updated with the current
parsed data.
 
Parameters:
  elem    - Element name.
  attrs   - Element attributes.
XmlCbEndFieldDefMinMax(self, elem, data, **attrs)
End-Of-Element callback for the 'fielddef' min/max limits sub-elements.
 
The associated XML parser database entries are updated with the current
parsed data.
 
Parameters:
  elem    - Element name.
  data    - Element data.
  attrs   - Element attributes.
XmlCbEndMetaData(self, elem, data, **attrs)
End Callback for the 'meta' general data sub-elements.
 
The associated XML parser database entries are updated with the current
parsed data.
 
Parameters:
  elem    - Element name.
  data    - Element data.
  attrs   - Element attributes.
XmlCbEndMetaLang(self, elem, data, **attrs)
End-Of-Element callback for the 'meta' language-specific data
sub-elements.
 
The associated XML parser database entries are updated with the current
parsed data.
 
Parameters:
  elem    - Element name.
  data    - Element data.
  attrs   - Element attributes.
XmlCbEndMsgDef(self, elem, data, **attrs)
End-Of-Element callback for the 'msgdef' element.
 
The associated XML parser database entries are updated with the current
parsed data.
 
Parameters:
  elem    - Element name.
  data    - Element data.
  attrs   - Element attributes.
XmlCbEndSection(self, elem, data, **attrs)
End-Of-Element callback for a major XML section.
 
Parameters:
  elem    - Element name.
  data    - Element data.
  attrs   - Element attributes.
XmlCbStartFTypeDef(self, elem, **attrs)
Start-Of-Element callback for the 'ftypedef' element.
 
The associated XML parser database entries are updated with the current
parsed data.
 
Parameters:
  elem    - Element name.
  attrs   - Element attributes.
XmlCbStartFieldDef(self, elem, **attrs)
Start-Of-Element callback for the 'fielddef' element.
 
The associated XML parser database entries are updated with the current
parsed data.
 
Parameters:
  elem    - Element name.
  attrs   - Element attributes.
XmlCbStartMsgDef(self, elem, **attrs)
Start-Of-Element callback for the 'msgdef' element.
 
The associated XML parser database entries are updated with the current
parsed data.
 
Parameters:
  elem    - Element name.
  attrs   - Element attributes.
XmlCbStartNetMsgs(self, elem, **attrs)
Start-Of-Element callback for the 'netmsgs' top element.
 
Parameters:
  elem    - Element name.
  attrs   - Element attributes.
XmlCbStartPad(self, elem, **attrs)
Start-Of-Element callback for the 'pad' element.
 
The associated XML parser database entries are updated with the current
parsed data.
 
Parameters:
  elem    - Element name.
  attrs   - Element attributes.
XmlCbStartSection(self, elem, **attrs)
Start-Of-Element callback for a major XML section.
 
Parameters:
  elem    - Element name.
  attrs   - Element attributes.
XmlChkTokenDispo(self, elem, dispo)
Parse and validate XML element 'disposition' attribute.
 
Parameters:
  elem    - Element name value.
  dispo   - Element attribute value.
 
Return:
  dispo
XmlChkTokenFType(self, elem, ftype)
Parse and validate XML element ftype attribute.
 
Parameters:
  elem    - Element name value.
  ftype   - Element ftype raw attribute value.
 
Return:
  Returns ('vector', vtype) if vector.
  Returns (ftype, None) otherwise.
XmlChkTokenId(self, elem, attr, id)
Parse and validate XML element id attribute.
 
Parameters:
  elem    - Element name value.
  attr    - Element attribute name.
  id      - Element attribute value.
 
Return:
  id
XmlDebug(self, level, *args)
Print XML debugging info.
 
Parameters:
  level   - Debugging level.
  *args   - List of debug message arguments.
XmlError(self, *args)
Raise XML parser error on XML syntax or semanitc error.
 
Parameters:
  *args   - List of warning message arguments.
XmlFieldDefContext(self)
Get current field definition context.
 
Return:
  Returns (pid, pinfo) - the parent element id/name and parent
  (implicit) field attributes.
XmlHandlerCharData(self, data)
XML Parser handler called back for each line of element data.
 
Parameters:
  data    - Unstructured element data.
XmlHandlerComment(self, comment)
XML Parser handler called back for each end of a comment block.
 
Parameters:
  comment - Comment text sans '<!-' and '-->'.
XmlHandlerDTD(self, context, base, systemId, publicId)
XML Parser handler called back at start of DTD processing.
XmlHandlerElementDecl(self, name, model)
XML Parser handler called back at start of DTD ELEMENT processing.
XmlHandlerEndElem(self, elem)
XML Parser handler called back at end of element.
 
The associated database element(s) are set with the converted data.
The data must conform to the requirements of the element.
 
Parameters:
  elem    - Element name.
XmlHandlerEntityDecl(entityName, is_parameter_entity, value, base, systemId, publicId, notationName)
XML Parser handler called back at start of DTD ENTITY processing.
XmlHandlerStartDoctype(self, doctypeName, systemId, publicId, has_internal_subset)
XML Parser handler called back at start of DOCTYPE processing.
XmlHandlerStartElem(self, elem, attrs)
XML Parser handler called back at start of element.
 
Parameters:
  elem    - Element name.
  attrs   - Dictionary of element attributes.
XmlTokenFType(self, token)
Parse XML element ftype token.
 
Parameters:
  token  - Element ftype token raw value.
 
Return:
  Returns ('vector', vtype) if vector.
  Returns (ftype, None) otherwise.
XmlWarning(self, *args)
Print XML syntax warning.
 
Parameters:
  *args   - List of warning message arguments.
__getitem__(self, dbkey)
x.__getitem__(dbkey) <==> x[dbkey]
 
Get database entry.
__init__(self, filename=None, debug=0, **kwargs)
Initialize NetMsgsXmlParser instance.
 
Parameters:
  filename    - XML file name.
  debug       - Set debugging level: 0 == off, 1, 2, 3.
  kwargs      - Optional XML overrides:
                  encoding  - Message encoding. One of itv flat.
                  endian    - Byte order. One of big little native.
                  ns        - Message namespace (name prefix).
                  brief     - Brief description.
__setitem__(self, dbkey, val)
x.__setitem__(dbkey, val) <==> x[dbkey]=val
 
Set new or overwrite existing database entry.

 
class NetMsgsXmlParserError(exceptions.Exception)
    XML Parser Exception Class.
 
 
Method resolution order:
NetMsgsXmlParserError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Methods defined here:
__init__(self, msg='XML Parser Error')
Raise exception.
 
Parameters:
  msg    - Exception message string.

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message