THE ORIONIS API
Build with clarity.
Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.
class LocalStorageDriver(IStorageDriver): (source)
Constructor: LocalStorageDriver(root, base_url)
Storage driver backed by the local filesystem.
Every path is resolved inside the configured root directory and
all blocking I/O runs on worker threads via
asyncio.to_thread, keeping the event loop responsive.
Visibility is mapped onto POSIX permission bits (0o644/0o600
for files), which degrades gracefully on platforms without a full
POSIX mode implementation.
| Static Method | __iter |
Yield the direct children of the requested kind under base. |
| Static Method | __temp |
Build a unique staging path for an atomic write. |
| Static Method | __walk |
Yield every nested entry of the requested kind under base. |
| Method | __absolute |
Return the absolute path for an already normalized path. |
| Method | __build |
Build the public URL for normalized. |
| Method | __commit |
Promote a finished temp file to its final destination. |
| Method | __copy |
Copy source to target synchronously. |
| Method | __download |
Copy normalized to a local destination synchronously. |
| Method | __file |
Return the POSIX file mode for visibility. |
| Method | __hash |
Compute the content hash of normalized synchronously. |
| Method | __info |
Build a metadata snapshot for normalized synchronously. |
| Method | __init__ |
Initialize the driver rooted at root. |
| Method | __list |
List entries under normalized synchronously. |
| Method | __move |
Move source to target synchronously. |
| Method | __open |
Open the file at normalized synchronously. |
| Method | __open |
Open a temporary sibling file for writing synchronously. |
| Method | __read |
Read the file at normalized synchronously. |
| Method | __relative |
Return the canonical relative path for absolute. |
| Method | __stat |
Stat the file at normalized or raise when it is absent. |
| Method | __visibility |
Derive the visibility level from POSIX permission bits. |
| Method | __write |
Atomically write data to normalized synchronously. |
| Async Method | copy |
Copy the file at source to target. |
| Async Method | create |
Create the directory at path, including missing parents. |
| Async Method | delete |
Delete the file at path. |
| Async Method | delete |
Recursively delete the directory at path. |
| Async Method | directories |
List the directory paths contained in the directory at path. |
| Async Method | directory |
Check whether a directory exists at path. |
| Async Method | download |
Copy the file at path to a location on the local filesystem. |
| Async Method | exists |
Check whether a file exists at path. |
| Async Method | files |
List the file paths contained in the directory at path. |
| Async Method | hash |
Compute the content hash of the file at path. |
| Async Method | info |
Collect a metadata snapshot for the file at path. |
| Async Method | last |
Return the last-modification timestamp of the file at path. |
| Async Method | mime |
Guess the MIME type of the file at path. |
| Async Method | move |
Move the file at source to target. |
| Method | open |
Open an asynchronous binary stream for the file at path. |
| Async Method | read |
Read the full contents of the file at path. |
| Async Method | read |
Stream the contents of the file at path in chunks. |
| Async Method | set |
Change the visibility of the file at path. |
| Async Method | size |
Return the size in bytes of the file at path. |
| Async Method | temporary |
Build a signed, time-limited URL for the file at path. |
| Async Method | url |
Build the public URL for the file at path. |
| Async Method | visibility |
Return the visibility of the file at path. |
| Async Method | write |
Write contents to path, replacing any existing file. |
| Async Method | write |
Write the chunks produced by stream to path. |
| Class Variable | __slots__ |
Undocumented |
| Instance Variable | _base |
Undocumented |
| Instance Variable | _root |
Undocumented |
Yield the direct children of the requested kind under base.
| Parameters | |
base:Path | Absolute directory to inspect. |
wantbool | When True, yield directories; otherwise files. |
| Returns | |
Iterator[ | Undocumented |
| Yields | |
Path | Absolute path of each matching entry. |
Build a unique staging path for an atomic write.
| Parameters | |
absolute:Path | Final absolute destination path. |
| Returns | |
Path | Sibling path carrying a random infix, so concurrent writers never share a staging file, and still ending in .tmp so listings keep filtering it out. |
Yield every nested entry of the requested kind under base.
| Parameters | |
base:Path | Absolute directory used as the traversal root. |
wantbool | When True, yield directories; otherwise files. |
| Returns | |
Iterator[ | Undocumented |
| Yields | |
Path | Absolute path of each matching entry. |
Return the absolute path for an already normalized path.
| Parameters | |
normalized:str | Canonical root-relative path. |
| Returns | |
Path | Absolute path inside the disk root. |
Promote a finished temp file to its final destination.
| Parameters | |
tmp:Path | Fully written temporary file. |
absolute:Path | Final absolute destination path. |
visibility:str | None | Visibility to apply, or None to keep the OS default. |
| Returns | |
None | Undocumented |
Copy normalized to a local destination synchronously.
| Parameters | |
normalized:str | Canonical root-relative file path. |
destination:str | Path | Local target file or existing directory. |
| Returns | |
Path | Absolute local path of the downloaded file. |
| Raises | |
StorageFileNotFoundException | If the file does not exist. |
Compute the content hash of normalized synchronously.
| Parameters | |
normalized:str | Canonical root-relative file path. |
algorithm:str | Any algorithm name accepted by hashlib.new. |
| Returns | |
str | Hexadecimal digest of the file contents. |
| Raises | |
StorageFileNotFoundException | If the file does not exist. |
UnsupportedStorageOperationException | If algorithm is not available. |
Initialize the driver rooted at root.
| Parameters | |
root:Path | Directory acting as the disk root. It is created when missing. |
basestr | None | Base URL used to build public file URLs, or None when the disk does not expose URLs. |
| Returns | |
None | Undocumented |
Open a temporary sibling file for writing synchronously.
| Parameters | |
tmp:Path | Absolute path of the temporary file. |
| Returns | |
BinaryIO | Open binary handle in write mode. |
Return the canonical relative path for absolute.
| Parameters | |
absolute:Path | Absolute path inside the disk root. |
| Returns | |
str | Root-relative path using / as separator. |
Copy the file at path to a location on the local filesystem.
| Parameters | |
path:str | Root-relative file path on the disk. |
destination:str | Path | Local target. When it points to an existing directory the file keeps its original name inside that directory. |
| Returns | |
Path | Absolute local path of the downloaded file. |
| Raises | |
StorageFileNotFoundException | If the file does not exist. |
Compute the content hash of the file at path.
| Parameters | |
path:str | Root-relative file path. |
algorithm:str | Any algorithm name accepted by hashlib.new. |
| Returns | |
str | Hexadecimal digest of the file contents. |
| Raises | |
StorageFileNotFoundException | If the file does not exist. |
UnsupportedStorageOperationException | If algorithm is not available. |
Guess the MIME type of the file at path.
The guess is derived from the file extension and requires no disk access.
| Parameters | |
path:str | Root-relative file path. |
| Returns | |
str | None | MIME type, or None when it cannot be determined. |
Open an asynchronous binary stream for the file at path.
| Parameters | |
path:str | Root-relative file path. |
mode:str | Binary mode: 'rb', 'wb', 'ab', 'rb+', 'wb+', or 'ab+'. |
| Returns | |
AsyncStream | Lazily opened stream; use it as an async context manager. |
| Raises | |
UnsupportedStorageOperationException | If mode is not a supported binary mode. |
str, chunk_size: int = _CHUNK_SIZE) -> AsyncIterator[ bytes]:
(source)
¶
Build a signed, time-limited URL for the file at path.
The local driver cannot sign URLs, so this operation always fails.
| Parameters | |
path:str | Root-relative file path. |
expiresint | Lifetime of the URL in seconds. |
| Returns | |
str | Never returned by this driver. |
| Raises | |
UnsupportedStorageOperationException | Always, since local disks cannot sign URLs. |
Write contents to path, replacing any existing file.
The write is atomic: data lands in a sibling temporary file that is renamed over the destination once complete.
| Parameters | |
path:str | Root-relative file path. |
contents:bytes | str | Data to persist. Strings are encoded as UTF-8. |
visibility:str | None | Visibility to apply, or None to keep the OS default. |
| Returns | |
None | Undocumented |
str, stream: AsyncIterable[ bytes], visibility: str | None = None):
(source)
¶
Write the chunks produced by stream to path.
Chunks are appended to a temporary file that atomically replaces the destination once the stream is exhausted, so a failed transfer never leaves a partial file behind.
| Parameters | |
path:str | Root-relative file path. |
stream:AsyncIterable[bytes] | Asynchronous byte-chunk producer. |
visibility:str | None | Visibility to apply, or None to keep the OS default. |
| Returns | |
None | Undocumented |