1
0
Fork 0
mirror of https://github.com/Findus23/matomo4-plugins.git synced 2024-09-19 15:23:43 +02:00
matomo4-plugins/main.py

24 lines
740 B
Python
Raw Normal View History

2020-08-31 20:38:05 +02:00
from datetime import datetime
2020-08-31 20:27:19 +02:00
from pathlib import Path
from subprocess import run
from jinja2 import Template, StrictUndefined
from api import get_all_plugins
template_file = Path("template.html")
output_html_file = Path("public/index.html")
sp = run(["git", "rev-parse", "--verify", "HEAD"], capture_output=True)
commit = sp.stdout.decode().strip()
2020-08-31 20:42:49 +02:00
plugins, supported, unsupported = get_all_plugins()
2020-08-31 20:38:05 +02:00
template = Template(template_file.read_text(), autoescape=True, undefined=StrictUndefined)
2020-08-31 20:27:19 +02:00
output_html_file.write_text(template.render({
2020-08-31 20:42:49 +02:00
"plugins": plugins,
2020-08-31 20:38:05 +02:00
"commit": commit,
2020-08-31 20:42:49 +02:00
"now": datetime.now(),
"supported": supported,
"unsupported": unsupported,
"fraction": supported / (supported + unsupported) * 100
2020-08-31 20:27:19 +02:00
}))