|
4 | 4 | # "potodo", |
5 | 5 | # "jinja2", |
6 | 6 | # "requests", |
| 7 | +# "docutils", |
7 | 8 | # ] |
8 | 9 | # /// |
9 | 10 | import subprocess |
|
14 | 15 | from git import Repo |
15 | 16 | from jinja2 import Template |
16 | 17 |
|
| 18 | +import repositories |
17 | 19 | import visitors |
18 | 20 | from completion import branches_from_devguide, get_completion |
19 | 21 |
|
20 | 22 | completion_progress = [] |
21 | 23 | generation_time = datetime.now(timezone.utc) |
22 | 24 |
|
23 | 25 | with TemporaryDirectory() as clones_dir: |
| 26 | + Repo.clone_from(f'https://github.com/python/devguide.git', devguide_dir := Path(clones_dir, 'devguide'), depth=1) |
| 27 | + latest_branch = branches_from_devguide(devguide_dir)[0] |
24 | 28 | Repo.clone_from( |
25 | | - f'https://github.com/python/cpython.git', Path(clones_dir, 'cpython'), depth=1, branch=branches_from_devguide()[0] |
| 29 | + f'https://github.com/python/cpython.git', Path(clones_dir, 'cpython'), depth=1, branch=latest_branch |
26 | 30 | ) |
27 | 31 | subprocess.run(['make', '-C', Path(clones_dir, 'cpython/Doc'), 'venv'], check=True) |
28 | 32 | subprocess.run(['make', '-C', Path(clones_dir, 'cpython/Doc'), 'gettext'], check=True) |
29 | | - for language in ('es', 'fr', 'id', 'it', 'ja', 'ko', 'pl', 'pt-br', 'tr', 'uk', 'zh-cn', 'zh-tw'): |
30 | | - completion_number = get_completion(clones_dir, language) |
31 | | - visitors_number = visitors.get_number_of_visitors(language) |
32 | | - completion_progress.append((language, completion_number, visitors_number)) |
| 33 | + for language, repo in repositories.get_languages_and_repos(devguide_dir): |
| 34 | + if repo: |
| 35 | + completion_number = get_completion(clones_dir, repo) |
| 36 | + visitors_number = visitors.get_number_of_visitors(language) |
| 37 | + else: |
| 38 | + completion_number, visitors_number = 0.0, 0 |
| 39 | + completion_progress.append((language, repo, completion_number, visitors_number)) |
33 | 40 | print(completion_progress[-1]) |
34 | 41 |
|
35 | | -template = Template(""" |
| 42 | +template = Template( |
| 43 | + """ |
36 | 44 | <html lang="en"> |
37 | 45 | <head> |
38 | 46 | <title>Python Docs Translation Dashboard</title> |
|
49 | 57 | </tr> |
50 | 58 | </thead> |
51 | 59 | <tbody> |
52 | | -{% for language, completion, visitors in completion_progress | sort(attribute=1) | reverse %} |
| 60 | +{% for language, repo, completion, visitors in completion_progress | sort(attribute=2) | reverse %} |
53 | 61 | <tr> |
| 62 | + {% if repo %} |
54 | 63 | <td data-label="language"> |
55 | | - <a href="https://github.com/python/python-docs-{{ language }}" target="_blank"> |
| 64 | + <a href="https://github.com/{{ repo }}" target="_blank"> |
56 | 65 | {{ language }} |
57 | 66 | </a> |
58 | 67 | </td> |
|
61 | 70 | {{ '{:,}'.format(visitors) }} |
62 | 71 | </a> |
63 | 72 | </td> |
| 73 | + {% else %} |
| 74 | + <td data-label="language">{{ language }}</td> |
| 75 | + <td data-label="visitors">0</td> |
| 76 | + {% endif %} |
64 | 77 | <td data-label="completion"> |
65 | 78 | <div class="progress-bar" style="width: {{ completion | round(2) }}%;">{{ completion | round(2) }}%</div> |
66 | 79 | </td> |
|
71 | 84 | <p>Last updated at {{ generation_time.strftime('%A, %d %B %Y, %X %Z') }}.</p> |
72 | 85 | </body> |
73 | 86 | </html> |
74 | | -""") |
| 87 | +""" |
| 88 | +) |
75 | 89 |
|
76 | 90 | output = template.render(completion_progress=completion_progress, generation_time=generation_time) |
77 | 91 |
|
|
0 commit comments