File-like Object¶
Native support for reading from object stores as a file-like object.
Use obstore.open or obstore.open_async to open files. Writing files in this way is not yet supported.
obstore.open ¶
open(store: ObjectStore, path: str) -> ReadableFile
Open a file object from the specified location.
Parameters:
-
store(ObjectStore) –The ObjectStore instance to use.
-
path(str) –The path within ObjectStore to retrieve.
Returns:
-
ReadableFile–ReadableFile
obstore.open_async
async
¶
open_async(store: ObjectStore, path: str) -> AsyncReadableFile
Call open asynchronously, returning a file object with asynchronous operations.
Refer to the documentation for open.
obstore.ReadableFile ¶
A readable file object with synchronous operations.
This implements a similar interface as a generic readable Python binary file-like object.
read ¶
Read up to size bytes from the object and return them. As a convenience, if
size is unspecified or None, all bytes until EOF are returned.
readall ¶
readall() -> Bytes
Read and return all the bytes from the stream until EOF, using multiple calls to the stream if necessary.
readlines ¶
Read all remaining lines into a list of buffers
seek ¶
Change the stream position to the given byte offset, interpreted relative to the position indicated by whence, and return the new absolute position. Values for whence are:
os.SEEK_SETor 0: start of the stream (the default);offsetshould be zero or positiveos.SEEK_CURor 1: current stream position;offsetmay be negativeos.SEEK_ENDor 2: end of the stream;offsetis usually negative
obstore.AsyncReadableFile ¶
A readable file object with asynchronous operations.
read
async
¶
Read up to size bytes from the object and return them. As a convenience, if
size is unspecified or None, all bytes until EOF are returned.
readall
async
¶
readall() -> Bytes
Read and return all the bytes from the stream until EOF, using multiple calls to the stream if necessary.
readline
async
¶
readline() -> Bytes
Read a single line of the file, up until the next newline character.
readlines
async
¶
Read all remaining lines into a list of buffers
seek
async
¶
Change the stream position to the given byte offset, interpreted relative to the position indicated by whence, and return the new absolute position. Values for whence are:
os.SEEK_SETor 0: start of the stream (the default);offsetshould be zero or positiveos.SEEK_CURor 1: current stream position;offsetmay be negativeos.SEEK_ENDor 2: end of the stream;offsetis usually negative