Skip to content

Commit cc0bae6

Browse files
committed
test stub
1 parent 4bc70ab commit cc0bae6

File tree

4 files changed

+68
-61
lines changed

4 files changed

+68
-61
lines changed

generate.py

Lines changed: 4 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -51,66 +51,10 @@
5151
)
5252
print(completion_progress[-1])
5353

54-
template = Template(
55-
"""
56-
<html lang="en">
57-
<head>
58-
<title>Python Docs Translation Dashboard</title>
59-
<link rel="stylesheet" href="style.css">
60-
</head>
61-
<body>
62-
<h1>Python Docs Translation Dashboard</h1>
63-
<table>
64-
<thead>
65-
<tr>
66-
<th>language</th>
67-
<th>build</th>
68-
<th><a href="https://plausible.io/data-policy#how-we-count-unique-users-without-cookies">visitors<a/></th>
69-
<th>translators</th>
70-
<th>completion</th>
71-
</tr>
72-
</thead>
73-
<tbody>
74-
{% for language, repo, completion, translators, visitors, in_switcher in completion_progress | sort(attribute=2) | reverse %}
75-
<tr>
76-
{% if repo %}
77-
<td data-label="language">
78-
<a href="https://github.com/{{ repo }}" target="_blank">
79-
{{ language }}
80-
</a>
81-
</td>
82-
<td data-label="build">
83-
{% if in_switcher %}
84-
<a href="https://docs.python.org/{{ language }}/">in switcher</a>
85-
{% else %}
86-
87-
{% endif %}
88-
</td>
89-
<td data-label="visitors">
90-
<a href="https://plausible.io/docs.python.org?filters=((contains,page,(/{{ language }}/)))" target="_blank">
91-
{{ '{:,}'.format(visitors) }}
92-
</a>
93-
</td>
94-
<td data-label="translators">{{ '{:,}'.format(translators) }}</td>
95-
{% else %}
96-
<td data-label="language">{{ language }}</td>
97-
<td data-label="visitors">0</td>
98-
<td data-label="translators">0</td>
99-
{% endif %}
100-
<td data-label="completion">
101-
<div class="progress-bar" style="width: {{ completion | round(2) }}%;">{{ completion | round(2) }}%</div>
102-
</td>
103-
</tr>
104-
{% endfor %}
105-
</tbody>
106-
</table>
107-
<p>Last updated at {{ generation_time.strftime('%A, %d %B %Y, %X %Z') }}.</p>
108-
</body>
109-
</html>
110-
"""
111-
)
54+
template = Template(Path("template.html").read_text())
11255

11356
output = template.render(completion_progress=completion_progress, generation_time=generation_time)
11457

115-
with open("index.html", "w") as file:
116-
file.write(output)
58+
if __file__ == '__main__':
59+
with open("index.html", "w") as file:
60+
file.write(output)

repositories.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import tempfile
21
import pathlib
32
import re
43
from typing import Generator, Optional

template.html

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<html lang="en">
2+
<head>
3+
<title>Python Docs Translation Dashboard</title>
4+
<link rel="stylesheet" href="style.css">
5+
</head>
6+
<body>
7+
<h1>Python Docs Translation Dashboard</h1>
8+
<table>
9+
<thead>
10+
<tr>
11+
<th>language</th>
12+
<th>build</th>
13+
<th><a href="https://plausible.io/data-policy#how-we-count-unique-users-without-cookies">visitors<a/></th>
14+
<th>translators</th>
15+
<th>completion</th>
16+
</tr>
17+
</thead>
18+
<tbody>
19+
{% for language, repo, completion, translators, visitors, in_switcher in completion_progress | sort(attribute=2) | reverse %}
20+
<tr>
21+
{% if repo %}
22+
<td data-label="language">
23+
<a href="https://github.com/{{ repo }}" target="_blank">
24+
{{ language }}
25+
</a>
26+
</td>
27+
<td data-label="build">
28+
{% if in_switcher %}
29+
<a href="https://docs.python.org/{{ language }}/">in switcher</a>
30+
{% else %}
31+
32+
{% endif %}
33+
</td>
34+
<td data-label="visitors">
35+
<a href="https://plausible.io/docs.python.org?filters=((contains,page,(/{{ language }}/)))" target="_blank">
36+
{{ '{:,}'.format(visitors) }}
37+
</a>
38+
</td>
39+
<td data-label="translators">{{ '{:,}'.format(translators) }}</td>
40+
{% else %}
41+
<td data-label="language">{{ language }}</td>
42+
<td data-label="visitors">0</td>
43+
<td data-label="translators">0</td>
44+
{% endif %}
45+
<td data-label="completion">
46+
<div class="progress-bar" style="width: {{ completion | round(2) }}%;">{{ completion | round(2) }}%</div>
47+
</td>
48+
</tr>
49+
{% endfor %}
50+
</tbody>
51+
</table>
52+
<p>Last updated at {{ generation_time.strftime('%A, %d %B %Y, %X %Z') }}.</p>
53+
</body>
54+
</html>

test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from datetime import datetime
2+
from pathlib import Path
3+
4+
from jinja2 import Template
5+
6+
template = Template(Path("template.html").read_text())
7+
output = template.render(completion_progress=(), generation_time=datetime.now())
8+
9+
with open("index.html", "w") as file:
10+
file.write(output)

0 commit comments

Comments
 (0)