#NEWLINE# def download_data( dataset_name = None ) : #NEWLINE# #INDENT# 'Check with the user that the are happy with terms and conditions for the data set, then download it.' #NEWLINE# import itertools #NEWLINE# dr = data_resources [ dataset_name ] #NEWLINE# if ( not authorize_download ( dataset_name ) ) : #NEWLINE# #INDENT# raise Exception ( 'Permission to download data set denied.' ) #NEWLINE# #UNINDENT# zip_urls = ( dr [ 'urls' ] , dr [ 'files' ] ) #NEWLINE# if dr . has_key ( 'save_names' ) : #NEWLINE# #INDENT# zip_urls += ( dr [ 'save_names' ] , ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# zip_urls += ( [ ] , ) #NEWLINE# #UNINDENT# if dr . has_key ( 'suffices' ) : #NEWLINE# #INDENT# zip_urls += ( dr [ 'suffices' ] , ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# zip_urls += ( [ ] , ) #NEWLINE# #UNINDENT# for ( url , files , save_names , suffices ) in itertools . izip_longest ( * zip_urls , fillvalue = [ ] ) : #NEWLINE# #INDENT# for ( f , save_name , suffix ) in itertools . izip_longest ( files , save_names , suffices , fillvalue = None ) : #NEWLINE# #INDENT# download_url ( os . path . join ( url , f ) , dataset_name , save_name , suffix = suffix ) #NEWLINE# #UNINDENT# #UNINDENT# return True