[damned-lies] Do not error out on pot files with no messages
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Do not error out on pot files with no messages
- Date: Sun, 5 May 2019 17:04:04 +0000 (UTC)
commit b5d125b81ba79999463d54e260c2b95489310898
Author: Pino Toscano <toscano pino tiscali it>
Date: Thu May 2 05:58:42 2019 +0200
Do not error out on pot files with no messages
language is None for them, so skip all the extra processing that really
applies only to po files.
stats/models.py | 2 +-
stats/tests/empty.pot | 19 +++++++++++++++++++
stats/tests/tests.py | 14 ++++++++++++++
3 files changed, 34 insertions(+), 1 deletion(-)
---
diff --git a/stats/models.py b/stats/models.py
index ad93c597..19d74d67 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -1503,7 +1503,7 @@ class Statistics(models.Model):
# If stats are 100%, compare the total number of strings between
# committed po (pofile) and merged po (outpo).
# Until https://savannah.gnu.org/bugs/index.php?50910 is fixed.
- if stats['fuzzy'] + stats['untranslated'] == 0: # Fully translated
+ if self.language and stats['fuzzy'] + stats['untranslated'] == 0: # Fully translated po file
abs_po_path = self.branch.co_path / self.domain.get_po_path(self.language.locale)
if abs_po_path.exists():
git_stats = utils.po_file_stats(abs_po_path)
diff --git a/stats/tests/empty.pot b/stats/tests/empty.pot
new file mode 100644
index 00000000..971e3eb4
--- /dev/null
+++ b/stats/tests/empty.pot
@@ -0,0 +1,19 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: https://gitlab.gnome.org/GNOME/gedit/issues\n"
+"POT-Creation-Date: 2019-03-17 23:29+0000\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL li org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index f80ca910..c0fd51dc 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -740,6 +740,20 @@ class StatisticsTests(TestCase):
]
self.assertEqual(sorted(infos)[0].statistics.branch.module.name, 'gnome-hello')
+ def test_empty_pot(self):
+ pot_file = Path(__file__).parent / 'empty.pot'
+ mod = Module.objects.get(name='zenity')
+ dom = Domain.objects.create(
+ module=mod, name='po2', dtype='ui', description='UI Translations'
+ )
+ branch = mod.branch_set.get(name='gnome-3-8')
+ stat = Statistics.objects.create(branch=branch, domain=dom, language=None)
+ stat.update_stats(pot_file)
+ self.assertEqual(stat.full_po, stat.part_po)
+ self.assertEqual(stat.translated(), 0)
+ self.assertEqual(stat.fuzzy(), 0)
+ self.assertEqual(stat.untranslated(), 0)
+
class FigureTests(TestCase):
fixtures = ['sample_data.json']
def test_figure_view(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]