Command-line utility to retrieve a Moin page's raw text. Non-RPC so generally needs to be run as your webserver user.
Written by MaxCampos.
1 #!/usr/local/bin/python
2 # -*- coding: iso-8859-1 -*-
3 #
4 # wikiget.py v1.0
5 #
6 # Retrieve the raw text of a Moin page.
7 #
8 # By: Max Campos <mcampos@bpsw.biz>
9 # Sept. 1, 2005
10
11 def parseOpts():
12 from optparse import OptionParser
13
14 usage = "usage: %prog [options] SomePage"
15 op = OptionParser(usage=usage)
16 op.add_option('-w', '--wikidir', dest='wikidir',
17 help="Dir containing your wikiconf.py");
18
19 (options, args) = op.parse_args()
20 if len(args) > 0:
21 options.pagename = args[0]
22 else:
23 op.error("You must specify a page name.")
24
25 return options
26
27
28 from MoinMoin.request import RequestCLI
29 from MoinMoin.Page import Page
30 import os
31 import sys
32
33 opts = parseOpts() or sys.exit(1)
34
35 # Do chdir to the wikidir so that any relative file paths in
36 # the wiki config work.
37 if opts.wikidir:
38 os.chdir(opts.wikidir)
39 sys.path.append(opts.wikidir)
40
41 request = RequestCLI(url='foo')
42 p = Page(request, opts.pagename)
43
44 # Return the raw wiki text.
45 print p.getPageText()
Alternatives
Using wget - will not work for non ascii page names:
wget http://mydomain/mywiki/PageName?action=raw
Using urllib, this will work with any unicode name: