Skip to content

Commit f6fd25d

Browse files
committed
Revert branch iteration to 3.6
1 parent 23e2f56 commit f6fd25d

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

completion.py

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json
2-
from collections.abc import Iterator
32
from dataclasses import dataclass
43
from functools import cache
54
from pathlib import Path
@@ -13,28 +12,17 @@
1312

1413

1514
@cache
16-
def latest_branch_from_devguide(devguide_dir: Path) -> str:
15+
def branches_from_devguide(devguide_dir: Path) -> list[str]:
1716
p = devguide_dir.joinpath('include/release-cycle.json')
18-
for branch in (data := json.loads(p.read_text())):
19-
if data[branch]['status'] in ('bugfix', 'security'):
20-
return branch
21-
raise ValueError(f'Supported release not found in {p}')
22-
23-
24-
def iterate_branches(latest: str) -> Iterator[str]:
25-
yield latest
26-
major, minor = latest.split('.')
27-
while int(minor) > 6: # hu has 3.6 branch, hi has 3.7
28-
minor = str(int(minor) - 1)
29-
yield f'{major}.{minor}'
30-
yield 'master'
17+
data = json.loads(p.read_text())
18+
return [
19+
branch for branch in data if data[branch]['status'] in ('bugfix', 'security')
20+
]
3121

3222

3323
def get_completion(clones_dir: str, repo: str) -> tuple[float, 'TranslatorsData']:
3424
clone_path = Path(clones_dir, repo)
35-
for branch in iterate_branches(
36-
latest_branch_from_devguide(Path(clones_dir, 'devguide'))
37-
):
25+
for branch in branches_from_devguide(Path(clones_dir, 'devguide')) + ['master']:
3826
try:
3927
git.Repo.clone_from(
4028
f'https://github.com/{repo}.git', clone_path, branch=branch
@@ -63,8 +51,3 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, 'TranslatorsData'
6351
class TranslatorsData:
6452
number: int
6553
link: str | Literal[False]
66-
67-
68-
if __name__ == '__main__':
69-
for branch in iterate_branches('3.13'):
70-
print(branch)

generate.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import contribute
2323
import build_status
2424
from visitors import get_number_of_visitors
25-
from completion import latest_branch_from_devguide, get_completion, TranslatorsData
25+
from completion import branches_from_devguide, get_completion, TranslatorsData
2626
from repositories import get_languages_and_repos, Language
2727

2828
generation_time = datetime.now(timezone.utc)
@@ -35,11 +35,12 @@ def get_completion_progress() -> Iterator['LanguageProjectData']:
3535
devguide_dir := Path(clones_dir, 'devguide'),
3636
depth=1,
3737
)
38+
latest_branch = branches_from_devguide(devguide_dir)[0]
3839
Repo.clone_from(
3940
'https://github.com/python/cpython.git',
4041
cpython_dir := Path(clones_dir, 'cpython'),
4142
depth=1,
42-
branch=latest_branch_from_devguide(devguide_dir),
43+
branch=latest_branch,
4344
)
4445
subprocess.run(['make', '-C', cpython_dir / 'Doc', 'venv'], check=True)
4546
subprocess.run(['make', '-C', cpython_dir / 'Doc', 'gettext'], check=True)

0 commit comments

Comments
 (0)