BarecatReadOnlyFileObject#

class barecat.io.fileobj.BarecatReadOnlyFileObject(shard_file, start, size)[source]#

Bases: BarecatFileObject

File-like object representing a section of a file.

Parameters:
  • shard_file – the shard file handle

  • start (int) – start position of the section in the file

  • size (int) – size of the section

Properties#

size

Size of the section in bytes.

Instance Methods#

read([size])

Read a from the section, starting from the current position.

readinto(buffer)

Read bytes into a buffer from the section, starting from the current position.

readall()

Read all remaining bytes from the section.

readable()

Always returns True, since the section is always readable.

seekable()

Always returns True, since the section is always seekable.

sendfile(out_fd[, offset, count])

Send bytes from the section to a file descriptor.

writable()

Always returns False, since the section is read-only.

truncate([size])

Truncate file to size bytes.

readline([size])

Read and return a line from the stream.

tell()

Return current stream position.

seek(offset[, whence])

Change stream position.

close()

Mark as closed. The underlying shard file is not closed (we don't own it).