5 """Fetch the .po files from KDE's SVN for Trojita
7 Run me from Trojita's top-level directory.
11 SVN_PATH
= "svn://anonsvn.kde.org/home/kde/trunk/l10n-kde4/"
12 SOURCE_PO_PATH
= "/messages/extragear-pim/trojita_common.po"
13 OUTPUT_PO_PATH
= "./po/"
14 OUTPUT_PO_PATTERN
= "trojita_common_%s.po"
16 fixer
= re
.compile(r
'^#~\| ', re
.MULTILINE
)
17 re_empty_msgid
= re
.compile('^msgid ""$', re
.MULTILINE
)
18 re_empty_line
= re
.compile('^$', re
.MULTILINE
)
19 re_has_qt_contexts
= re
.compile('X-Qt-Contexts: true\\n')
21 if not os
.path
.exists(OUTPUT_PO_PATH
):
22 os
.mkdir(OUTPUT_PO_PATH
)
24 all_languages
= subprocess
.check_output(['svn', 'cat', SVN_PATH
+ 'subdirs'],
25 stderr
=subprocess
.STDOUT
)
27 all_languages
= [x
.strip() for x
in all_languages
.split("\n") if len(x
)]
28 for lang
in all_languages
:
30 raw_data
= subprocess
.check_output(['svn', 'cat', SVN_PATH
+ lang
+ SOURCE_PO_PATH
],
31 stderr
=subprocess
.PIPE
)
32 (transformed
, subs
) = fixer
.subn('# ~| ', raw_data
)
33 pos1
= re_empty_msgid
.search(transformed
).start()
34 pos2
= re_empty_line
.search(transformed
).start()
35 if re_has_qt_contexts
.search(transformed
, pos1
, pos2
) is None:
36 transformed
= transformed
[:pos2
] + \
37 '"X-Qt-Contexts: true\\n"\n' + \
41 print "Fetched %s (and performed %d cleanups)" % (lang
, subs
)
43 print "Fetched %s" % lang
44 file(OUTPUT_PO_PATH
+ OUTPUT_PO_PATTERN
% lang
, "wb").write(transformed
)
45 except subprocess
.CalledProcessError
:
46 print "No data for %s" % lang
48 # Inform qmake about the updated file list
49 os
.utime("CMakeLists.txt", None)