b2sdk._internal.stream.range RangeOfInputStream

class b2sdk._internal.stream.range.RangeOfInputStream(stream, offset, length)[source]

Bases: ReadOnlyStreamMixin, StreamWithLengthWrapper

Wrap a file-like object (read only) and read the selected range of the file.

__init__(stream, offset, length)[source]
Parameters:
  • stream – a seekable stream

  • offset (int) – offset in the stream

  • length (int) – max number of bytes to read

seek(pos, whence=0)[source]

Seek to a given position in the stream.

Parameters:

pos (int) – position in the stream relative to steam offset

Returns:

new position relative to stream offset

Return type:

int

tell()[source]

Return current stream position relative to offset.

Return type:

int

read(size=None)[source]

Read data from the stream.

Parameters:

size (int) – number of bytes to read

Returns:

data read from the stream

Return type:

bytes

close()[source]

Flush and close the IO object.

This method has no effect if the file is already closed.

b2sdk._internal.stream.range.wrap_with_range(stream, stream_length, range_offset, range_length)[source]