Add missing exceptions.

This commit is contained in:
Edward Betts 2019-12-12 15:37:39 +00:00
parent f1d1542d3d
commit b5f87657ba

View file

@ -14,6 +14,16 @@ query_url = 'https://query.wikidata.org/bigdata/namespace/wdq/sparql'
url_start = 'http://www.wikidata.org/entity/Q' url_start = 'http://www.wikidata.org/entity/Q'
commons_start = 'http://commons.wikimedia.org/wiki/Special:FilePath/' commons_start = 'http://commons.wikimedia.org/wiki/Special:FilePath/'
class QueryError(Exception):
def __init__(self, query, r):
self.query = query
self.r = r
class QueryTimeout(QueryError):
def __init__(self, query, r):
self.query = query
self.r = r
def row_id(row, field='item'): def row_id(row, field='item'):
return int(utils.drop_start(row[field]['value'], url_start)) return int(utils.drop_start(row[field]['value'], url_start))