tailhead/__init__.py
def tail(self, lines=10):
        """
        Return the last lines of the file.
        """
        self.file.seek(0, SEEK_END)

        for i in range(lines):
            if self.seek_previous_line() == -1:
                break

        data = self.file.read()

        for t in self.LINE_TERMINATORS:
            if data.endswith(t):
                # Only terminators _between_ lines should be preserved.
                # Otherwise terminator of the last line will be treated as separtaing line and empty line.
                data = data[:-len(t)]
                break

        if data:
            return self.splitlines(data)
        else:
            return []
def tail(self, lines=10):
        self.file.seek(0, SEEK_END)

        for i in range(lines):
            if self.seek_previous_line() == -1:
                break

        data = self.file.read()

        for t in self.LINE_TERMINATORS:
            if data.endswith(t):
                # Only terminators _between_ lines should be preserved.
                # Otherwise terminator of the last line will be treated as separtaing line and empty line.
                data = data[:-len(t)]
                break

        if data:
            return self.splitlines(data)
        else:
            return []
def tail ( self , lines = 10 ) : self . file . seek ( 0 , SEEK_END ) for i in range ( lines ) : if self . seek_previous_line ( ) == - 1 : break data = self . file . read ( ) for t in self . LINE_TERMINATORS : if data . endswith ( t ) : # Only terminators _between_ lines should be preserved. # Otherwise terminator of the last line will be treated as separtaing line and empty line. data = data [ : - len ( t ) ] break if data : return self . splitlines ( data ) else : return [ ]
Return the last lines of the file.
Return the last lines of the file .