arxiv.canonical.services.readable module

Provides BytesIOProxy.

class arxiv.canonical.services.readable.BytesIOProxy(read)[source]

Bases: _io.BytesIO

A readable object that wraps a read() callable.

This gives us lazy, proxied read access to a (presumably expensive) resource that is consistent with io.IOBase.

close()[source]

Flush and close this stream.

Return type

None

fileno()[source]

Return the underlying file descriptor of the stream if it exists.

Return type

int

flush()[source]

Flush the write buffers of the stream if applicable.

Return type

None

isatty()[source]

Return True if the stream is interactive.

Return type

bool

read(size=-1)[source]

Read from the stream.

Return type

bytes

readable()[source]

Return True if the stream can be read from.

Return type

bool

readline(size=-1)[source]

Read and return one line from the stream.

Return type

bytes

readlines(hint=-1)[source]

Read and return a list of lines from the stream.

Return type

List[bytes]

seek(offset, whence=0)[source]

Change the stream position to the given byte offset.

Return type

int

seekable()[source]

Return True if the stream supports random access.

Return type

bool

tell()[source]

Return the current stream position.

Return type

int

truncate(size=None)[source]

Truncation is not supported.

Return type

int

writable()[source]

Writing is not supported.

Return type

bool

writelines(lines)[source]

Writing is not supported.

Return type

None

class arxiv.canonical.services.readable.IterReadWrapper(iter_content, size=4096)[source]

Bases: _io.BytesIO

Wraps a response body streaming iterator to provide read().

read(size=-1)[source]

Read from the content stream, loading more content if necessary.

Return type

bytes

readable()[source]

Indicate that it is a readable stream.

Return type

Literal[True]

seek(offset, whence=0)[source]

Change the stream position to the given byte offset.

Return type

int

seekable()[source]

Indicate that this is a seekable stream.

Return type

Literal[True]

tell()[source]

Return the current stream position.

Return type

int