annotate MoinMoin/script/export/package.py @ 4065:d54e233a8784

package pages: feature added to optionally include attachments.
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Mon, 01 Sep 2008 09:16:49 +0200
parents 2a3a6cb34e45
children a20de9383481
rev   line source
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
2 """
3108
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
3 MoinMoin - Create a MoinMoin package from wiki pages specified.
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
4
3108
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
5 @copyright: 2002-2004 Juergen Hermann <jh@web.de>
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
6 2005-2006 MoinMoin:ThomasWaldmann,
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
7 2007 Federico Lorenzi
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
8 @license: GNU GPL, see COPYING for details.
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
9 """
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
10
3175
2a3a6cb34e45 pylint findings: fix some harmless stuff
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3108
diff changeset
11 import os
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
12
3175
2a3a6cb34e45 pylint findings: fix some harmless stuff
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3108
diff changeset
13 from MoinMoin import wikiutil, user
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
14 from MoinMoin import script
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
15
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
16
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
17 class PluginScript(script.MoinScript):
3108
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
18 """\
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
19 Purpose:
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
20 ========
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
21 This tool allows you to create a package of certain wiki pages.
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
22
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
23 Detailed Instructions:
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
24 ======================
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
25 General syntax: moin [options] export package [package-options]
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
26
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
27 [options] usually should be:
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
28 --config-dir=/path/to/my/cfg/ --wiki-url=wiki.example.org/
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
29
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
30 [package-options] see below:
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
31 0. You must run this script as owner of the wiki files, usually this is the
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
32 web server user.
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
33
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
34 1. To package all non-system and non-underlay pages on a wiki to the file '~/mywiki.zip'
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
35 moin ... export package --output ~/mywiki.zip
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
36
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
37 2. To package the pages 'FooBar' and 'TestPage' on a wiki to the file '~/mywiki.zip'
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
38 moin ... export package --pages FooBar,TestPage --output ~/mywiki.zip
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
39
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
40 3. To package all pages matching the search term 'MoinMoin' on a wiki to the file '~/mywiki.zip'
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
41 moin ... export package --search MoinMoin --output ~/mywiki.zip
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
42
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
43 4. Optionally, the --user argument could be added to any of the above examples,
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
44 causing the script to respect ACLs.
4065
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3175
diff changeset
45
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3175
diff changeset
46 5. Optionally, the --include_attachments argument could be added to any of the above examples,
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3175
diff changeset
47 causing the script to include attachments into the output file.
3108
2572688e031a improved moin script's builtin help function, thanks to Federico Lorenzi (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3070
diff changeset
48 """
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
49
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
50 def __init__(self, argv=None, def_values=None):
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
51 script.MoinScript.__init__(self, argv, def_values)
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
52 self.parser.add_option(
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
53 "-p", "--pages", dest="pages",
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
54 help="List of pages to package. Can be regular expressions, comma seperated lists, or a lone * for everything."
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
55 )
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
56 self.parser.add_option(
4065
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3175
diff changeset
57 "-a", "--include_attachments", action="store_true", dest="attachment",
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3175
diff changeset
58 help="Include attachments from each page"
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3175
diff changeset
59 )
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3175
diff changeset
60 self.parser.add_option(
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
61 "-o", "--output", dest="output",
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
62 help="Output file for the package."
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
63 )
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
64 self.parser.add_option(
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
65 "-s", "--search", dest="search",
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
66 help="Search string to match."
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
67 )
3070
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3062
diff changeset
68
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
69 self.parser.add_option(
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
70 "-u", "--user", dest="package_user",
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
71 help="User as whom the package operation will be performed as. "
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
72 )
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
73
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
74 def mainloop(self):
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
75 """ moin-package's main code. """
3070
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3062
diff changeset
76
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
77 # Initalize request
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
78 self.init_request()
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
79 request = self.request
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
80 _ = self.request.getText
3070
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3062
diff changeset
81
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
82 # Check our command line args
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
83 if self.options.pages and self.options.search:
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
84 script.fatal(_("Options --pages and --search are mutually exclusive!"))
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
85 elif not self.options.output:
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
86 script.fatal(_("You must specify an output file!"))
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
87 elif not self.options.pages and not self.options.search:
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
88 script.log(_("No pages specified using --pages or --search, assuming full package."))
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
89
4065
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3175
diff changeset
90 include_attachments = self.options.attachment or False
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3175
diff changeset
91 if include_attachments:
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3175
diff changeset
92 script.log(_("All attachments included into the package."))
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3175
diff changeset
93
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
94 # Sanity checks
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
95 if os.path.exists(self.options.output):
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
96 script.fatal(_("Output file already exists! Cowardly refusing to continue!"))
3070
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3062
diff changeset
97
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
98 # Check for user
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
99 if self.options.package_user:
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
100 request.user = user.User(request, name=self.options.package_user)
3070
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3062
diff changeset
101
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
102 # Import PackagePages here, as we now have an initalized request.
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
103 from MoinMoin.action.PackagePages import PackagePages
3070
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3062
diff changeset
104
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
105 # Perform actual packaging.
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
106 package = PackagePages(request.rootpage.page_name, request)
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
107 packageoutput = open(self.options.output, "wb")
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
108 if self.options.search:
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
109 packagedata = package.collectpackage(package.searchpackage(request,
4065
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3175
diff changeset
110 self.options.search), packageoutput,
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3175
diff changeset
111 include_attachments=include_attachments)
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
112 elif self.options.pages:
4065
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3175
diff changeset
113 packagedata = package.collectpackage(self.options.pages.split(","), packageoutput, include_attachments=include_attachments)
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
114 else:
3175
2a3a6cb34e45 pylint findings: fix some harmless stuff
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3108
diff changeset
115 packagedata = package.collectpackage(request.rootpage.getPageList(
3070
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3062
diff changeset
116 include_underlay=False,
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3062
diff changeset
117 filter=lambda name: not wikiutil.isSystemPage(request, name)),
4065
d54e233a8784 package pages: feature added to optionally include attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3175
diff changeset
118 packageoutput, include_attachments=include_attachments)
3062
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
119 if packagedata:
94941d9d30ee refactored action.PackagePages for CloneWikiPagesByPackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
120 script.fatal(packagedata)
3070
ed1a433803c6 PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3062
diff changeset
121