Project

General

Profile

« Previous | Next » 

Revision 4989

tnrs_client: Factored TNRS request code into separate function tnrs_request()

View differences:

tnrs_client
69 69
    if not match: raise SystemExit('Invalid '+name+' response:\n'+response)
70 70
    return match.groups()
71 71

  
72
def main():
73
    # Input
74
    env_names = []
75
    debug = opts.env_flag('debug', False, env_names)
76
    taxons = sys.argv[1:]
77
    if not taxons: raise SystemExit('Usage: '+opts.env_usage(env_names, True)
78
        +' '+sys.argv[0]+' taxon... >out 2>>log')
72
def tnrs_request(taxons, debug=False):
79 73
    assert len(taxons) <= max_taxons
80 74
    
81 75
    # Logging
......
135 129
    response, response_info = do_request(url=csv_url, headers={})
136 130
    sys.stdout.write(response)
137 131

  
132
def main():
133
    # Input
134
    env_names = []
135
    debug = opts.env_flag('debug', False, env_names)
136
    taxons = sys.argv[1:]
137
    if not taxons: raise SystemExit('Usage: '+opts.env_usage(env_names, True)
138
        +' '+sys.argv[0]+' taxon... >out 2>>log')
139
    
140
    tnrs_request(taxons, debug)
141

  
138 142
main()

Also available in: Unified diff