Skip to content

Commit 4faf155

Browse files
committed
Merge branch 'main' into check-against-latest
# Conflicts: # completion.py
2 parents 6067937 + e5b7dba commit 4faf155

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

completion.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
1-
import shutil
1+
from functools import cache
22
from pathlib import Path
33
from tempfile import TemporaryDirectory
44

55
import git
66
from potodo import potodo
7+
import requests
8+
9+
@cache
10+
def branches_from_devguide() -> list[str]:
11+
r = requests.get(
12+
"https://raw.githubusercontent.com/"
13+
"python/devguide/main/include/release-cycle.json",
14+
timeout=10,
15+
)
16+
data = r.json()
17+
return [
18+
branch for branch in data if data[branch]["status"] in ("bugfix", "security")
19+
]
720

821

922
def get_completion(clones_dir: str, language: str) -> float:
1023
clone_path = Path(clones_dir, language)
11-
for branch in ('3.13', '3.12', '3.11', '3.10', '3.9'):
24+
25+
for branch in branches_from_devguide():
1226
try:
1327
git.Repo.clone_from(
1428
f'https://github.com/python/python-docs-{language}.git', clone_path, depth=1, branch=branch

generate.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@
1414
from git import Repo
1515
from jinja2 import Template
1616

17-
import completion
1817
import visitors
18+
from completion import branches_from_devguide, get_completion
1919

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

2323
with TemporaryDirectory() as clones_dir:
24-
Repo.clone_from(f'https://github.com/python/cpython.git', Path(clones_dir, 'cpython'), depth=1, branch='3.13')
24+
Repo.clone_from(
25+
f'https://github.com/python/cpython.git', Path(clones_dir, 'cpython'), depth=1, branch=branches_from_devguide()[0]
26+
)
2527
subprocess.run(['make', '-C', Path(clones_dir, 'cpython/Doc'), 'venv'], check=True)
2628
subprocess.run(['make', '-C', Path(clones_dir, 'cpython/Doc'), 'gettext'], check=True)
2729
for language in ('es', 'fr', 'id', 'it', 'ja', 'ko', 'pl', 'pt-br', 'tr', 'uk', 'zh-cn', 'zh-tw'):
28-
completion_number = completion.get_completion(clones_dir, language)
30+
completion_number = get_completion(clones_dir, language)
2931
visitors_number = visitors.get_number_of_visitors(language)
3032
completion_progress.append((language, completion_number, visitors_number))
3133
print(completion_progress[-1])
@@ -55,7 +57,7 @@
5557
</a>
5658
</td>
5759
<td data-label="visitors">
58-
<a href="https://https://plausible.io/docs.python.org?filters=((contains,page,(/{{ language }}/)))" target="_blank">
60+
<a href="https://plausible.io/docs.python.org?filters=((contains,page,(/{{ language }}/)))" target="_blank">
5961
{{ '{:,}'.format(visitors) }}
6062
</a>
6163
</td>

0 commit comments

Comments
 (0)