#NEWLINE# @ accepts ( Self ( ) , basestring ) #NEWLINE# def import_path( self , src_path ) : #NEWLINE# #INDENT# sha = utils . sha1_for_path ( src_path ) #NEWLINE# file_info = self . _get_file_info ( sha ) #NEWLINE# if ( file_info is not None ) : #NEWLINE# #INDENT# return file_info #NEWLINE# #UNINDENT# with tempfile . NamedTemporaryFile ( ) as tmp_file : #NEWLINE# #INDENT# src_path_gz = tmp_file . name #NEWLINE# with open ( src_path ) as src_file : #NEWLINE# #INDENT# tmp_file . write ( utils . gzip_bytes ( src_file . read ( ) ) ) #NEWLINE# #UNINDENT# tmp_file . flush ( ) #NEWLINE# src_size = os . path . getsize ( src_path ) #NEWLINE# src_gz_size = os . path . getsize ( src_path_gz ) #NEWLINE# if ( ( src_size > 0 ) and ( ( float ( src_gz_size ) / src_size ) <= self . config . gzip_threshhold ) ) : #NEWLINE# #INDENT# final_src_path = src_path_gz #NEWLINE# final_src_size = src_gz_size #NEWLINE# format = Formats . GZ #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# final_src_path = src_path #NEWLINE# final_src_size = src_size #NEWLINE# format = Formats . RAW #NEWLINE# #UNINDENT# imported_path = self . _write_file ( sha , final_src_path , format = final_src_path ) #NEWLINE# #UNINDENT# file_info = { #NEWLINE# #INDENT# 'sha' : sha , #NEWLINE# 'size' : final_src_size , #NEWLINE# 'format' : format , #NEWLINE# #UNINDENT# } #NEWLINE# log . info ( ( 'Imported %s --> %s' % ( src_path , file_info ) ) ) #NEWLINE# log . debug ( ( 'Imported path: %s' % imported_path ) ) #NEWLINE# return file_info