From 0a14a6baec87883bfb129220f0fec631acc3bc18 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Mon, 10 Nov 2025 21:39:16 +0100 Subject: [PATCH 1/2] try to filter --- completion.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/completion.py b/completion.py index e8484e34e..95a481dc5 100644 --- a/completion.py +++ b/completion.py @@ -33,12 +33,14 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, str, float]: else: break path_for_merge = Path(clones_dir, 'rebased_translations', repo) - completion = potodo.merge_and_scan_paths( + project = potodo.merge_and_scan_paths( [clone_path], pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), merge_path=path_for_merge, api_url='', - ).completion + ) + completion = project.completion + project.filter(lambda file: file.path in (Path('bugs.po'), Path('tutorial'))) if completion: # Fetch commit from before 30 days ago and checkout From 74eda6b4398bd99e72fc67d8177593635116dbee Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Sun, 30 Nov 2025 05:04:01 +0100 Subject: [PATCH 2/2] Add core completion data in the backend script --- completion.py | 25 ++++++++++++++++++++----- generate.py | 12 +++++++++--- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/completion.py b/completion.py index 95a481dc5..53c5af845 100644 --- a/completion.py +++ b/completion.py @@ -6,6 +6,7 @@ import git import urllib3 from potodo import potodo +from potodo.arguments_handling import Filters @cache @@ -19,7 +20,9 @@ def branches_from_peps() -> list[str]: ] -def get_completion(clones_dir: str, repo: str) -> tuple[float, str, float]: +def get_completion( + clones_dir: str, repo: str +) -> tuple[float, float, str, float, float]: clone_path = Path(clones_dir, 'translations', repo) for branch in branches_from_peps() + ['master', 'main']: try: @@ -40,7 +43,11 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, str, float]: api_url='', ) completion = project.completion - project.filter(lambda file: file.path in (Path('bugs.po'), Path('tutorial'))) + project.filter( + filters=Filters(False, True, 0, 100, False, False), + exclude=['**/*', '!bugs.po', '!tutorial/', '!library/functions.po'], + ) + core_completion = project.completion if completion: # Fetch commit from before 30 days ago and checkout @@ -53,16 +60,24 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, str, float]: else: clone_repo.git.checkout(commit.hexsha) with TemporaryDirectory() as tmpdir: - month_ago_completion = potodo.merge_and_scan_paths( + project = potodo.merge_and_scan_paths( [clone_path], pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), merge_path=Path(tmpdir), api_url='', - ).completion + ) + month_ago_completion = project.completion + project.filter( + filters=Filters(False, True, 0, 100, False, False), + exclude=['**/*', '!bugs.po', '!tutorial/', '!library/functions.po'], + ) + month_ago_core_completion = project.completion clone_repo.git.checkout(branch) # restore the original state else: month_ago_completion = 0.0 + month_ago_core_completion = 0.0 change = completion - month_ago_completion + core_change = core_completion - month_ago_core_completion - return completion, branch, change + return core_completion, completion, branch, core_change, change diff --git a/generate.py b/generate.py index 2a8292b56..5f345013a 100644 --- a/generate.py +++ b/generate.py @@ -59,17 +59,21 @@ def get_project_data( ) -> 'LanguageProjectData': built = language.code in languages_built if repo: - completion, branch, change = get_completion(clones_dir, repo) + core_complation, completion, branch, core_change, change = get_completion( + clones_dir, repo + ) else: - completion = 0.0 - change = 0.0 + core_complation = completion = 0.0 + core_change = change = 0.0 branch = '' return LanguageProjectData( language, repo, branch, + core_complation, completion, + core_change, change, built, translated_name=languages_built.get(language.code, ''), @@ -83,7 +87,9 @@ class LanguageProjectData: language: Language repository: str | None branch: str + core_completion: float completion: float + core_change: float change: float built: bool translated_name: str