Back to index

moin  1.9.0~rc2
markup15to16.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 """
00003     convert some markup contained in po files to new link/macro markup
00004 """
00005 DOMAIN = "MoinMoin"
00006 
00007 import re
00008 import sys
00009 import codecs
00010 
00011 def run():
00012     sys.path.insert(0, '../..')
00013 
00014     lang = sys.argv[1]
00015 
00016     f = codecs.open("%s.%s.po" % (lang, DOMAIN), "r", "utf-8")
00017     text = f.read()
00018     f.close()
00019 
00020     # replace [[Macro(...)]] by <<Macro(...)>>
00021     macro_rule = r"\[\[(?P<macro>.*?)\]\]"
00022     macro_repl = r"<<\g<macro>>>"
00023     macro_re = re.compile(macro_rule, re.U|re.M|re.S)
00024     text = macro_re.sub(macro_repl, text)
00025 
00026     #print repr(text)
00027 
00028     f = codecs.open("%s.%s.po" % (lang, DOMAIN), "w", "utf-8")
00029     f.write(text)
00030     f.close()
00031 
00032 if __name__ == "__main__":
00033     run()
00034