better error reporting in wikipedia plugin

This commit is contained in:
Ryan Hitchman 2009-03-30 17:32:52 -06:00
parent b1d722fdf7
commit b965ec92ab
1 changed files with 4 additions and 1 deletions

View File

@ -25,7 +25,10 @@ def wiki(query):
items = x.findall(ns + 'Section/' + ns + 'Item') items = x.findall(ns + 'Section/' + ns + 'Item')
if items == []: if items == []:
return 'no results found' if x.find('error') is not None:
return 'error: %(code)s: %(info)s' % x.find('error').attrib
else:
return 'no results found'
def extract(item): def extract(item):
return [item.find(ns + x).text for x in return [item.find(ns + x).text for x in