about summary refs log tree commit diff stats
path: root/create_report.py
blob: d123609de86c80cb3580d0a339e0baf189c1f6f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from parse_data import parse_data
from jinja2 import Environment, FileSystemLoader
from argparse import ArgumentParser
from sys import argv

parser = ArgumentParser(prog=argv[0])
parser.add_argument('input_path', help="input to parse")
parser.add_argument('-o', '--out', help="output file (default: report.html)", default="report.html")
parser.add_argument('-c', '--csv', help="Flag: the input file is a csv and NOT an executable", action='store_true')

args = parser.parse_args()

data, stats = parse_data(args.input_path, args.csv)

# Load the template from the current directory
env = Environment(loader=FileSystemLoader('.'))
template = env.get_template("template.html")

# Render the template with data
html_output = template.render(data=data, stats=stats)

# Save the generated HTML to a file
with open(args.out, "w", encoding="utf-8") as f:
    f.write(html_output)

print(f"Report generated: {args.out}")