diff --git a/potodo/_po_file.py b/potodo/_po_file.py index 9a85566..c35247b 100644 --- a/potodo/_po_file.py +++ b/potodo/_po_file.py @@ -1,4 +1,4 @@ -from typing import Dict, Mapping, Sequence, Set +from typing import Dict, Mapping, Sequence, Set, List from pathlib import Path import polib @@ -16,10 +16,13 @@ class PoFileStats: self.pofile: polib.POFile = polib.pofile(self.path) self.directory: str = self.path.parent.name - self.fuzzy_entries: Sequence[polib.POEntry] = self.pofile.fuzzy_entries() - self.fuzzy_nb: int = len(self.fuzzy_entries) + self.obsolete_entries: Sequence[polib.POEntry] = self.pofile.obsolete_entries() + self.obsolete_nb: int = len(self.pofile.obsolete_entries()) - self.percent_translated: int = self.pofile.percent_translated() + self.fuzzy_entries: List[polib.POEntry] = [ + entry for entry in self.pofile if entry.fuzzy and not entry.obsolete + ] + self.fuzzy_nb: int = len(self.fuzzy_entries) self.translated_entries: Sequence[ polib.POEntry @@ -31,11 +34,8 @@ class PoFileStats: ] = self.pofile.untranslated_entries() self.untranslated_nb: int = len(self.untranslated_entries) - self.obsolete_entries: Sequence[polib.POEntry] = self.pofile.obsolete_entries() - self.obsolete_nb: int = len(self.pofile.obsolete_entries()) - + self.percent_translated: int = self.pofile.percent_translated() self.po_file_size = len(self.pofile) - self.obsolete_nb - self.filename_dir: str = self.directory + "/" + self.filename def __str__(self) -> str: diff --git a/tests/fixtures/python-docs-fr/obsolete.po b/tests/fixtures/python-docs-fr/obsolete.po new file mode 100644 index 0000000..8333b57 --- /dev/null +++ b/tests/fixtures/python-docs-fr/obsolete.po @@ -0,0 +1,39 @@ +msgid "" +msgstr "" +"Project-Id-Version: Python 3\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-10-09 17:54+0200\n" +"PO-Revision-Date: 2019-11-02 14:46+0100\n" +"Last-Translator: XXX\n" +"Language-Team: FRENCH \n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.2.1\n" + +#: /un/chemin/idiot.rst:69 +msgid "This is a dummy sentence." +msgstr "Ceci est une phrase bateau." + +#: /un/chemin/idiot.rst:420 +msgid "Incredibly useful as a tool, this potodo" +msgstr "Incroyablement utile comme outil, ce potodo" + +#: /un/chemin/idiot.rst:666 +msgid "We should translate this eventually" +msgstr "" + +#~ msgid "Supported Versions" +#~ msgstr "Versions supportées" + +#~ msgid "Other resources" +#~ msgstr "Autres ressources" + +#, fuzzy +#~ msgid "MingW -- Python extensions" +#~ msgstr "Utiliser Python sur Windows" + +#, fuzzy +#~ msgid "A Python for Windows Tutorial" +#~ msgstr "Utiliser Python sur Windows" diff --git a/tests/test_potodo.py b/tests/test_potodo.py index d4ba2a8..722486b 100644 --- a/tests/test_potodo.py +++ b/tests/test_potodo.py @@ -22,3 +22,5 @@ def test_potodo(capsys): assert "token.po" in captured.out assert "glossary.po" not in captured.out assert "sphinx.po" not in captured.out + assert "2 fuzzy" not in captured.out + assert "3 fuzzy" in captured.out