#NEWLINE# def readline( self , length = None ) : #NEWLINE# #INDENT# "Read one entire line from the file.\n\n        A trailing newline character is kept in the string (but may be absent\n        when a file ends with an incomplete line). If the size argument is\n        present and non-negative, it is a maximum byte count (including the\n        trailing newline) and an incomplete line may be returned.\n\n        An empty string is returned only when EOF is encountered immediately.\n\n        Note: Unlike stdio's fgets(), the returned string contains null\n        characters ('\\0') if they occurred in the input.\n        " #NEWLINE# _complain_ifclosed ( self . closed ) #NEWLINE# if self . buflist : #NEWLINE# #INDENT# self . buf += '' . join ( self . buflist ) #NEWLINE# self . buflist = [ ] #NEWLINE# #UNINDENT# i = self . buf . find ( '\n' , self . pos ) #NEWLINE# if ( i < 0 ) : #NEWLINE# #INDENT# newpos = self . len #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# newpos = ( i + 1 ) #NEWLINE# #UNINDENT# if ( ( length is not None ) and ( length >= 0 ) ) : #NEWLINE# #INDENT# if ( ( self . pos + length ) < newpos ) : #NEWLINE# #INDENT# newpos = ( self . pos + length ) #NEWLINE# #UNINDENT# #UNINDENT# r = self . buf [ self . pos : newpos ] #NEWLINE# self . pos = newpos #NEWLINE# return r