Improve the check_trans script by using Supybot's .po(t) parser.

The previous method matched line by line, which broke for msgmerge alternative (poedit\!\!\!) that changes line breaks.
This commit is contained in:
Valentin Lorentz 2014-01-21 19:30:24 +01:00
parent 736c615605
commit 01c34d806d
1 changed files with 8 additions and 21 deletions

View File

@ -3,8 +3,11 @@
import os import os
import sys import sys
import glob import glob
import operator
import subprocess import subprocess
from supybot.i18n import parse
def main(): def main():
directory = sys.argv[1] directory = sys.argv[1]
if directory == '--core': if directory == '--core':
@ -63,27 +66,11 @@ def checkPlugin(pluginPath):
def checkTranslation(pot, po): def checkTranslation(pot, po):
checking = False checking = False
for potLine in pot: pot = set(map(operator.itemgetter(0), parse(pot)))
if not checking and potLine.startswith('msgid'): po = set(map(operator.itemgetter(0), parse(po)))
checking = True diff = filter(lambda x:x not in po, pot)
while True: print(diff)
poLine = po.readline() return not bool(diff)
if poLine == '': # EOF
return False
if poLine.startswith('msgid'):
if poLine == potLine:
break
else:
return False
continue
elif checking and potLine.startswith('msgstr'):
checking = False
if checking:
poLine = po.readline()
if potLine != poLine:
return False
return True
if __name__ == '__main__': if __name__ == '__main__':
main() main()