66import git
77import urllib3
88from potodo import potodo
9+ from potodo .arguments_handling import Filters
910
1011
1112@cache
@@ -19,7 +20,9 @@ def branches_from_peps() -> list[str]:
1920 ]
2021
2122
22- def get_completion (clones_dir : str , repo : str ) -> tuple [float , str , float ]:
23+ def get_completion (
24+ clones_dir : str , repo : str
25+ ) -> tuple [float , float , str , float , float ]:
2326 clone_path = Path (clones_dir , 'translations' , repo )
2427 for branch in branches_from_peps () + ['master' , 'main' ]:
2528 try :
@@ -39,12 +42,18 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, str, float]:
3942 print (f'success: { branch } { repo } : clone or switch' )
4043 break
4144 path_for_merge = Path (clones_dir , 'rebased_translations' , repo )
42- completion = potodo .merge_and_scan_paths (
45+ project = potodo .merge_and_scan_paths (
4346 [clone_path ],
4447 pot_path = Path (clones_dir , 'cpython/Doc/build/gettext' ),
45- merge_path = path_for_merge ,
48+ merge_path = path_for_merge . absolute () ,
4649 api_url = '' ,
47- ).completion
50+ )
51+ completion = project .completion
52+ core_excludes = ['**/*' , '!bugs.po' , '!tutorial/*' , '!library/functions.po' ]
53+ project .filter (
54+ filters = Filters (False , True , 0 , 100 , False , False ), exclude = core_excludes
55+ )
56+ core_completion = project .completion
4857
4958 if completion :
5059 # Fetch commit from before 30 days ago and checkout
@@ -54,19 +63,28 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, str, float]:
5463 )
5564 except StopIteration :
5665 month_ago_completion = 0.0
66+ month_ago_core_completion = 0.0
5767 else :
5868 clone_repo .git .checkout (commit .hexsha )
5969 with TemporaryDirectory () as tmpdir :
60- month_ago_completion = potodo .merge_and_scan_paths (
70+ project = potodo .merge_and_scan_paths (
6171 [clone_path ],
6272 pot_path = Path (clones_dir , 'cpython/Doc/build/gettext' ),
6373 merge_path = Path (tmpdir ),
6474 api_url = '' ,
65- ).completion
75+ )
76+ month_ago_completion = project .completion
77+ project .filter (
78+ filters = Filters (False , True , 0 , 100 , False , False ),
79+ exclude = core_excludes ,
80+ )
81+ month_ago_core_completion = project .completion
6682 clone_repo .git .checkout (branch ) # restore the original state
6783 else :
6884 month_ago_completion = 0.0
85+ month_ago_core_completion = 0.0
6986
7087 change = completion - month_ago_completion
88+ core_change = core_completion - month_ago_core_completion
7189
72- return completion , branch , change
90+ return core_completion , completion , branch , core_change , change
0 commit comments