annotate MoinMoin/i18n/tools/po2wiki.py @ 4474:aa929a72715d

replace master18 URLs by master19
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 03 Jan 2009 17:26:20 +0100
parents 532865ba8334
children
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 #!/usr/bin/python
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3 remove everthing top of the first msgid line (PIs destroyed by gettext),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4 prepend some processing instructions to a .po file to be able to put it
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
5 onto moinmaster wiki, letting it get processed by gettext parser
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
6 """
4039
532865ba8334 update i18n scripts to access master18 wiki
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3693
diff changeset
7
4474
aa929a72715d replace master18 URLs by master19
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4039
diff changeset
8 master_url = "http://master19.moinmo.in/?action=xmlrpc2"
4039
532865ba8334 update i18n scripts to access master18 wiki
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3693
diff changeset
9 user = "ThomasWaldmann" # must be a known Wiki account
532865ba8334 update i18n scripts to access master18 wiki
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3693
diff changeset
10
532865ba8334 update i18n scripts to access master18 wiki
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3693
diff changeset
11 import sys, os
532865ba8334 update i18n scripts to access master18 wiki
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3693
diff changeset
12 import xmlrpclib
532865ba8334 update i18n scripts to access master18 wiki
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3693
diff changeset
13
532865ba8334 update i18n scripts to access master18 wiki
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3693
diff changeset
14 password = os.environ.get("PASS", "")
532865ba8334 update i18n scripts to access master18 wiki
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3693
diff changeset
15 sys.path.insert(0, '../..')
532865ba8334 update i18n scripts to access master18 wiki
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3693
diff changeset
16
491
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
17 def run():
1291
277695e8e6f5 updated i18n, cosmetic changes to i18n tools
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 991
diff changeset
18 excluded = ["en", ] # languages managed in repository, not in wiki
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
19
491
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
20 lang = sys.argv[1]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
21
491
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
22 data = sys.stdin.read()
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
23
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
24 if lang in excluded:
1662
3338af3c3867 update i18n, fix i18n tools
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1291
diff changeset
25 f = open("%s.MoinMoin.po" % lang, "w")
491
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
26 f.write(data)
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
27 f.close()
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
28 sys.exit(0)
1291
277695e8e6f5 updated i18n, cosmetic changes to i18n tools
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 991
diff changeset
29
491
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
30 data = data.decode('utf-8')
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
31
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
32 cutpos = data.index(u"msgid")
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
33 data = data[cutpos:] # remove comments at top
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
34
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
35 data = u"""\
3693
f976d490b9df use new ACLs / comments also when processing MoinI18n/xx pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3438
diff changeset
36 ## Please edit system and help pages ONLY in the master wiki!
f976d490b9df use new ACLs / comments also when processing MoinI18n/xx pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3438
diff changeset
37 ## For more information, please see MoinMoin:MoinDev/Translation.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
38 ##master-page:None
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
39 ##master-date:None
3693
f976d490b9df use new ACLs / comments also when processing MoinI18n/xx pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3438
diff changeset
40 #acl -All:write Default
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
41 #format gettext
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
42 #language %s
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
43
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
44 #
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
45 # MoinMoin %s system text translation
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
46 #
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
47 %s""" % (lang, lang, data)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
48
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
49
491
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
50 pagename = "MoinI18n/%s" % lang
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
51 pagedata = data.encode('utf-8')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
52
4039
532865ba8334 update i18n scripts to access master18 wiki
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3693
diff changeset
53 wiki = xmlrpclib.ServerProxy(master_url)
3436
7b96b91b9206 i18n tools: use multicall and getAuthToken instead of http basic auth transport
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3115
diff changeset
54 token = wiki.getAuthToken(user, password)
7b96b91b9206 i18n tools: use multicall and getAuthToken instead of http basic auth transport
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3115
diff changeset
55 mc = xmlrpclib.MultiCall(wiki)
7b96b91b9206 i18n tools: use multicall and getAuthToken instead of http basic auth transport
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3115
diff changeset
56 mc.applyAuthToken(token)
7b96b91b9206 i18n tools: use multicall and getAuthToken instead of http basic auth transport
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3115
diff changeset
57 mc.WhoAmI() # then we see in the result if auth worked correctly!
7b96b91b9206 i18n tools: use multicall and getAuthToken instead of http basic auth transport
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3115
diff changeset
58 mc.putPage(pagename, pagedata)
7b96b91b9206 i18n tools: use multicall and getAuthToken instead of http basic auth transport
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3115
diff changeset
59 mc.deleteAuthToken(token)
7b96b91b9206 i18n tools: use multicall and getAuthToken instead of http basic auth transport
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3115
diff changeset
60 result = mc()
7b96b91b9206 i18n tools: use multicall and getAuthToken instead of http basic auth transport
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3115
diff changeset
61 print "Page: %s rc=%r" % (pagename, list(result))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
62
491
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
63 if __name__ == "__main__":
3438
ed3c9a77bee2 updated i18n
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3437
diff changeset
64 run()
491
be33ecd58d4e add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
Thomas Waldmann <tw@waldmann-edv.de>
parents: 396
diff changeset
65