parameters: ()
docstring: Generate useful data from a coverage report.
docstring_summary: Generate useful data from a coverage report.
docstring_tokens: Generate useful data from a coverage report .
function: def main():
    """Generate useful data from a coverage report."""
    # Parse args.
    parser = argparse.ArgumentParser()
    parser.add_argument('--report', help='input file; an llvm coverage report.',
                        required=True)
    parser.add_argument('--nanobench', help='output file for nanobench data.')
    parser.add_argument(
        '--key', metavar='key_or_value', nargs='+',
        help='key/value pairs identifying this bot.')
    parser.add_argument(
        '--properties', metavar='key_or_value', nargs='+',
        help='key/value pairs representing properties of this build.')
    parser.add_argument('--linebyline',
                        help='output file for line-by-line JSON data.')
    args = parser.parse_args()
  
    if args.nanobench and not (args.key and args.properties):
      raise Exception('--key and --properties are required with --nanobench')
  
    with open(args.report) as f:
      report = f.read()
  
    line_by_line = _get_per_file_per_line_coverage(report)
  
    if args.linebyline:
      with open(args.linebyline, 'w') as f:
        json.dump(line_by_line, f)
  
    if args.nanobench:
      # Parse the key and properties for use in the nanobench JSON output.
      key = _parse_key_value(args.key)
      properties = _parse_key_value(args.properties)
  
      # Get per-file summaries.
      per_file = _get_per_file_summaries(line_by_line)
  
      # Write results.
      format_results = _nanobench_json(per_file, properties, key)
      with open(args.nanobench, 'w') as f:
        json.dump(format_results, f)
function_tokens: def main ( ) : # Parse args. parser = argparse . ArgumentParser ( ) parser . add_argument ( '--report' , help = 'input file; an llvm coverage report.' , required = True ) parser . add_argument ( '--nanobench' , help = 'output file for nanobench data.' ) parser . add_argument ( '--key' , metavar = 'key_or_value' , nargs = '+' , help = 'key/value pairs identifying this bot.' ) parser . add_argument ( '--properties' , metavar = 'key_or_value' , nargs = '+' , help = 'key/value pairs representing properties of this build.' ) parser . add_argument ( '--linebyline' , help = 'output file for line-by-line JSON data.' ) args = parser . parse_args ( ) if args . nanobench and not ( args . key and args . properties ) : raise Exception ( '--key and --properties are required with --nanobench' ) with open ( args . report ) as f : report = f . read ( ) line_by_line = _get_per_file_per_line_coverage ( report ) if args . linebyline : with open ( args . linebyline , 'w' ) as f : json . dump ( line_by_line , f ) if args . nanobench : # Parse the key and properties for use in the nanobench JSON output. key = _parse_key_value ( args . key ) properties = _parse_key_value ( args . properties ) # Get per-file summaries. per_file = _get_per_file_summaries ( line_by_line ) # Write results. format_results = _nanobench_json ( per_file , properties , key ) with open ( args . nanobench , 'w' ) as f : json . dump ( format_results , f )