Revision: 3897 Author: russblau Date: 2007-07-25 20:09:29 +0000 (Wed, 25 Jul 2007)
Log Message: ----------- Catch NoPage exception in Page.templates()
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2007-07-25 11:56:14 UTC (rev 3896) +++ trunk/pywikipedia/wikipedia.py 2007-07-25 20:09:29 UTC (rev 3897) @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- """ Library to get and put pages on a MediaWiki.
@@ -1416,7 +1416,7 @@ """ try: thistxt = self.get() - except IsRedirectPage: + except (IsRedirectPage, NoPage): return []
# remove commented-out stuff etc. @@ -3491,7 +3491,7 @@ path = self.longpages_address(n=number) get_throttle() html = self.getUrl(path) - entryR = re.compile(ur'<li>(<a href=".+?" title=".+?">hist</a>) <a href=".+?" title="(?P<title>.+?)">.+?</a> [(?P<length>\d+)(.+?)]</li>') + entryR = re.compile(ur'<li>(<a href=".+?" title=".+?">hist</a>) <a href=".+?" title="(?P<title>.+?)">.+?</a> [(?P<length>\d+)(.+?)]</li>') for m in entryR.finditer(html): title = m.group('title') length = int(m.group('length')) @@ -3510,7 +3510,7 @@ path = self.shortpages_address(n = number) get_throttle() html = self.getUrl(path) - entryR = re.compile(ur'<li>(<a href=".+?" title=".+?">hist</a>) <a href=".+?" title="(?P<title>.+?)">.+?</a> [(?P<length>\d+)(.+?)]</li>') + entryR = re.compile(ur'<li>(<a href=".+?" title=".+?">hist</a>) <a href=".+?" title="(?P<title>.+?)">.+?</a> [(?P<length>\d+)(.+?)]</li>') for m in entryR.finditer(html): title = m.group('title') length = int(m.group('length'))