From cc0bae665b46137f9a6063f3d1ae96e259bf9e26 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Mon, 30 Dec 2024 11:14:33 +0100 Subject: [PATCH] test stub --- generate.py | 64 ++++--------------------------------------------- repositories.py | 1 - template.html | 54 +++++++++++++++++++++++++++++++++++++++++ test.py | 10 ++++++++ 4 files changed, 68 insertions(+), 61 deletions(-) create mode 100644 template.html create mode 100644 test.py diff --git a/generate.py b/generate.py index cf875048d..77520fea7 100644 --- a/generate.py +++ b/generate.py @@ -51,66 +51,10 @@ ) print(completion_progress[-1]) -template = Template( - """ - - - Python Docs Translation Dashboard - - - -

Python Docs Translation Dashboard

- - - - - - - - - - - -{% for language, repo, completion, translators, visitors, in_switcher in completion_progress | sort(attribute=2) | reverse %} - - {% if repo %} - - - - - {% else %} - - - - {% endif %} - - -{% endfor %} - -
languagebuildvisitorstranslatorscompletion
- - {{ language }} - - - {% if in_switcher %} - in switcher - {% else %} - ✗ - {% endif %} - - - {{ '{:,}'.format(visitors) }} - - {{ '{:,}'.format(translators) }}{{ language }}00 -
{{ completion | round(2) }}%
-
-

Last updated at {{ generation_time.strftime('%A, %d %B %Y, %X %Z') }}.

- - -""" -) +template = Template(Path("template.html").read_text()) output = template.render(completion_progress=completion_progress, generation_time=generation_time) -with open("index.html", "w") as file: - file.write(output) +if __file__ == '__main__': + with open("index.html", "w") as file: + file.write(output) diff --git a/repositories.py b/repositories.py index c7e09323c..edaf3089d 100644 --- a/repositories.py +++ b/repositories.py @@ -1,4 +1,3 @@ -import tempfile import pathlib import re from typing import Generator, Optional diff --git a/template.html b/template.html new file mode 100644 index 000000000..e0ab19fb5 --- /dev/null +++ b/template.html @@ -0,0 +1,54 @@ + + + Python Docs Translation Dashboard + + + +

Python Docs Translation Dashboard

+ + + + + + + + + + + +{% for language, repo, completion, translators, visitors, in_switcher in completion_progress | sort(attribute=2) | reverse %} + + {% if repo %} + + + + + {% else %} + + + + {% endif %} + + +{% endfor %} + +
languagebuildvisitorstranslatorscompletion
+ + {{ language }} + + + {% if in_switcher %} + in switcher + {% else %} + ✗ + {% endif %} + + + {{ '{:,}'.format(visitors) }} + + {{ '{:,}'.format(translators) }}{{ language }}00 +
{{ completion | round(2) }}%
+
+

Last updated at {{ generation_time.strftime('%A, %d %B %Y, %X %Z') }}.

+ + \ No newline at end of file diff --git a/test.py b/test.py new file mode 100644 index 000000000..98d7db27d --- /dev/null +++ b/test.py @@ -0,0 +1,10 @@ +from datetime import datetime +from pathlib import Path + +from jinja2 import Template + +template = Template(Path("template.html").read_text()) +output = template.render(completion_progress=(), generation_time=datetime.now()) + +with open("index.html", "w") as file: + file.write(output)