[Pywikipedia-l] SVN: [4810] trunk/pywikipedia

rotem at svn.wikimedia.org rotem at svn.wikimedia.org
Sat Jan 5 12:57:30 UTC 2008


Revision: 4810
Author:   rotem
Date:     2008-01-05 12:57:29 +0000 (Sat, 05 Jan 2008)

Log Message:
-----------
Creating a new exception, NoSuchSite, for 'Wiki does not exist' places, and using it in the appropriate places.

Modified Paths:
--------------
    trunk/pywikipedia/testfamily.py
    trunk/pywikipedia/wikipedia.py

Modified: trunk/pywikipedia/testfamily.py
===================================================================
--- trunk/pywikipedia/testfamily.py	2008-01-05 12:46:18 UTC (rev 4809)
+++ trunk/pywikipedia/testfamily.py	2008-01-05 12:57:29 UTC (rev 4810)
@@ -39,6 +39,8 @@
         wikipedia.getall(site, [wikipedia.Page(site, 'Any page name')])
     except KeyboardInterrupt:
         raise
+    except wikipedia.NoSuchSite:
+        pass
     except:
         wikipedia.output( u'Error processing language %s' % site.lang )
         wikipedia.output( u''.join(traceback.format_exception(*sys.exc_info())))

Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py	2008-01-05 12:46:18 UTC (rev 4809)
+++ trunk/pywikipedia/wikipedia.py	2008-01-05 12:57:29 UTC (rev 4810)
@@ -17,6 +17,7 @@
     Error:              Base class for all exceptions in this module
     NoUsername:         Username is not in user-config.py
     NoPage:             Page does not exist on the wiki
+    NoSuchSite:         Site does not exist
     IsRedirectPage:     Page is a redirect page
     IsNotRedirectPage:  Page is not a redirect page
     LockedPage:         Page is locked
@@ -155,6 +156,9 @@
 class NoPage(Error):
     """Page does not exist"""
 
+class NoSuchSite(Error):
+    """Site does not exist"""
+
 class IsRedirectPage(Error):
     """Page is a redirect page"""
 
@@ -649,7 +653,7 @@
             # may encounter pages from non-existing wikis such as
             # http://eo.wikisource.org/
             if text.find("<title>Wiki does not exist</title>") != -1:
-                raise NoPage(u'Wiki %s does not exist yet' % self.site())
+                raise NoSuchSite(u'Wiki %s does not exist yet' % self.site())
 
             #Check for new messages
             if '<div class="usermessage">' in text:
@@ -2412,7 +2416,7 @@
                     # may encounter pages from non-existing wikis such as
                     # http://eo.wikisource.org/
                     if data.find("<title>Wiki does not exist</title>") != -1:
-                        return
+                        raise NoSuchSite(u'Wiki %s does not exist yet' % self)
                     elif data.find("<siteinfo>") == -1: # This probably means we got a 'temporary unaivalable'
                         output(u'Got incorrect export page. Sleeping for %d seconds...' % dt)
                         time.sleep(dt)





More information about the Pywikipedia-l mailing list