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
14 class Language(object):
15 def __init__(self
, code
, updated
, translated
, fuzzy
, untranslated
):
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())
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'))
41 print ' --== gPodder translation summary == --'
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)
52 print ' Total translations: %d' % len(languages
)