(self)
Internal: read lines until outerboundary.
        Data is read as bytes: boundaries and line ends must be converted
        to bytes for comparisons.
Internal: read lines until outerboundary.
        Data is read as bytes: boundaries and line ends must be converted
        to bytes for comparisons.
Internal : read lines until outerboundary . Data is read as bytes : boundaries and line ends must be converted to bytes for comparisons .
def read_lines_to_outerboundary(self):
        """Internal: read lines until outerboundary.
        Data is read as bytes: boundaries and line ends must be converted
        to bytes for comparisons.
        """
        next_boundary = b"--" + self.outerboundary
        last_boundary = next_boundary + b"--"
        delim = b""
        last_line_lfend = True
        _read = 0
        while 1:

            if self.limit is not None and 0 <= self.limit <= _read:
                break
            line = self.fp.readline(1<<16) # bytes
            self.bytes_read += len(line)
            _read += len(line)
            if not line:
                self.done = -1
                break
            if delim == b"\r":
                line = delim + line
                delim = b""
            if line.startswith(b"--") and last_line_lfend:
                strippedline = line.rstrip()
                if strippedline == next_boundary:
                    break
                if strippedline == last_boundary:
                    self.done = 1
                    break
            odelim = delim
            if line.endswith(b"\r\n"):
                delim = b"\r\n"
                line = line[:-2]
                last_line_lfend = True
            elif line.endswith(b"\n"):
                delim = b"\n"
                line = line[:-1]
                last_line_lfend = True
            elif line.endswith(b"\r"):
                # We may interrupt \r\n sequences if they span the 2**16
                # byte boundary
                delim = b"\r"
                line = line[:-1]
                last_line_lfend = False
            else:
                delim = b""
                last_line_lfend = False
            self.__write(odelim + line)
def read_lines_to_outerboundary ( self ) : next_boundary = b"--" + self . outerboundary last_boundary = next_boundary + b"--" delim = b"" last_line_lfend = True _read = 0 while 1 : if self . limit is not None and 0 <= self . limit <= _read : break line = self . fp . readline ( 1 << 16 ) # bytes self . bytes_read += len ( line ) _read += len ( line ) if not line : self . done = - 1 break if delim == b"\r" : line = delim + line delim = b"" if line . startswith ( b"--" ) and last_line_lfend : strippedline = line . rstrip ( ) if strippedline == next_boundary : break if strippedline == last_boundary : self . done = 1 break odelim = delim if line . endswith ( b"\r\n" ) : delim = b"\r\n" line = line [ : - 2 ] last_line_lfend = True elif line . endswith ( b"\n" ) : delim = b"\n" line = line [ : - 1 ] last_line_lfend = True elif line . endswith ( b"\r" ) : # We may interrupt \r\n sequences if they span the 2**16 # byte boundary delim = b"\r" line = line [ : - 1 ] last_line_lfend = False else : delim = b"" last_line_lfend = False self . __write ( odelim + line )