Release preparation (fix version number resolving)
[panucci.git] / data / po / summary.py
blobe3496dacb8f43fb344e3fedf32da7481ce99746d
1 #!/usr/bin/python
2 # summary.py - Text-based visual translation completeness summary
3 # Thomas Perl <thp@gpodder.org>, 2009-01-03
5 # Usage: make statistics | python summary.py
8 import sys
9 import re
10 import math
12 width = 40
14 class Language(object):
15 def __init__(self, code, updated, translated, fuzzy, untranslated):
16 self.code = code
17 self.updated = updated
18 self.translated = int(translated)
19 self.fuzzy = int(fuzzy)
20 self.untranslated = int(untranslated)
22 def get_translated_ratio(self):
23 return float(self.translated)/float(self.translated+self.fuzzy+self.untranslated)
25 def get_fuzzy_ratio(self):
26 return float(self.fuzzy)/float(self.translated+self.fuzzy+self.untranslated)
28 def get_untranslated_ratio(self):
29 return float(self.untranslated)/float(self.translated+self.fuzzy+self.untranslated)
31 def __cmp__(self, other):
32 return cmp(self.get_translated_ratio(), other.get_translated_ratio())
34 languages = []
36 for line in sys.stdin:
37 match = re.match('^(..)\.po \(([^)]*)\): ((\d+) translated message[s]?)?(, (\d+) fuzzy translation[s]?)?(, (\d+) untranslated message[s]?)?\.', line).groups()
38 languages.append(Language(match[0], match[1], match[3] or '0', match[5] or '0', match[7] or '0'))
40 print ''
41 print ' --== gPodder translation summary == --'
42 print ''
44 for language in sorted(languages):
45 tc = '#'*(int(math.floor(width*language.get_translated_ratio())))
46 fc = '~'*(int(math.floor(width*language.get_fuzzy_ratio())))
47 uc = ' '*(width-len(tc)-len(fc))
49 print ' %s (%s) [%s%s%s] -- %3.0f %% translated' % (language.code, language.updated, tc, fc, uc, language.get_translated_ratio()*100)
51 print ''
52 print ' Total translations: %d' % len(languages)
53 print ''