[Bps-public-commit] wifty branch, master, updated. 7f064311dae46959be8680ef97ec7a93bd962c0f

Thomas Sibley trs at bestpractical.com
Mon Nov 8 13:44:17 EST 2010


The branch, master has been updated
       via  7f064311dae46959be8680ef97ec7a93bd962c0f (commit)
      from  92714a46dbce2c18670d1bb88a1165edf6367056 (commit)

Summary of changes:
 bin/export-to-mediawiki |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)

- Log -----------------------------------------------------------------
commit 7f064311dae46959be8680ef97ec7a93bd962c0f
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Mon Nov 8 13:44:10 2010 -0500

    Support skipping empty pages

diff --git a/bin/export-to-mediawiki b/bin/export-to-mediawiki
index f9775b7..812b558 100755
--- a/bin/export-to-mediawiki
+++ b/bin/export-to-mediawiki
@@ -13,14 +13,15 @@ use HTML::WikiConverter;
 use HTML::WikiConverter::MediaWiki;
 
 use Getopt::Long;
-my ($HELP, $FILE, $SHALLOW);
+my ($HELP, $FILE, $SHALLOW, $SKIPEMPTY);
 my $THRESH = 1.5; #Mb
 
 GetOptions(
-    'help'    => \$HELP,
-    'shallow' => \$SHALLOW,
-    'chunk=i' => \$THRESH,
-    'file=s'  => \$FILE,
+    'help'          => \$HELP,
+    'shallow'       => \$SHALLOW,
+    'chunk=i'       => \$THRESH,
+    'file=s'        => \$FILE,
+    'skip-empty'    => \$SKIPEMPTY,
 );
 
 if ($HELP or not defined $FILE) {
@@ -35,6 +36,9 @@ Usage: $0 --file=export [--shallow] [--chunk=1.5]
   --chunk=#     Chunks the export into files of # megabytes.
                 Defaults to 1.5.
 
+  --skip-empty  Omit empty pages from the export. Only applies to
+                shallow exports.
+
     EOT
     exit;
 }
@@ -120,8 +124,15 @@ CHUNK: while ($CHUNK > 0) {
             };
             if ($@) {
                 # Don't die, just warn and move on
-                warn "Error converting " . $p->name . ": $@\n";
-                $wiki = "Error converting page: $@";
+                warn "Error converting page '" . $p->name . "', revision ", $r->id, ": $@\n";
+                $wiki = "Error converting page '$@', revision " . $r->id;
+            }
+            
+            # Skip empty pages
+            if ($SHALLOW and $SKIPEMPTY and $wiki =~ /^\s*$/) {
+                warn "Skipping empty page '", $p->name, "' (revision ", $r->id, ")\n";
+                $LASTREV = $r->id;
+                next;
             }
 
             print $FH xml(

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list