|
6 | 6 | # "requests", |
7 | 7 | # ] |
8 | 8 | # /// |
| 9 | +import subprocess |
9 | 10 | from datetime import datetime, timezone |
| 11 | +from pathlib import Path |
10 | 12 | from tempfile import TemporaryDirectory |
11 | 13 |
|
| 14 | +from git import Repo |
12 | 15 | from jinja2 import Template |
13 | 16 |
|
14 | | -import completion |
15 | 17 | import visitors |
| 18 | +from completion import branches_from_devguide, get_completion |
16 | 19 |
|
17 | 20 | completion_progress = [] |
18 | 21 | generation_time = datetime.now(timezone.utc) |
19 | 22 |
|
20 | | -with TemporaryDirectory() as tmpdir: |
| 23 | +with TemporaryDirectory() as clones_dir: |
| 24 | + Repo.clone_from( |
| 25 | + f'https://github.com/python/cpython.git', Path(clones_dir, 'cpython'), depth=1, branch=branches_from_devguide()[0] |
| 26 | + ) |
| 27 | + subprocess.run(['make', '-C', Path(clones_dir, 'cpython/Doc'), 'venv'], check=True) |
| 28 | + subprocess.run(['make', '-C', Path(clones_dir, 'cpython/Doc'), 'gettext'], check=True) |
21 | 29 | for language in ('es', 'fr', 'id', 'it', 'ja', 'ko', 'pl', 'pt-br', 'tr', 'uk', 'zh-cn', 'zh-tw'): |
22 | | - completion_number, branch = completion.get_completion_and_branch(tmpdir, language) |
| 30 | + completion_number = get_completion(clones_dir, language) |
23 | 31 | visitors_number = visitors.get_number_of_visitors(language) |
24 | | - completion_progress.append((language, completion_number, branch, visitors_number)) |
| 32 | + completion_progress.append((language, completion_number, visitors_number)) |
25 | 33 | print(completion_progress[-1]) |
26 | 34 |
|
27 | 35 | template = Template(""" |
28 | 36 | <html lang="en"> |
29 | 37 | <head> |
30 | | -<title>Python Docs Translation Dashboard</title> |
31 | | -<link rel="stylesheet" href="style.css"> |
| 38 | + <title>Python Docs Translation Dashboard</title> |
| 39 | + <link rel="stylesheet" href="style.css"> |
32 | 40 | </head> |
33 | 41 | <body> |
34 | 42 | <h1>Python Docs Translation Dashboard</h1> |
|
37 | 45 | <tr> |
38 | 46 | <th>language</th> |
39 | 47 | <th><a href="https://plausible.io/data-policy#how-we-count-unique-users-without-cookies">visitors<a/></th> |
40 | | - <th>branch</th> |
41 | 48 | <th>completion</th> |
42 | 49 | </tr> |
43 | 50 | </thead> |
44 | 51 | <tbody> |
45 | | -{% for language, completion, branch, visitors in completion_progress | sort(attribute=1) | reverse %} |
| 52 | +{% for language, completion, visitors in completion_progress | sort(attribute=1) | reverse %} |
46 | 53 | <tr> |
47 | 54 | <td data-label="language"> |
48 | 55 | <a href="https://github.com/python/python-docs-{{ language }}" target="_blank"> |
|
54 | 61 | {{ '{:,}'.format(visitors) }} |
55 | 62 | </a> |
56 | 63 | </td> |
57 | | - <td data-label="branch">{{ branch }}</td> |
58 | 64 | <td data-label="completion"> |
59 | 65 | <div class="progress-bar" style="width: {{ completion | round(2) }}%;">{{ completion | round(2) }}%</div> |
60 | 66 | </td> |
|
63 | 69 | </tbody> |
64 | 70 | </table> |
65 | 71 | <p>Last updated at {{ generation_time.strftime('%A, %d %B %Y, %X %Z') }}.</p> |
66 | | -<p>Note that the completion value is based on files available in language Git repository and <a href="https://github.com/m-aciek/pydocs-translation-dashboard/issues/2" target="_blank">may not include</a> e.g. resources which translation hasn't yet started.</p> |
67 | 72 | </body> |
68 | 73 | </html> |
69 | 74 | """) |
|
0 commit comments