index — testreport @ master

html testreport generator out of text input

create_report.py (view raw)

 1from parse_data import parse_data
 2from jinja2 import Environment, FileSystemLoader
 3from argparse import ArgumentParser
 4from sys import argv
 5
 6parser = ArgumentParser(prog=argv[0])
 7parser.add_argument('input_path', help="input to parse")
 8parser.add_argument('-o', '--out', help="output file (default: report.html)", default="report.html")
 9parser.add_argument('-c', '--csv', help="Flag: the input file is a csv and NOT an executable", action='store_true')
10
11args = parser.parse_args()
12
13data, stats = parse_data(args.input_path, args.csv)
14
15# Load the template from the current directory
16env = Environment(loader=FileSystemLoader('.'))
17template = env.get_template("template.html")
18
19# Render the template with data
20html_output = template.render(data=data, stats=stats)
21
22# Save the generated HTML to a file
23with open(args.out, "w", encoding="utf-8") as f:
24    f.write(html_output)
25
26print(f"Report generated: {args.out}")