Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on:
schedule:
- cron: '*/30 * * * *'
push:
branches:
- '*'
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/setup-python@main
- uses: astral-sh/setup-uv@main
- uses: actions/checkout@main
- run: uv run generate.py
- run: git config --local user.email [email protected]
- run: git config --local user.name "GitHub Action's update job"
- run: git add .
- run: git commit -m 'Update progress values'
- uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
9 changes: 6 additions & 3 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# "jinja2",
# ]
# ///
from datetime import datetime, timezone
from pathlib import Path
from shutil import rmtree
from tempfile import TemporaryDirectory
Expand All @@ -13,14 +14,15 @@
from jinja2 import Template

completion_progress = []
generation_time = datetime.now(timezone.utc)

with TemporaryDirectory() as tmpdir:
for language in ('es', 'fr', 'id', 'it', 'ja', 'ko', 'pl', 'pt-br', 'tr', 'uk', 'zh-cn', 'zh-tw'):
clone_path = Path(tmpdir, language)
for branch in ('3.13', '3.12', '3.11', '3.10', '3.9'):
try:
Repo.clone_from(f'git@github.com:python/python-docs-{language}.git', clone_path, depth=1, branch=branch)
except GitCommandError as e:
Repo.clone_from(f'https://github.com/python/python-docs-{language}.git', clone_path, depth=1, branch=branch)
except GitCommandError:
print(f'failed to clone {language} {branch}')
continue
try:
Expand Down Expand Up @@ -58,11 +60,12 @@
{% endfor %}
</tbody>
</table>
<p>Last updated at {{ generation_time.strftime('%x %X %Z') }}.</p>
</body>
</html>
""")

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

with open("index.html", "w") as file:
file.write(output)
9 changes: 5 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1>Python Docs Translation Dashboard</h1>
<td data-label="language">es</td>
<td data-label="branch">3.12</td>
<td data-label="completion">
<div class="progress-bar" style="width: 91.12%;">91.12%</div>
<div class="progress-bar" style="width: 91.69%;">91.69%</div>
</td>
</tr>

Expand All @@ -40,23 +40,23 @@ <h1>Python Docs Translation Dashboard</h1>
<td data-label="language">uk</td>
<td data-label="branch">3.12</td>
<td data-label="completion">
<div class="progress-bar" style="width: 68.76%;">68.76%</div>
<div class="progress-bar" style="width: 68.32%;">68.32%</div>
</td>
</tr>

<tr>
<td data-label="language">ja</td>
<td data-label="branch">3.11</td>
<td data-label="completion">
<div class="progress-bar" style="width: 68.08%;">68.08%</div>
<div class="progress-bar" style="width: 68.11%;">68.11%</div>
</td>
</tr>

<tr>
<td data-label="language">pt-br</td>
<td data-label="branch">3.13</td>
<td data-label="completion">
<div class="progress-bar" style="width: 62.71%;">62.71%</div>
<div class="progress-bar" style="width: 62.82%;">62.82%</div>
</td>
</tr>

Expand Down Expand Up @@ -110,5 +110,6 @@ <h1>Python Docs Translation Dashboard</h1>

</tbody>
</table>
<p>Last updated at 11/19/24 08:59:14 UTC.</p>
</body>
</html>
Loading