fdutils/files.py
def seek_line(self):
        """\
        Searches backwards from the current file position for a line terminator
        and seeks to the character after it.
        """
        pos = end_pos = self.file.tell()
        read_size = self.read_size
        if pos > read_size:
            pos -= read_size
        else:
            pos = 0
            read_size = end_pos

        self.seek(pos)

        bytes_read, read_str = self.read(read_size)

        if bytes_read and read_str[-1] in self.line_terminators:
            # The last charachter is a line terminator, don't count this one
            bytes_read -= 1

            if read_str[-2:] == '\r\n' and '\r\n' in self.line_terminators:
                # found crlf
                bytes_read -= 1

        while bytes_read > 0:
            # Scan backward, counting the newlines in this bufferfull
            i = bytes_read - 1
            while i >= 0:
                if read_str[i] in self.line_terminators:
                    self.seek(pos + i + 1)
                    return self.file.tell()
                i -= 1

            if pos == 0 or pos - self.read_size < 0:
                # Not enought lines in the buffer, send the whole file
                self.seek(0)
                return None

            pos -= self.read_size
            self.seek(pos)

            bytes_read, read_str = self.read(self.read_size)

        return None
\
        Searches backwards from the current file position for a line terminator
        and seeks to the character after it.
        
\
Searches backwards from the current file position for a line terminator
and seeks to the character after it.
\ Searches backwards from the current file position for a line terminator and seeks to the character after it .
def seek_line(self):
        pos = end_pos = self.file.tell()
        read_size = self.read_size
        if pos > read_size:
            pos -= read_size
        else:
            pos = 0
            read_size = end_pos
        self.seek(pos)
        bytes_read, read_str = self.read(read_size)
        if bytes_read and read_str[-1] in self.line_terminators:
            bytes_read -= 1
            if read_str[-2:] == '\r\n' and '\r\n' in self.line_terminators:
                bytes_read -= 1
        while bytes_read > 0:
            i = bytes_read - 1
            while i >= 0:
                if read_str[i] in self.line_terminators:
                    self.seek(pos + i + 1)
                    return self.file.tell()
                i -= 1
            if pos == 0 or pos - self.read_size < 0:
                self.seek(0)
                return None
            pos -= self.read_size
            self.seek(pos)
            bytes_read, read_str = self.read(self.read_size)
        return None
def seek_line ( self ) : pos = end_pos = self . file . tell ( ) read_size = self . read_size if pos > read_size : pos -= read_size else : pos = 0 read_size = end_pos self . seek ( pos ) bytes_read , read_str = self . read ( read_size ) if bytes_read and read_str [ - 1 ] in self . line_terminators : bytes_read -= 1 if read_str [ - 2 : ] == '\r\n' and '\r\n' in self . line_terminators : bytes_read -= 1 while bytes_read > 0 : i = bytes_read - 1 while i >= 0 : if read_str [ i ] in self . line_terminators : self . seek ( pos + i + 1 ) return self . file . tell ( ) i -= 1 if pos == 0 or pos - self . read_size < 0 : self . seek ( 0 ) return None pos -= self . read_size self . seek ( pos ) bytes_read , read_str = self . read ( self . read_size ) return None
\
Searches backwards from the current file position for a line terminator
and seeks to the character after it.
\ Searches backwards from the current file position for a line terminator and seeks to the character after it .
"""\
        Searches backwards from the current file position for a line terminator
        and seeks to the character after it.
        """ # The last charachter is a line terminator, don't count this one # found crlf # Scan backward, counting the newlines in this bufferfull # Not enought lines in the buffer, send the whole file
self