Removing obsolete entries from fuzzies (#42)

Removing obsolete entries from fuzzies
This commit is contained in:
Jules Lasne (jlasne) 2019-12-13 18:05:31 +01:00 committed by GitHub
commit dfcbb15439
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 8 deletions

View File

@ -1,4 +1,4 @@
from typing import Dict, Mapping, Sequence, Set from typing import Dict, Mapping, Sequence, Set, List
from pathlib import Path from pathlib import Path
import polib import polib
@ -16,10 +16,13 @@ class PoFileStats:
self.pofile: polib.POFile = polib.pofile(self.path) self.pofile: polib.POFile = polib.pofile(self.path)
self.directory: str = self.path.parent.name self.directory: str = self.path.parent.name
self.fuzzy_entries: Sequence[polib.POEntry] = self.pofile.fuzzy_entries() self.obsolete_entries: Sequence[polib.POEntry] = self.pofile.obsolete_entries()
self.fuzzy_nb: int = len(self.fuzzy_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[ self.translated_entries: Sequence[
polib.POEntry polib.POEntry
@ -31,11 +34,8 @@ class PoFileStats:
] = self.pofile.untranslated_entries() ] = self.pofile.untranslated_entries()
self.untranslated_nb: int = len(self.untranslated_entries) self.untranslated_nb: int = len(self.untranslated_entries)
self.obsolete_entries: Sequence[polib.POEntry] = self.pofile.obsolete_entries() self.percent_translated: int = self.pofile.percent_translated()
self.obsolete_nb: int = len(self.pofile.obsolete_entries())
self.po_file_size = len(self.pofile) - self.obsolete_nb self.po_file_size = len(self.pofile) - self.obsolete_nb
self.filename_dir: str = self.directory + "/" + self.filename self.filename_dir: str = self.directory + "/" + self.filename
def __str__(self) -> str: def __str__(self) -> str:

View File

@ -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 <traductions@lists.afpy.org>\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"

View File

@ -22,3 +22,5 @@ def test_potodo(capsys):
assert "token.po" in captured.out assert "token.po" in captured.out
assert "glossary.po" not in captured.out assert "glossary.po" not in captured.out
assert "sphinx.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