#NEWLINE# def _read_inner( self , size = ( - 1 ) , readline = False ) : #NEWLINE# #INDENT# 'Shared implementation of read() and readline().' #NEWLINE# self . _check_open ( ) #NEWLINE# if ( not self . _remaining ( ) ) : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# data_list = [ ] #NEWLINE# if ( size is None ) : #NEWLINE# #INDENT# size = ( - 1 ) #NEWLINE# #UNINDENT# to_read = min ( size , self . _remaining ( ) ) #NEWLINE# if ( to_read < 0 ) : #NEWLINE# #INDENT# to_read = self . _remaining ( ) #NEWLINE# #UNINDENT# break_after = False #NEWLINE# while ( to_read > 0 ) : #NEWLINE# #INDENT# self . _fetch_next_if_buffer_exhausted ( ) #NEWLINE# buffer_bytes_read = ( self . position - self . buffer_start_position ) #NEWLINE# bytes_to_read_from_buffer = min ( ( len ( self . buffer ) - buffer_bytes_read ) , to_read ) #NEWLINE# if readline : #NEWLINE# #INDENT# next_newline_position = self . buffer . find ( '\n' , buffer_bytes_read , len ( self . buffer ) ) #NEWLINE# if ( next_newline_position != ( - 1 ) ) : #NEWLINE# #INDENT# bytes_to_read_from_buffer = ( ( 1 + next_newline_position ) - buffer_bytes_read ) #NEWLINE# break_after = True #NEWLINE# #UNINDENT# #UNINDENT# data_list . append ( self . buffer [ buffer_bytes_read : ( buffer_bytes_read + bytes_to_read_from_buffer ) ] ) #NEWLINE# self . position += bytes_to_read_from_buffer #NEWLINE# to_read -= bytes_to_read_from_buffer #NEWLINE# if break_after : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# return '' . join ( data_list )