tartiflette/pullrequests/publish.py

45 lines
1.2 KiB
Python
Raw Permalink Normal View History

2017-03-08 14:24:58 +01:00
#!/usr/bin/python3
import os
import json
from jinja2 import Template
from ansi2html import Ansi2HTMLConverter
from ansi2html.style import get_styles
###############################################################################
2017-03-24 18:01:05 +01:00
output_dir = "../www/"
2017-03-08 14:24:58 +01:00
2017-03-24 18:01:05 +01:00
template_path = os.path.join(output_dir,"template_pullrequests.html")
output_path = os.path.join(output_dir,"pullrequests.html")
2017-03-08 14:24:58 +01:00
summary_path = os.path.join("./", "summary.json")
###############################################################################
conv = Ansi2HTMLConverter()
shell_css = "\n".join(map(str, get_styles(conv.dark_bg, conv.scheme)))
def shell_to_html(shell):
return conv.convert(shell, False)
###############################################################################
if __name__ == '__main__':
# Fetch the list of all reports, sorted in reverse-chronological order
2017-03-08 17:31:22 +01:00
summary = json.load(open(summary_path))
2017-03-08 14:24:58 +01:00
# Generate the output using the template
template = open(template_path, "r").read()
t = Template(template)
2017-03-08 17:31:22 +01:00
result = t.render(data=summary, convert=shell_to_html, shell_css=shell_css)
2017-03-08 14:24:58 +01:00
open(output_path, "w").write(result)
print("Done.")