Skip to content
Open
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
14 changes: 10 additions & 4 deletions completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, str, float]:
clone_path = Path(clones_dir, 'translations', repo)
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
)
if not clone_path.exists():
clone_repo = git.Repo.clone_from(
f'https://github.com/{repo}.git', clone_path, branch=branch
)
else:
(clone_repo := git.Repo(clone_path)).git.fetch()
clone_repo.git.switch(branch)
clone_repo.git.pull()
except git.GitCommandError:
print(f'failed to clone {repo} {branch}')
print(f'failure: {branch} {repo}: clone or switch, continuing')
branch = ''
continue
else:
print(f'success: {branch} {repo}: clone or switch')
break
path_for_merge = Path(clones_dir, 'rebased_translations', repo)
completion = potodo.merge_and_scan_paths(
Expand Down
34 changes: 21 additions & 13 deletions generate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import json
import concurrent.futures
import itertools
Expand All @@ -20,20 +22,26 @@
generation_time = datetime.now(timezone.utc)


def get_completion_progress() -> Iterator['LanguageProjectData']:
def get_completion_progress() -> Iterator[LanguageProjectData]:
clones_dir = Path('clones')
Repo.clone_from(
'https://github.com/python/devguide.git',
devguide_dir := Path(clones_dir, 'devguide'),
depth=1,
)
if not (devguide_dir := Path(clones_dir, 'devguide')).exists():
Repo.clone_from('https://github.com/python/devguide.git', devguide_dir, depth=1)
else:
Repo(devguide_dir).git.pull()
latest_branch = branches_from_peps()[0]
Repo.clone_from(
'https://github.com/python/cpython.git',
cpython_dir := Path(clones_dir, 'cpython'),
depth=1,
branch=latest_branch,
)
if not (cpython_dir := Path(clones_dir, 'cpython')).exists():
Repo.clone_from(
'https://github.com/python/cpython.git',
cpython_dir,
depth=1,
branch=latest_branch,
)
else:
(cpython_repo := Repo(cpython_dir)).git.fetch()
cpython_repo.git.switch(latest_branch)
cpython_repo.git.pull()

subprocess.run(['make', '-C', cpython_dir / 'Doc', 'clean'], check=True)
subprocess.run(['make', '-C', cpython_dir / 'Doc', 'venv'], check=True)
subprocess.run(['make', '-C', cpython_dir / 'Doc', 'gettext'], check=True)

Expand All @@ -56,7 +64,7 @@ def get_project_data(
repo: str | None,
languages_built: dict[str, str],
clones_dir: str,
) -> 'LanguageProjectData':
) -> LanguageProjectData:
built = language.code in languages_built
if repo:
completion, branch, change = get_completion(clones_dir, repo)
Expand Down
Loading