Project

General

Profile

« Previous | Next » 

Revision 5083

tnrs.py: parse_response(): Raise custom InvalidResponse exception instead of SystemExit, so callers can catch the exception and respond to it

View differences:

tnrs.py
50 50
download_response_pattern = '^//OK\[1,\["(.*)"\],0,7\]$'
51 51
download_url_suffix = '&name=tnrs_results.txt&encoding=utf8'
52 52

  
53
class InvalidResponse(Exception): pass
54

  
53 55
def gwt_encode(str_): return re.sub(r'[^\w.() -]+', r' ', str_)
54 56

  
55 57
def parse_response(name, pattern, response):
56 58
    match = re.match(pattern, response)
57
    if not match: raise SystemExit('Invalid '+name+' response:\n'+response)
59
    if not match: raise InvalidResponse('Invalid '+name+' response:\n'+response)
58 60
    return match.groups()
59 61

  
60 62
def tnrs_request(taxons, debug=False):

Also available in: Unified diff