diff --git a/completion.py b/completion.py index 39abae9ac..16f3ada55 100644 --- a/completion.py +++ b/completion.py @@ -4,13 +4,14 @@ from tempfile import TemporaryDirectory import git +import urllib3 from potodo import potodo @cache -def branches_from_devguide(devguide_dir: Path) -> list[str]: - p = devguide_dir.joinpath('include/release-cycle.json') - data = json.loads(p.read_text()) +def branches_from_peps() -> list[str]: + resp = urllib3.request('GET', 'https://peps.python.org/api/release-cycle.json') + data = json.loads(resp.data) return [ branch for branch in data if data[branch]['status'] in ('bugfix', 'security') ] @@ -18,10 +19,7 @@ def branches_from_devguide(devguide_dir: Path) -> list[str]: def get_completion(clones_dir: str, repo: str) -> tuple[float, str, float]: clone_path = Path(clones_dir, 'translations', repo) - for branch in branches_from_devguide(Path(clones_dir, 'devguide')) + [ - 'master', - 'main', - ]: + for branch in branches_from_peps() + ['master', 'main']: try: clone_repo = git.Repo.clone_from( f'https://github.com/{repo}.git', clone_path, branch=branch diff --git a/generate.py b/generate.py index ba699a1ec..2a8292b56 100644 --- a/generate.py +++ b/generate.py @@ -14,7 +14,7 @@ import translated_names import contribute -from completion import branches_from_devguide, get_completion +from completion import branches_from_peps, get_completion from repositories import Language, get_languages_and_repos generation_time = datetime.now(timezone.utc) @@ -27,7 +27,7 @@ def get_completion_progress() -> Iterator['LanguageProjectData']: devguide_dir := Path(clones_dir, 'devguide'), depth=1, ) - latest_branch = branches_from_devguide(devguide_dir)[0] + latest_branch = branches_from_peps()[0] Repo.clone_from( 'https://github.com/python/cpython.git', cpython_dir := Path(clones_dir, 'cpython'),