annotate MoinMoin/i18n/tools/markup15to16.py @ 6133:a6283e189869 tip

fixup: remove nonexisting passlib.utils._blowfish this was removed by the passlib 1.7.1 upgrade.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 01 Jun 2017 18:10:19 +0200
parents b1e7d968330d
children
rev   line source
2767
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
1 #!/usr/bin/python
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 """
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3 convert some markup contained in po files to new link/macro markup
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4 """
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
5 DOMAIN = "MoinMoin"
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
6
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
7 import re
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
8 import sys
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
9 import codecs
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
10
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11 def run():
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12 sys.path.insert(0, '../..')
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13
2924
b551fc405222 use standard xx-yy for languages now (not xx_yy), fixes zh-tw issue (port from 1.6)
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2768
diff changeset
14 lang = sys.argv[1]
2767
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15
3051
b1e7d968330d i18n tools: fix small bugs (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2924
diff changeset
16 f = codecs.open("%s.%s.po" % (lang, DOMAIN), "r", "utf-8")
2767
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
17 text = f.read()
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
18 f.close()
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
19
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
20 # replace [[Macro(...)]] by <<Macro(...)>>
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
21 macro_rule = r"\[\[(?P<macro>.*?)\]\]"
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
22 macro_repl = r"<<\g<macro>>>"
2768
d1a1f10a0451 po files: also find macros that are split at EOL
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2767
diff changeset
23 macro_re = re.compile(macro_rule, re.U|re.M|re.S)
2767
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
24 text = macro_re.sub(macro_repl, text)
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
25
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
26 #print repr(text)
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
27
3051
b1e7d968330d i18n tools: fix small bugs (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2924
diff changeset
28 f = codecs.open("%s.%s.po" % (lang, DOMAIN), "w", "utf-8")
2767
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
29 f.write(text)
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
30 f.close()
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
31
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
32 if __name__ == "__main__":
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33 run()
95a97b45a8e9 simple po file conversion to new (macro) markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34