Skip to content
This repository has been archived by the owner on Mar 11, 2023. It is now read-only.

Infos. supplémentaires dans les dossiers. #111

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions potodo/potodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -55,6 +56,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,
)
)
Expand Down Expand Up @@ -139,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(
Expand Down
8 changes: 8 additions & 0 deletions tests/test_potodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ 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
assert "file3.po" in captured.out
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):
Expand All @@ -46,6 +48,9 @@ def test_output(capsys):
{
"name": "folder/",
"percent_translated": 0.0,
"entries": 1,
"fuzzies": 0,
"translated": 0,
"files": [
{
"name": "folder/file3",
Expand All @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions tests/test_potodo_default_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
)
Expand Down