diff 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
line wrap: on
line diff
--- a/MoinMoin/script/export/package.py	Sun Aug 31 22:14:02 2008 +0200
+++ b/MoinMoin/script/export/package.py	Mon Sep 01 09:16:49 2008 +0200
@@ -42,6 +42,9 @@
 
     4. Optionally, the --user argument could be added to any of the above examples,
        causing the script to respect ACLs.
+
+    5. Optionally, the --include_attachments argument could be added to any of the above examples,
+       causing the script to include attachments into the output file.
 """
 
     def __init__(self, argv=None, def_values=None):
@@ -51,6 +54,10 @@
             help="List of pages to package. Can be regular expressions, comma seperated lists, or a lone * for everything."
         )
         self.parser.add_option(
+            "-a", "--include_attachments", action="store_true", dest="attachment",
+            help="Include attachments from each page"
+        )
+        self.parser.add_option(
             "-o", "--output", dest="output",
             help="Output file for the package."
         )
@@ -80,6 +87,10 @@
         elif not self.options.pages and not self.options.search:
             script.log(_("No pages specified using --pages or --search, assuming full package."))
 
+        include_attachments = self.options.attachment or False
+        if include_attachments:
+            script.log(_("All attachments included into the package."))
+
         # Sanity checks
         if os.path.exists(self.options.output):
             script.fatal(_("Output file already exists! Cowardly refusing to continue!"))
@@ -96,14 +107,15 @@
         packageoutput = open(self.options.output, "wb")
         if self.options.search:
             packagedata = package.collectpackage(package.searchpackage(request,
-                                                                       self.options.search), packageoutput)
+                                                                       self.options.search), packageoutput,
+                                                                       include_attachments=include_attachments)
         elif self.options.pages:
-            packagedata = package.collectpackage(self.options.pages.split(","), packageoutput)
+            packagedata = package.collectpackage(self.options.pages.split(","), packageoutput, include_attachments=include_attachments)
         else:
             packagedata = package.collectpackage(request.rootpage.getPageList(
                                 include_underlay=False,
                                 filter=lambda name: not wikiutil.isSystemPage(request, name)),
-                                packageoutput)
+                                packageoutput, include_attachments=include_attachments)
         if packagedata:
             script.fatal(packagedata)