Commits

Anonymous committed 728b49d

fixed issue #5: percent_translated divide by 0 on empty po files

  • Participants
  • Parent commits 4281c60

Comments (0)

Files changed (1)

         >>> po = polib.pofile('tests/test_pofile_helpers.po')
         >>> po.percent_translated()
         50
+        >>> po = POFile()
+        >>> po.percent_translated()
+        100
         """
         total = len([e for e in self if not e.obsolete])
+        if total == 0:
+            return 100
         translated = len(self.translated_entries())
         return int((100.00 / float(total)) * translated)