[geneagrapher] 101/226: * Added BadIdError class. * Updated error handling for bad node IDs to catch both known classes of Math Genealogy Project page errors. This fixes #14.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Sat Jul 11 17:10:50 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository geneagrapher.

commit 359dd305c1cb8223726e8230d141ef8221ca0034
Author: David Alber <alber.david at gmail.com>
Date:   Sun Dec 28 05:10:31 2008 +0000

     * Added BadIdError class.
     * Updated error handling for bad node IDs to catch both known classes of Math Genealogy Project page errors. This fixes #14.
---
 Geneagrapher/geneagrapher/grab.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/Geneagrapher/geneagrapher/grab.py b/Geneagrapher/geneagrapher/grab.py
index d1f6a1f..e190f3e 100644
--- a/Geneagrapher/geneagrapher/grab.py
+++ b/Geneagrapher/geneagrapher/grab.py
@@ -2,6 +2,12 @@ import urllib
 import re
 from htmlentitydefs import name2codepoint
 
+class BadIdError(ValueError):
+    def __init__(self, value):
+        self.value = value
+    def __str__(self):
+        return repr(self.value)
+
 class Grabber:
     """
     Class for grabbing and parsing mathematician information from
@@ -45,10 +51,11 @@ class Grabber:
         # Split the page string at newline characters.
         psarray = self.pagestr.split('\n')
         
-        if psarray[0].find("An error occurred in the forwarding block") > -1:
+        if psarray[0].find("An error occurred in the forwarding block") > -1 or \
+                psarray[0].find("DB Error: invalid number") > -1:
             # Then a bad URL (e.g., a bad record id) was given. Throw an exception.
             msg = "Invalid page address for id %d" % (self.id)
-            raise ValueError(msg)
+            raise BadIdError(msg)
 
         lines = iter(psarray)
         for line in lines:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/geneagrapher.git



More information about the debian-science-commits mailing list