Skip to content
Merged
Changes from 1 commit
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
12 changes: 5 additions & 7 deletions completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@
from functools import cache
from pathlib import Path
from tempfile import TemporaryDirectory
from urllib.request import urlopen
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This project already requires both requests (via Sphinx) and urllib3 (directly), perhaps we should use one of the two?


import git
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]:
with urlopen('https://peps.python.org/api/release-cycle.json') as in_file:
data = json.loads(in_file.read().decode('utf-8'))
return [
branch for branch in data if data[branch]['status'] in ('bugfix', 'security')
]


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
Expand Down
Loading