Skip to content

livery.workshop._store_tasks

livery.workshop._store_tasks

fm store.ls and fm store.show: the state store, read by hand.

Every row the workshop keeps is a declared series of the state store (livery.git), gathered in one place (livery.workshop._series). store.ls names each series and family with its scope (local, or remote and mirrored by a sync, or remote and fetched on read), its window, and what it holds; store.show prints a series' rows newest first through the same reader the verdicts use, so what a person reads is what the gate judged. Both only read: the gate's verbs write, and the janitor bounds.

Functions:

Name Description
ls_flow

One line per declared series or family: scope, window, and what it holds.

show_flow

A series' rows newest first, a family's by its key, or the rows as JSON.

store_ls

List every series the workshop keeps: its scope, its window, what it holds.

store_show

Print a series' rows newest first, through the reader the verdicts use.

Attributes:

Name Type Description
store

store module-attribute

store = group('store', help='The state store, read by hand')

ls_flow

ls_flow(root: Path) -> list[str]

One line per declared series or family: scope, window, and what it holds.

One listing of the remote namespace and one fetch of what the checkout lacks serve every series, so the call costs two round trips whatever the store holds.

Source code in packages/workshop/src/livery/workshop/_store_tasks.py
def ls_flow(root: Path) -> list[str]:
    """One line per declared series or family: scope, window, and what it holds.

    One listing of the remote namespace and one fetch of what the
    checkout lacks serve every series, so the call costs two round
    trips whatever the store holds.
    """
    with git.remote_snapshot(state_store(root), fetch=git.WHOLE):
        return _ls_lines(root)

show_flow

show_flow(root: Path, name: str, *, key: str = '', as_json: bool = False) -> list[str]

A series' rows newest first, a family's by its key, or the rows as JSON.

Refuses an unknown name (naming the known ones), a family without its key (listing the keys it holds), a key of the wrong shape, and a series the store cannot read (with the store's reason). The read goes through one listing of the remote namespace.

Source code in packages/workshop/src/livery/workshop/_store_tasks.py
def show_flow(
    root: Path, name: str, *, key: str = "", as_json: bool = False
) -> list[str]:
    """A series' rows newest first, a family's by its key, or the rows as JSON.

    Refuses an unknown name (naming the known ones), a family without
    its key (listing the keys it holds), a key of the wrong shape, and
    a series the store cannot read (with the store's reason). The
    read goes through one listing of the remote namespace.
    """
    with git.remote_snapshot(state_store(root), fetch=(name,)):
        return _show_lines(root, name, key=key, as_json=as_json)

store_ls

store_ls() -> None

List every series the workshop keeps: its scope, its window, what it holds.

A remote series is read from origin, a local one from this checkout's git directory; a series that cannot be read prints the store's reason in its place.

Source code in packages/workshop/src/livery/workshop/_store_tasks.py
@store.task(name="ls")
def store_ls() -> None:
    """List every series the workshop keeps: its scope, its window, what it holds.

    A remote series is read from origin, a local one from this
    checkout's git directory; a series that cannot be read prints the
    store's reason in its place.
    """
    for line in ls_flow(_root()):
        print(line)

store_show

store_show(series: Annotated[str, doc("the series' name, as store.ls lists it")], key: Annotated[str, doc("a family's key, its parts comma-separated")] = '', json: Annotated[bool, doc('the rows as JSON, newest first')] = False) -> None

Print a series' rows newest first, through the reader the verdicts use.

Each row prints as its file name and stamp, then its fields on one line with containers by size; --json prints every field as it is. A family (store.ls shows its key parts) is shown one key at a time, and without --key lists the keys it holds.

Source code in packages/workshop/src/livery/workshop/_store_tasks.py
@store.task(name="show")
def store_show(
    series: Annotated[str, doc("the series' name, as store.ls lists it")],
    key: Annotated[str, doc("a family's key, its parts comma-separated")] = "",
    json: Annotated[bool, doc("the rows as JSON, newest first")] = False,
) -> None:
    """Print a series' rows newest first, through the reader the verdicts use.

    Each row prints as its file name and stamp, then its fields on one
    line with containers by size; ``--json`` prints every field as it
    is. A family (``store.ls`` shows its key parts) is shown one key at
    a time, and without ``--key`` lists the keys it holds.
    """
    for line in show_flow(_root(), series, key=key, as_json=json):
        print(line)