arxiv.canonical.services.remote module

class arxiv.canonical.services.remote.DeferredRequestReader(method, uri, stream=True)[source]

Bases: _io.BytesIO

IO[bytes] object that reads lazily via an HTTP request.

read(size=-1)[source]

Read from the remote resource.

Return type

bytes

seek(offset, whence=0)[source]

Change stream position.

Seek to byte offset pos relative to position indicated by whence:

0 Start of stream (the default). pos should be >= 0; 1 Current position - pos may be negative; 2 End of stream - pos usually negative.

Returns the new absolute position.

Return type

None

seekable()[source]

Returns True if the IO object can be seeked.

Return type

bool

tell()[source]

Current file position, an integer.

Return type

bool

class arxiv.canonical.services.remote.RemoteSource(trusted_domain, trusted_scheme='https', retry=3, backoff=2, retry_status=5, force_retry_on=(<HTTPStatus.INTERNAL_SERVER_ERROR: 500>, <HTTPStatus.BAD_GATEWAY: 502>, <HTTPStatus.SERVICE_UNAVAILABLE: 503>, <HTTPStatus.GATEWAY_TIMEOUT: 504>))[source]

Bases: arxiv.canonical.core.ICanonicalSource

Retrieves content from remote URIs.

can_resolve(uri)[source]

Indicate whether or not the implementation can resolve an URI.

Parameters

uri (D.URI) –

Returns

Return type

bool

Return type

bool

load(key, stream=True)[source]

Make an IO that waits to load from the record until it is read().

Return type

IO[bytes]

load_entry(key)[source]

Load an entry from the record.

Return type

Tuple[RecordStream, str]