[Pywikipedia-l] SVN: [4870] trunk/pywikipedia/pagefromfile.py

rotem at svn.wikimedia.org rotem at svn.wikimedia.org
Sun Jan 13 17:14:32 UTC 2008


Revision: 4870
Author:   rotem
Date:     2008-01-13 17:14:31 +0000 (Sun, 13 Jan 2008)

Log Message:
-----------
(support request 1868291) Catch put exceptions in pagefromfile.py.

Modified Paths:
--------------
    trunk/pywikipedia/pagefromfile.py

Modified: trunk/pywikipedia/pagefromfile.py
===================================================================
--- trunk/pywikipedia/pagefromfile.py	2008-01-13 17:08:26 UTC (rev 4869)
+++ trunk/pywikipedia/pagefromfile.py	2008-01-13 17:14:31 UTC (rev 4870)
@@ -164,13 +164,20 @@
                 wikipedia.setAction('')
 
         if self.debug:
-                wikipedia.output("*** Debug mode ***\n" + \
-                    "\03{lightpurple}title\03{default}: " + title + "\n" + \
-                    "\03{lightpurple}contents\03{default}:\n" + contents + "\n" \
-                    "\03{lightpurple}comment\03{default}: " + comment + "\n")
-                return
+            wikipedia.output("*** Debug mode ***\n" + \
+                "\03{lightpurple}title\03{default}: " + title + "\n" + \
+                "\03{lightpurple}contents\03{default}:\n" + contents + "\n" \
+                "\03{lightpurple}comment\03{default}: " + comment + "\n")
+            return
 
-        page.put(contents, comment = comment, minorEdit = self.minor)
+        try:
+            page.put(contents, comment = comment, minorEdit = self.minor)
+        except wikipedia.LockedPage:
+            wikipedia.output(u"Page %s is locked; skipping." % title)
+        except wikipedia.EditConflict:
+            wikipedia.output(u'Skipping %s because of edit conflict' % title)
+        except wikipedia.SpamfilterError, error:
+            wikipedia.output(u'Cannot change %s because of spam blacklist entry %s' % (title, error.url))
 
 class PageFromFileReader:
     """





More information about the Pywikipedia-l mailing list