#NEWLINE# def __init__( self , parsed_uri , min_part_size = WEBHDFS_MIN_PART_SIZE ) : #NEWLINE# #INDENT# if ( parsed_uri . scheme not in 'webhdfs' ) : #NEWLINE# #INDENT# raise TypeError ( 'can only process WebHDFS files' ) #NEWLINE# #UNINDENT# self . parsed_uri = parsed_uri #NEWLINE# self . closed = False #NEWLINE# self . min_part_size = min_part_size #NEWLINE# payload = { #NEWLINE# #INDENT# 'op' : 'CREATE' , #NEWLINE# 'overwrite' : True , #NEWLINE# #UNINDENT# } #NEWLINE# init_response = requests . put ( ( 'http://' + parsed_uri . parsed_uri . uri_path ) , params = payload , allow_redirects = False ) #NEWLINE# if ( not ( init_response . status_code == httplib . TEMPORARY_REDIRECT ) ) : #NEWLINE# #INDENT# raise WebHdfsException ( ( ( str ( init_response . status_code ) + '\n' ) + init_response . content ) ) #NEWLINE# #UNINDENT# uri = init_response . headers [ 'location' ] #NEWLINE# response = requests . put ( uri , data = '' , headers = { #NEWLINE# #INDENT# 'content-type' : 'application/octet-stream' , #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( not ( response . status_code == httplib . CREATED ) ) : #NEWLINE# #INDENT# raise WebHdfsException ( ( ( str ( response . status_code ) + '\n' ) + response . content ) ) #NEWLINE# #UNINDENT# self . lines = [ ] #NEWLINE# self . parts = 0 #NEWLINE# self . chunk_bytes = 0 #NEWLINE# self . total_size = 0