~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/script/export/package.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20080622211713-inlv5k4eifxckelr
ImportĀ upstreamĀ versionĀ 1.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
General syntax: moin [options] export package [package-options]
26
26
 
27
27
[options] usually should be:
28
 
    --config-dir=/path/to/my/cfg/ --wiki-url=http://wiki.example.org/
 
28
    --config-dir=/path/to/my/cfg/ --wiki-url=wiki.example.org/
29
29
 
30
30
[package-options] see below:
31
31
    0. You must run this script as owner of the wiki files, usually this is the
42
42
 
43
43
    4. Optionally, the --user argument could be added to any of the above examples,
44
44
       causing the script to respect ACLs.
45
 
 
46
 
    5. Optionally, the --include_attachments argument could be added to any of the above examples,
47
 
       causing the script to include attachments into the output file.
48
45
"""
49
46
 
50
47
    def __init__(self, argv=None, def_values=None):
54
51
            help="List of pages to package. Can be regular expressions, comma seperated lists, or a lone * for everything."
55
52
        )
56
53
        self.parser.add_option(
57
 
            "-a", "--include_attachments", action="store_true", dest="attachment",
58
 
            help="Include attachments from each page"
59
 
        )
60
 
        self.parser.add_option(
61
54
            "-o", "--output", dest="output",
62
55
            help="Output file for the package."
63
56
        )
87
80
        elif not self.options.pages and not self.options.search:
88
81
            script.log(_("No pages specified using --pages or --search, assuming full package."))
89
82
 
90
 
        include_attachments = self.options.attachment or False
91
 
        if include_attachments:
92
 
            script.log(_("All attachments included into the package."))
93
 
 
94
83
        # Sanity checks
95
84
        if os.path.exists(self.options.output):
96
85
            script.fatal(_("Output file already exists! Cowardly refusing to continue!"))
107
96
        packageoutput = open(self.options.output, "wb")
108
97
        if self.options.search:
109
98
            packagedata = package.collectpackage(package.searchpackage(request,
110
 
                                                                       self.options.search), packageoutput,
111
 
                                                                       include_attachments=include_attachments)
 
99
                                                                       self.options.search), packageoutput)
112
100
        elif self.options.pages:
113
 
            packagedata = package.collectpackage(self.options.pages.split(","), packageoutput, include_attachments=include_attachments)
 
101
            packagedata = package.collectpackage(self.options.pages.split(","), packageoutput)
114
102
        else:
115
103
            packagedata = package.collectpackage(request.rootpage.getPageList(
116
104
                                include_underlay=False,
117
105
                                filter=lambda name: not wikiutil.isSystemPage(request, name)),
118
 
                                packageoutput, include_attachments=include_attachments)
 
106
                                packageoutput)
119
107
        if packagedata:
120
108
            script.fatal(packagedata)
121
109