improve docstring for last_bytes()

Change-Id: Ic402a29c9e701a6cde3e882cc97721008cdd5460
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2018-01-02 08:50:18 -05:00
parent 4d35db56f8
commit 11feb68eb3
1 changed files with 8 additions and 1 deletions

View File

@ -127,12 +127,19 @@ def compute_file_checksum(path, read_chunksize=65536, algorithm='sha256'):
def last_bytes(path, num):
"""Return num bytes from the end of the file, and unread byte count.
"""Return num bytes from the end of the file and unread byte count.
Returns a tuple containing some content from the file and the
number of bytes that appear in the file before the point at which
reading started. The content will be at most ``num`` bytes, taken
from the end of the file. If the file is smaller than ``num``
bytes the entire content of the file is returned.
:param path: The file path to read
:param num: The number of bytes to return
:returns: (data, unread_bytes)
"""
with open(path, 'rb') as fp: