CONVERT SERVICE

The CONVERT SERVICE of DATA FORMATS ANALYZER is implemented in the DfaConverter.py file as a DfaConverter module class.

Public Interface

class DfaConverter.ConvertService(verbosity='IWE', dsvDelimiter=', ', refName=None, refVersion=None)

Provides methods to convert data from XML to DSV and back and also to TEX.

Parameters:

  • verbosity: The string specifying verbosity. See details in INIT SERVICE.
  • dsvDelimiter: The string specifying the delimiter for DSV files. Use comma (',') or tab ('\t') for compatibility.
  • refName: The string specifying the reference name. See details in INIT SERVICE.
  • refVersion: The string specifying the reference version. See details in INIT SERVICE.

The values of following class variables can be adjusted in the source code to fit the needs of the specific analysis: alreadyExplainedAbbreviations, outputFormatReviewed, outputFormatDescription and uppercaseLegend.

convertData(filepath=None)

Converts data from XML to DSV and back and also to TEX. Conversion direction is determined by the current filetype extension. Conversion rules, are determined from the current file structure.

Parameters:

  • filepath: The string specifying the full path to the file.

Private Methods

ConvertService._convertXmlToDsvAndTex()

Converts data from XML to DSV and TEX.

ConvertService._convertDsvToXml()

Converts data from DSV to XML.

ConvertService._extractRowContainerLegend(rowContainer, rowCellLegend, rowsLegend)

Extracts information about the processed XML structure. This information is then used as the legend to convert data from XML to DSV. Recursive approach makes it possible to handle more complicated XML tree structures.

Parameters:

  • rowContainer: The lxml.etree.Element with the current container element with data corresponding to one or more row cell (depending on the recursion progress) in the resulting DSV file.
  • rowCellLegend: The string with the legend string in construction (depending on the recursion progress) corresponding to one row cell in the resulting DSV file.
  • rowsLegend: The list of legend strings corresponding to one or more row cell (depending on the recursion progress) in the resulting DSV file. It has the following structure: LIST[STRING].

Returns: The list of legend strings corresponding to one or more row cell (depending on the recursion progress) in the resulting DSV file. It has the following structure: LIST[STRING].

ConvertService._appendRowContainerContent(rowContainer, rowCellLegend, rowCellData)

Appends the content to the container element in order to re-create XML structure according to the legend during the conversion of data from DSV to XML. Recursive approach makes it possible to handle more complicated XML tree structures.

Parameters:

  • rowContainer: The lxml.etree.Element with the current container element with data corresponding to one or more row cell (depending on the recursion progress) in the processed DSV file.
  • rowCellLegend: The list of legend strings to be processed (depending on the recursion progress) in order to re-create the XML structure for the data of one row cell from the processed DSV file. It has the following structure: LIST[STRING].
  • rowCellData: The string with the data of one row cell from the processed DSV file.

Returns: The lxml.etree.Element with the current container element holding data corresponding to one or more row cell (depending on the recursion progress) in the processed DSV file.

Table Of Contents

Previous topic

INIT SERVICE

Next topic

EXTRACT SERVICE