#NEWLINE# def __init__( self , client , path , buffer_size = DEFAULT_READ_BUFFER_SIZE ) : #NEWLINE# #INDENT# self . client = client #NEWLINE# self . path = path #NEWLINE# ( self . bucket , self . name ) = parse_gcs_path ( path ) #NEWLINE# self . buffer_size = buffer_size #NEWLINE# get_request = storage . StorageObjectsGetRequest ( bucket = self . bucket , object = self . name ) #NEWLINE# try : #NEWLINE# #INDENT# metadata = self . _get_object_metadata ( get_request ) #NEWLINE# #UNINDENT# except HttpError as http_error : #NEWLINE# #INDENT# if ( http_error . status_code == 404 ) : #NEWLINE# #INDENT# raise IOError ( errno . ENOENT , ( 'Not found: %s' % self . path ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logging . error ( 'HTTP error while requesting file %s: %s' , self . path , http_error ) #NEWLINE# raise #NEWLINE# #UNINDENT# #UNINDENT# self . size = metadata . size #NEWLINE# get_request . generation = metadata . generation #NEWLINE# self . download_stream = StringIO . StringIO ( ) #NEWLINE# self . downloader = transfer . Download ( self . download_stream , auto_transfer = False ) #NEWLINE# self . client . objects . Get ( get_request , download = self . downloader ) #NEWLINE# self . position = 0 #NEWLINE# self . buffer = '' #NEWLINE# self . buffer_start_position = 0 #NEWLINE# self . closed = False