fastoad.io.xml.variable_io_base module¶
Defines how OpenMDAO variables are serialized to XML using a conversion table
-
class
fastoad.io.xml.variable_io_base.
VariableXmlBaseFormatter
(translator: fastoad.io.xml.translator.VarXpathTranslator)[source]¶ Bases:
fastoad.io.formatter.IVariableIOFormatter
Customizable 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
-
read_variables
(data_source: Union[str, IO]) → fastoad.openmdao.variables.VariableList[source]¶ Reads variables from provided data source file.
- Parameters
data_source –
- Returns
a list of Variable instance
-
set_translator
(translator: fastoad.io.xml.translator.VarXpathTranslator)[source]¶ Sets the VarXpathTranslator() instance that rules how OpenMDAO variable are matched to XML Path.
- Parameters
translator –
-
unit_translation
¶ Used for converting read units in units recognized by OpenMDAO Dict keys can use regular expressions.
-
write_variables
(data_source: Union[str, IO], variables: fastoad.openmdao.variables.VariableList)[source]¶ Writes variables to defined data source file.
- Parameters
data_source –
variables –