File indexing completed on 2024-05-05 04:32:50
0001 #!/usr/bin/env python 0002 0003 import os 0004 import re 0005 import subprocess 0006 0007 """Fetch the .po files from KDE's SVN for Kst 0008 (Adapted from Trojita) 0009 0010 Run me from Kst's top-level directory, output will go to a po/ directory. 0011 """ 0012 0013 0014 SVN_PATH = "svn://anonsvn.kde.org/home/kde/trunk/l10n-kde4/" 0015 SOURCE_PO_PATH = "/messages/extragear-graphics/kst_common.po" 0016 OUTPUT_PO_PATH = "./po/" 0017 OUTPUT_PO_PATTERN = "kst_common_%s.po" 0018 0019 fixer = re.compile(r'^#~\| ', re.MULTILINE) 0020 re_empty_msgid = re.compile('^msgid ""$', re.MULTILINE) 0021 re_empty_line = re.compile('^$', re.MULTILINE) 0022 re_has_qt_contexts = re.compile('X-Qt-Contexts: true\\n') 0023 0024 if not os.path.exists(OUTPUT_PO_PATH): 0025 os.mkdir(OUTPUT_PO_PATH) 0026 0027 all_languages = subprocess.check_output(['svn', 'cat', SVN_PATH + 'subdirs'], 0028 stderr=subprocess.STDOUT) 0029 0030 all_languages = [x.strip() for x in all_languages.split("\n") if len(x)] 0031 for lang in all_languages: 0032 try: 0033 raw_data = subprocess.check_output(['svn', 'cat', SVN_PATH + lang + SOURCE_PO_PATH], 0034 stderr=subprocess.PIPE) 0035 (transformed, subs) = fixer.subn('# ~| ', raw_data) 0036 pos1 = re_empty_msgid.search(transformed).start() 0037 pos2 = re_empty_line.search(transformed).start() 0038 if re_has_qt_contexts.search(transformed, pos1, pos2) is None: 0039 transformed = transformed[:pos2] + \ 0040 '"X-Qt-Contexts: true\\n"\n' + \ 0041 transformed[pos2:] 0042 subs = subs + 1 0043 if (subs > 0): 0044 print "Fetched %s (and performed %d cleanups)" % (lang, subs) 0045 else: 0046 print "Fetched %s" % lang 0047 filename=OUTPUT_PO_PATH + OUTPUT_PO_PATTERN % lang 0048 file(filename, "wb").write(transformed) 0049 except subprocess.CalledProcessError: 0050 print "No data for %s" % lang 0051 0052 # Inform qmake about the updated file list 0053 os.utime("CMakeLists.txt", None)