sbsparser module
Module sbsparser provides the class SBSParser which allows the deserialization of a .sbs file into a SBSDocument
All derived SBSObject have a parse function with the same signature than on the base class
SBSObject: common_interface.SBSObject.parse()
- class sbsparser.FileTypeEnum
Bases:
objectEnumeration of different document types SBSParser can read
.. py:attribute:: FileTypeEnum.SBS
- module:
sbsparser
- value:
0
- SBSAR = 1
- SBSPRJ = 3
- SBSPRS = 2
- class sbsparser.SBSParser(aFileAbsPath, aContext, aFileType=0)
Bases:
objectClass used to provide useful functions when parsing a .sbs (=xml) file
- getAllSBSElementsIn(aContext, aDirAbsPath, aXmlNode, aTagName, aSBSClass)
Search for all children with the given tag under the given xmlNode, and parse them recursively
<xmlNode><tagname>…</tagname><tagname>…</tagname>…</xmlNode>
- Returns:
The list of SBS objects corresponding to the given tag, or [] if not found
- getAllSBSElementsInMulti(aContext, aDirAbsPath, aXmlNode, aTagConstructorDict)
Search for all children with various names under the given xmlNode, and parse them recursively using the parse function from the tag constructor dict
<xmlNode><tagnameA>…</tagnameA><tagnameB>…</tagnameB>…</xmlNode>
- Returns:
The list of SBS objects corresponding to the given tag, or [] if not found
- getAllXmlElementsUnder(aXmlElement, aTagName)
Get the xmlElements with the given tagName under the given xmlElement:
<xmlElement><tagname>…</tagname><tagname>…</tagname>…</xmlElement>
- Returns:
A list of xmlElement
- getRootNode()
Get the .sbs file root node :return: element of type etree
- getSBSElementIn(aContext, aDirAbsPath, aXmlNode, aTagName, aSBSClass)
Search for first child with the given tag under the given xmlNode, and parse them recursively
<xmlNode><tagname>…</tagname><tagname>…</tagname>…</xmlNode>
- Returns:
SBS object corresponding to the given tag, or None if not found
- getSBSElementList(aContext, aDirAbsPath, aXmlNode, aTagName, aChildTagName, aSBSClass)
Search for all children with the tag childtagname under the tag tagname under the given xmlNode, and parse them recursively:
<xmlNode><tagname><childtagname>…</childtagname><childtagname>…</childtagname>… </tagname></xmlNode>
- Returns:
The list of SBS objects corresponding to the tag childtagname, or [] if not found
- getXmlElementAttribValue(aXmlElement, aAttributeName)
Get the value of the attribute with the given name on the given xmlElement:
<xmlElement attributeName=””/>
- Returns:
The attribute value
- getXmlElementVAttribValue(aXmlElementParent, aChildName)
Get the value of the attribute ‘v’ on the given child element under xmlElementParent:
<xmlElementParent><childName v=””/> … </xmlElementParent>
- Returns:
The attribute value
- getXmlFilePathValue(aXmlElementParent, aChildName)
Get the value of the attribute ‘v’ on the given child element under xmlElementParent: <xmlElementParent><childName v=””/> … </xmlElementParent> Then convert attribute path given as a relative path. :return: The attribute value
- isValid()
Check if the package is valid
- Returns:
True if the package is valid, False otherwise
- parseSBSNode(aContext, aDirAbsPath, aXmlNode, aTagName, aSBSClass)
Search for a child node with the given tag in the given XmlNode, and parse the corresponding SBS object
- Returns:
the SBSObject parsed, or None if not found
- parseSBSNodeFromXmlNode(aContext, aDirAbsPath, aXmlNode, aSBSClass)
Search for a child node with the given tag in the given XmlNode, and parse the corresponding SBS object
- Returns:
the SBSObject parsed, or None if not found