fastoad.io.xml package
Subpackages
Submodules
Module contents
Package for handling XML files
- class fastoad.io.xml.VariableLegacy1XmlFormatter[source]
Bases:
VariableXmlBaseFormatterFormatter for legacy XML format (version “1”)
- class fastoad.io.xml.VariableXmlBaseFormatter(translator: VarXpathTranslator)[source]
Bases:
IVariableIOFormatterCustomizable formatter for variables
User must provide at instantiation a VarXpathTranslator instance that tells how variable names should be converted from/to XPath.
Note: XPath are always considered relatively to the root. Therefore, “foo/bar” should be provided to match following XML structure:
<root> <foo> <bar> "some value" </bar> </foo> </root>
- Parameters:
translator – the VarXpathTranslator instance
- xml_unit_attribute
The XML attribute key for specifying units
- xml_io_attribute
The XML attribute key for specifying I/O status
- class fastoad.io.xml.VariableXmlStandardFormatter[source]
Bases:
VariableXmlBaseFormatterStandard XML formatter for variables
Assuming self.path_separator is defined as
:(default), a variable named likefoo:barwith unitsm/swill be read and written as:<aircraft> <foo> <bar units="m/s" >`42.0</bar> </foo> <aircraft>
When writing outputs of a model, OpenMDAO component hierarchy may be used by defining
self.path_separator = '.' # Discouraged for reading ! self.use_promoted_names = False
This way, a variable like
componentA.subcomponent2.my_varwill be written as:<aircraft> <componentA> <subcomponent2> <my_var units="m/s" >72.0</my_var> </subcomponent2> <componentA> <aircraft>
- property path_separator
The separator that will be used in OpenMDAO variable names to match XML path. Warning: The dot “.” can be used when writing, but not when reading.