|
51 | 51 | ) |
52 | 52 | print(completion_progress[-1]) |
53 | 53 |
|
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()) |
112 | 55 |
|
113 | 56 | output = template.render(completion_progress=completion_progress, generation_time=generation_time) |
114 | 57 |
|
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) |
0 commit comments