Project

General

Profile

« Previous | Next » 

Revision 14596

fix: lib/tnrs.py: JSON mode: TSV export columns: need to translate these to JSON column names before they can be used with the JSON data

View differences:

trunk/lib/tnrs.py
72 72
	#  enabling the dirty setting).
73 73
download_response_pattern = '^//OK\[1,\["(.*)"\],0,7\]$'
74 74
download_url_suffix = '&name=tnrs_results.txt&encoding=utf8'
75
tsv_to_json_col_map = {
76
	'Name_matched_author': 'Canonical_author',
77
	'Accepted_name_species': 'Accepted_species',
78
	'Accepted_name_family': 'Accepted_family',
79
	'Selected': 'selected',
80
}
75 81

  
76 82
class InvalidResponse(Exception): pass
77 83

  
......
159 165
        debug_log('fetching export columns')
160 166
        export_cols = csvs.header(single_tnrs_request([''], debug,
161 167
            use_tnrs_export=True)) # need at least 1 name
162
        debug_log('export columns', strings.urepr(export_cols))
168
        debug_log('TSV export columns', strings.urepr(export_cols))
169
        json_cols = [tsv_to_json_col_map.get(c, c) for c in export_cols]
170
        debug_log('JSON columns', strings.urepr(json_cols))
163 171
    
164 172
    ## HTTP
165 173
    headers = initial_headers.copy() # don't modify global constant!

Also available in: Unified diff