yaml_tools.ymltoxml module

Transform mavlink-style xml files to/from xml and yaml. Note yaml format uses custom markup for XML attributes and comments. See the xmltodict docs for details.

yaml_tools.ymltoxml.get_input_type(filepath, prog_opts)[source]

Check filename extension, open and process by file type, return type flag and data from appropriate loader.

Parameters:
  • filepath – filename as Path obj

  • prog_opts (dict) – configuration options

Return tuple:

destination type flag and file data

Raises:

FileTypeError – if the input file is not xml or yml

yaml_tools.ymltoxml.main(argv=None)[source]

Transform YAML to XML and XML to YAML.

yaml_tools.ymltoxml.process_inputs(filepath, prog_opts, outpath=None, debug=False)[source]

Handle file arguments and process them.

Parameters:
  • filepath – filename as Path obj

  • prog_opts (dict) – configuration options

  • outpath (str) – output file name/path if provided

  • debug – enable extra processing info

Return None:

Handlles FileTypeError:

input file is not xml or yml

yaml_tools.ymltoxml.transform_data(payload, prog_opts, to_xml=True)[source]

Produce output data from dict-ish object using direction.

Parameters:
  • payload – input from xmltodict or yaml loader.

  • prog_opts (dict) – configuration options

  • to_xml (bool) – output direction, ie, if to_xml is True then output is XML.

Return res:

output file data in specified format.