<s> """<STR_LIT>""" <EOL> import urllib <EOL> from oslo_utils import netutils <EOL> from oslo_vmware import rw_handles <EOL> class VMwareHTTPReadFile ( rw_handles . FileHandle ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , host , port , data_center_name , datastore_name , cookies , <EOL> file_path , scheme = "<STR_LIT>" ) : <EOL> self . _base_url = self . _get_base_url ( scheme , host , port , file_path ) <EOL> param_list = { "<STR_LIT>" : data_center_name , "<STR_LIT>" : datastore_name } <EOL> self . _base_url = self . _base_url + "<STR_LIT:?>" + urllib . urlencode ( param_list ) <EOL> self . _conn = self . _create_read_connection ( self . _base_url , <EOL> cookies = cookies ) <EOL> rw_handles . FileHandle . __init__ ( self , self . _conn ) <EOL> def read ( self , chunk_size ) : <EOL> return self . _file_handle . read ( rw_handles . READ_CHUNKSIZE ) <EOL> def _get_base_url ( self , scheme , host , port , file_path ) : <EOL> if netutils . is_valid_ipv6 ( host ) : <EOL> base_url = "<STR_LIT>" % ( scheme , host , port , <EOL> urllib . pathname2url ( file_path ) ) <EOL> else : <EOL> base_url = "<STR_LIT>" % ( scheme , host , port , <EOL> urllib . pathname2url ( file_path ) ) <EOL> return base_url <EOL> def get_size ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _file_handle . headers . get ( "<STR_LIT>" , - <NUM_LIT:1> ) </s>
