camayoc.tests.qpc.cli.csv_report_parsing module

Helper functions for parsing csv reports.

camayoc.tests.qpc.cli.csv_report_parsing.extract_key_value_lines(input_lines, line_pairs, delim=', ')[source]

Extract multiple line pairs into list of dictionaries.

Parameters:
  • input_lines – a list of csv line strings.
  • line_pairs – A list of tuples containg the index pairs for the lines to be used as the key/value pairs of each dictionary (ex: [(0,1), (3,4)] ).
  • delim – the delimiter to split the lines with (defaults to ‘,’).
camayoc.tests.qpc.cli.csv_report_parsing.normalize_csv_report(f, header_range, header_lines, report_type='deployments')[source]

Extract and normalize csv report to match the returned JSON report.

Parameters:
  • f – A file object for the csv
  • header_range – An int specifing the range that the head extends into the csv file.
  • header_lines – A list of tuples containg the index pairs for the lines to be used as the key/value pairs of each header info dictionary (ex: [(0,1), (3,4)] ).
  • report_type – A string that defines what type of report object to return, ‘deployments’ or ‘detail’. Defaults to ‘deployments’.
camayoc.tests.qpc.cli.csv_report_parsing.normalize_deployments_report(header_info, reader)[source]

Normalize report info into a deployments report.

Takes information from report_info dict, and reader and returns a deployments report.

Parameters:
  • header_info – A list of dictonaries, which each dictonary containing the information of a header.
  • reader – A DictReader containing the parsed content (remainder after header section) of a report.
camayoc.tests.qpc.cli.csv_report_parsing.normalize_detail_report(header_info, reader)[source]

Normalize report info into a detail report.

Takes information from report_info dict, and reader and returns a detail format report

Parameters:
  • header_info – A list of dictonaries, which each dictonary containing the information of a header.
  • reader – A DictReader containing the parsed content (remainder after header section) of a report.
camayoc.tests.qpc.cli.csv_report_parsing.zip_line_pairs(input_lines, key_ind, value_ind, delim=', ')[source]

Take a list of csv strings, and combine 2 of them into a dictionary.

Parameters:
  • input_lines – a list of csv lines
  • key_ind – the index value for which line in input_lines should be used for the keys of the dictionary.
  • value_ind – the index value for which line in input_lines should be used for the values of the dictionary.
  • delim – the delimiter to split the lines with (defaults to ‘,’).