#NEWLINE# def __init__( self , open_request , file_storage ) : #NEWLINE# #INDENT# self . filename = open_request . filename ( ) #NEWLINE# self . file_storage = file_storage #NEWLINE# self . open_mode = open_request . open_mode ( ) #NEWLINE# content_type = open_request . content_type ( ) #NEWLINE# if open_request . is_appending : #NEWLINE# #INDENT# if ( not self . filename . startswith ( _GS_UPLOAD_PREFIX ) ) : #NEWLINE# #INDENT# raise_error ( file_service_pb . FileServiceErrors . INVALID_FILE_NAME ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not self . file_storage . has_upload ( self . filename ) ) : #NEWLINE# #INDENT# raise_error ( file_service_pb . FileServiceErrors . EXISTENCE_ERROR ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . file_storage . is_finalized ( self . filename ) : #NEWLINE# #INDENT# raise_error ( file_service_pb . FileServiceErrors . FINALIZATION_ERROR , 'File is already finalized' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( not self . filename . startswith ( _GS_PREFIX ) ) : #NEWLINE# #INDENT# raise_error ( file_service_pb . FileServiceErrors . INVALID_FILE_NAME ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . filename . startswith ( _GS_UPLOAD_PREFIX ) : #NEWLINE# #INDENT# raise_error ( file_service_pb . FileServiceErrors . INVALID_FILE_NAME ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . buf = self . file_storage . get_reader ( self . filename ) #NEWLINE# if ( not self . buf ) : #NEWLINE# #INDENT# raise_error ( file_service_pb . FileServiceErrors . EXISTENCE_ERROR ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( content_type != file_service_pb . FileContentType . RAW ) : #NEWLINE# #INDENT# raise_error ( file_service_pb . FileServiceErrors . WRONG_CONTENT_TYPE )