#NEWLINE# def _setup_collection_from_csv( self , collection , path , separator = ',' , quote_character = '"' ) : #NEWLINE# #INDENT# if ( not self . searcher . collection_exists ( collection [ 'name' ] ) ) : #NEWLINE# #INDENT# self . searcher . create_collection ( collection [ 'name' ] , collection [ 'fields' ] , collection [ 'uniqueKeyField' ] , collection [ 'df' ] ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# hdfs_path = ( '/tmp/%s' % uuid . uuid4 ( ) ) #NEWLINE# with open ( path ) as fh : #NEWLINE# #INDENT# self . fs . do_as_user ( self . user . username , self . fs . create , hdfs_path , data = fh . read ( ) ) #NEWLINE# #UNINDENT# self . searcher . update_data_from_hdfs ( self . fs , collection [ 'name' ] , self [ 'fields' ] , hdfs_path , 'separated' , separator = separator , quote_character = quote_character ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# if self . fs . do_as_user ( self . user . username , self . fs . exists , hdfs_path ) : #NEWLINE# #INDENT# self . fs . do_as_user ( self . user . username , self . fs . remove , hdfs_path , skip_trash = True )