diff --git a/completion.py b/completion.py index 9cbb21392..6a661329d 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: @@ -39,12 +42,18 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, str, float]: print(f'success: {branch} {repo}: clone or switch') 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, + merge_path=path_for_merge.absolute(), api_url='', - ).completion + ) + completion = project.completion + core_excludes = ['**/*', '!bugs.po', '!tutorial/*', '!library/functions.po'] + project.filter( + filters=Filters(False, True, 0, 100, False, False), exclude=core_excludes + ) + core_completion = project.completion if completion: # 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]: ) except StopIteration: month_ago_completion = 0.0 + month_ago_core_completion = 0.0 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=core_excludes, + ) + 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 7aaa1e9ea..be49be7e7 100644 --- a/generate.py +++ b/generate.py @@ -67,17 +67,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, ''), @@ -90,7 +94,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 diff --git a/src/style.css b/src/style.css index 2c38d6e1e..14bd515f5 100644 --- a/src/style.css +++ b/src/style.css @@ -105,21 +105,25 @@ ul.links-row li:not(:first-child)::before { /* ------------------------------ Index ------------------------------------- */ -.progress-bar-container { - border-radius: 4px; - border: 1px solid rgba(0, 0, 0, 0.2); +.progress { + font-size: 1rem; height: 20px; - overflow: hidden; - position: relative; } -.progress-bar { - display: inline-block; - color: white; - height: 100%; - line-height: 20px; - border-top-left-radius: 3px; - border-bottom-left-radius: 3px; +.outer-label { + display: none; + padding-left: .5em; + color: var(--text-color); + background-color: transparent; +} + +.progress-bar.low { + color: transparent; + user-select: none; +} + +.progress-bar.low + .outer-label { + display: flex; } /* ------------------------------ Metadata ---------------------------------- */ diff --git a/templates/base.html.jinja b/templates/base.html.jinja index 7f271c110..70d7504c0 100644 --- a/templates/base.html.jinja +++ b/templates/base.html.jinja @@ -8,14 +8,16 @@
Completion: {{ '{:.2f}%'.format(project.completion) }}
-30-day progress: {{ '{:.2f}%'.format(project.change) }}