From 6f0f673c653384c8f3b7c4e4d0390347b7552d27 Mon Sep 17 00:00:00 2001 From: Antoine Wecxsteen Date: Sat, 2 Jan 2021 23:08:11 +0100 Subject: [PATCH 1/2] Add more info to folders. --- potodo/potodo.py | 3 +++ tests/test_potodo.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/potodo/potodo.py b/potodo/potodo.py index 379df85..f694dd5 100644 --- a/potodo/potodo.py +++ b/potodo/potodo.py @@ -55,6 +55,9 @@ def add_dir_stats( dict( name=f"{directory_name}/", percent_translated=float(f"{folder_completion:.2f}"), + entries=sum(file["entries"] for file in buffer), + fuzzies=sum(file["fuzzies"] for file in buffer), + translated=sum(file["translated"] for file in buffer), files=buffer, ) ) diff --git a/tests/test_potodo.py b/tests/test_potodo.py index 631e397..416003c 100644 --- a/tests/test_potodo.py +++ b/tests/test_potodo.py @@ -29,6 +29,7 @@ def test_txt_output(capsys): exec_potodo(json_format=False, **config) captured = capsys.readouterr() + assert "# repository" in captured.out assert "file1.po" in captured.out assert "file2.po" in captured.out assert "# folder" in captured.out @@ -36,6 +37,7 @@ def test_txt_output(capsys): assert "1 fuzzy" in captured.out assert "2 fuzzy" not in captured.out assert "excluded" not in captured.out + assert "# TOTAL" in captured.out def test_output(capsys): @@ -46,6 +48,9 @@ def test_output(capsys): { "name": "folder/", "percent_translated": 0.0, + "entries": 1, + "fuzzies": 0, + "translated": 0, "files": [ { "name": "folder/file3", @@ -62,6 +67,9 @@ def test_output(capsys): { "name": f"{REPO_DIR}/", "percent_translated": 25.0, + "entries": 4, + "fuzzies": 1, + "translated": 1, "files": [ { "name": f"{REPO_DIR}/file1", From 48d1698fd737414f66f1b4e246ee647dd23b7f0a Mon Sep 17 00:00:00 2001 From: Antoine Wecxsteen Date: Sun, 3 Jan 2021 11:21:38 +0100 Subject: [PATCH 2/2] Details in folder displayed in output. --- potodo/potodo.py | 7 ++++--- tests/test_potodo_default_args.py | 12 ++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/potodo/potodo.py b/potodo/potodo.py index f694dd5..3ed95f7 100644 --- a/potodo/potodo.py +++ b/potodo/potodo.py @@ -35,8 +35,9 @@ def print_dir_stats( # placed it means it doesnt need to be printed folder_completion = 100 * folder_stats["translated"] / folder_stats["total"] - - print(f"\n\n# {directory_name} ({folder_completion:.2f}% done)\n") + print( + f"\n\n# {directory_name} {folder_stats['translated']:3d} / {folder_stats['total']:3d} ({folder_completion:5.1f}% translated)\n" + ) print("\n".join(buffer)) logging.debug("Not printing directory %s", directory_name) @@ -142,7 +143,7 @@ def non_interactive_output( else: if total_entries != 0: total_completion = 100 * total_translated / total_entries - print(f"\n\n# TOTAL ({total_completion:.2f}% done)\n") + print(f"\n\n# TOTAL ({total_completion:.2f}% translated)\n") def exec_potodo( diff --git a/tests/test_potodo_default_args.py b/tests/test_potodo_default_args.py index 205e2b6..d8d5c22 100644 --- a/tests/test_potodo_default_args.py +++ b/tests/test_potodo_default_args.py @@ -30,15 +30,15 @@ class TestPotodoCLI: def test_potodo_no_args(self): output = check_output("potodo").decode("utf-8") - assert "# excluded (50.00% done)" in output - assert "# folder (33.33% done)" in output + assert "# excluded 1 / 2 (50.00% translated)" in output + assert "# folder 1 / 3 (33.33% translated)" in output assert ( "- excluded.po 1 / 2 ( 50.0% translated)" in output ) assert ( "- file3.po 0 / 1 ( 0.0% translated)" in output ) - assert "# repository (25.00% done)" in output + assert "# repository 1 / 4 (25.00% translated)" in output assert ( "- file1.po 1 / 3 ( 33.0% translated), 1 fuzzy" in output @@ -52,12 +52,12 @@ def test_potodo_exclude(self): ["potodo", "-e", self.excluded_1, self.excluded_2] ).decode("utf-8") assert output == output_short - assert "# excluded (50.00% done)" not in output + assert "# excluded 1 / 2 (50.00% translated)" in output assert ( "- excluded.po 1 / 2 ( 50.0% translated)" not in output ) - assert "# repository (25.00% done)" in output + assert "# repository 1 / 4 (25.00% translated)" in output assert ( "- file1.po 1 / 3 ( 33.0% translated), 1 fuzzy" in output @@ -110,7 +110,7 @@ def test_potodo_counts(self): not in output ) assert "- file4.po 1 to do" in output - assert "# repository (25.00% done)" in output + assert "# repository 1 / 4 (25.00% translated)" in output assert ( "- file1.po 2 to do, including 1 fuzzies." in output )