diff --git a/completion.py b/completion.py index 9a09f5b10..26ca52746 100644 --- a/completion.py +++ b/completion.py @@ -6,6 +6,9 @@ import git from potodo import potodo +import translators + + @cache def branches_from_devguide(devguide_dir: Path) -> list[str]: p = devguide_dir.joinpath('include/release-cycle.json') @@ -15,20 +18,20 @@ def branches_from_devguide(devguide_dir: Path) -> list[str]: ] -def get_completion(clones_dir: str, repo: str) -> float: +def get_completion(clones_dir: str, repo: str) -> tuple[float, int]: clone_path = Path(clones_dir, repo) for branch in branches_from_devguide(Path(clones_dir, 'devguide')) + ['master']: try: - git.Repo.clone_from( - f'https://github.com/{repo}.git', clone_path, depth=1, branch=branch - ) + git.Repo.clone_from(f'https://github.com/{repo}.git', clone_path, branch=branch) except git.GitCommandError: print(f'failed to clone {repo} {branch}') + translators_number = 0 continue else: + translators_number = translators.get_number(clone_path) break with TemporaryDirectory() as tmpdir: completion = potodo.merge_and_scan_path( clone_path, pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), merge_path=Path(tmpdir), hide_reserved=False, api_url='' ).completion - return completion + return completion, translators_number diff --git a/generate.py b/generate.py index 629a02921..c38bffde2 100644 --- a/generate.py +++ b/generate.py @@ -32,11 +32,11 @@ subprocess.run(['make', '-C', Path(clones_dir, 'cpython/Doc'), 'gettext'], check=True) for language, repo in repositories.get_languages_and_repos(devguide_dir): if repo: - completion_number = get_completion(clones_dir, repo) + completion_number, translators_number = get_completion(clones_dir, repo) visitors_number = visitors.get_number_of_visitors(language) else: completion_number, visitors_number = 0.0, 0 - completion_progress.append((language, repo, completion_number, visitors_number)) + completion_progress.append((language, repo, completion_number, translators_number, visitors_number)) print(completion_progress[-1]) template = Template( @@ -53,11 +53,12 @@