forked from AFPy/potodo
Deduplicate code.
This commit is contained in:
parent
f2fd1ffcc1
commit
37737a2af6
|
@ -75,9 +75,7 @@ class PoFileStats:
|
|||
missing = len(self.fuzzy_entries) + len(self.untranslated_entries)
|
||||
parts = []
|
||||
parts.append(f"- {self.filename:<30} {missing:3d} to do")
|
||||
if self.fuzzy_nb:
|
||||
parts.append(f"including {self.fuzzy_nb} fuzzies")
|
||||
return ", ".join(parts) + "."
|
||||
return ", ".join(parts)
|
||||
|
||||
def percentages(self, with_reservation_dates: bool = False) -> str:
|
||||
"""Return a string representation with pct of untranslated and fuzzy."""
|
||||
|
@ -85,9 +83,7 @@ class PoFileStats:
|
|||
f"- {self.filename:<30} {self.translated_nb:3d} / {self.po_file_size:3d}"
|
||||
f" ({self.percent_translated:5.1f}% translated)"
|
||||
]
|
||||
if self.fuzzy_nb:
|
||||
parts.append(f"{self.fuzzy_nb} fuzzy")
|
||||
return ", ".join(parts) + "."
|
||||
return ", ".join(parts)
|
||||
|
||||
def as_dict(self) -> Dict[str, Any]:
|
||||
return {
|
||||
|
|
|
@ -99,9 +99,11 @@ def print_po_project(
|
|||
for po_file in sorted(directory.files):
|
||||
if select(po_file):
|
||||
line = [po_file.counts() if counts else po_file.percentages()]
|
||||
if po_file.fuzzy_nb:
|
||||
line.append(f"{po_file.fuzzy_nb} fuzzy")
|
||||
if po_file.reserved_by is not None:
|
||||
line.append(po_file.reservation_str(show_reservation_dates))
|
||||
print(", ".join(line))
|
||||
print(", ".join(line) + ".")
|
||||
|
||||
if po_project.total != 0:
|
||||
print(f"\n\n# TOTAL ({po_project.completion:.2f}% done)\n")
|
||||
|
|
|
@ -136,9 +136,7 @@ class TestPotodoCLI:
|
|||
)
|
||||
assert "- file4.po 1 to do" in output
|
||||
assert "# repository (25.00% done)" in output
|
||||
assert (
|
||||
"- file1.po 2 to do, including 1 fuzzies." in output
|
||||
)
|
||||
assert "- file1.po 2 to do, 1 fuzzy." in output
|
||||
|
||||
def test_potodo_exclude_fuzzy(self):
|
||||
output = check_output(
|
||||
|
@ -148,10 +146,7 @@ class TestPotodoCLI:
|
|||
assert (
|
||||
"- excluded.po 1 / 2 ( 50.0% translated)" in output
|
||||
)
|
||||
assert (
|
||||
"- file1.po 2 to do, including 1 fuzzies."
|
||||
not in output
|
||||
)
|
||||
assert "- file1.po 2 to do, 1 fuzzy." not in output
|
||||
|
||||
def test_potodo_matching_files_solo(self):
|
||||
output = check_output(
|
||||
|
|
Loading…
Reference in New Issue
Block a user