Skip to content

Local

obstore.store.LocalStore

Local filesystem storage providing an ObjectStore interface to files on local disk. Can optionally be created with a directory prefix.

from pathlib import Path

store = LocalStore()
store = LocalStore(prefix="/path/to/directory")
store = LocalStore(prefix=Path("."))

prefix property

prefix: Path | None

Get the prefix applied to all operations in this store, if any.

__init__

__init__(
    prefix: str | Path | None = None,
    *,
    automatic_cleanup: bool = False,
    mkdir: bool = False,
) -> None

Create a new LocalStore.

Parameters:

  • prefix (str | Path | None, default: None ) –

    Use the specified prefix applied to all paths. Defaults to None.

Other Parameters:

  • automatic_cleanup (bool) –

    if True, enables automatic cleanup of empty directories when deleting files. Defaults to False.

  • mkdir (bool) –

    if True and prefix is not None, the directory at prefix will attempt to be created. Note that this root directory will not be cleaned up, even if automatic_cleanup is True.

from_url classmethod

from_url(
    url: str, *, automatic_cleanup: bool = False, mkdir: bool = False
) -> LocalStore

Construct a new LocalStore from a file:// URL.

Examples:

Construct a new store pointing to the root of your filesystem:

url = "file:///"
store = LocalStore.from_url(url)

Construct a new store with a directory prefix:

url = "file:///Users/kyle/"
store = LocalStore.from_url(url)