Backends¶
qcstore.Backend
¶
The operations a store needs of the medium holding its files.
Paths are relative POSIX paths. Names starting with . are the backend's own
(temporary files) and never listed.
append
¶
append(path: str, data: bytes) -> None
Append bytes to a file, creating it; each call's bytes stay contiguous.
Source code in src/qcstore/backend.py
51 52 53 | |
delete
¶
delete(path: str) -> None
Remove a file if it exists.
Source code in src/qcstore/backend.py
63 64 65 | |
exists
¶
exists(path: str) -> bool
Whether a file or directory exists.
Source code in src/qcstore/backend.py
55 56 57 | |
get
¶
get(path: str, start: int = 0) -> bytes
Return a file's bytes from offset start to its end.
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
No such file. |
Source code in src/qcstore/backend.py
28 29 30 31 32 33 34 | |
list
¶
list(path: str) -> list[str]
The names directly inside a directory, sorted; empty if it does not exist.
Source code in src/qcstore/backend.py
59 60 61 | |
put
¶
put(
path: str, data: bytes, *, replace: bool = False
) -> None
Write a file atomically, creating its directories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The file. |
required |
data
|
bytes
|
Its contents. |
required |
replace
|
bool
|
Replace the file if it exists. Otherwise an existing file is left
as it is and |
False
|
Raises:
| Type | Description |
|---|---|
FileExistsError
|
The file exists and |
Source code in src/qcstore/backend.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
qcstore.LocalBackend
¶
LocalBackend(root: str | PathLike[str])
Files in a directory on a local disk or a network filesystem (NFS).
Writes go to a hidden temporary file beside the target, are flushed to disk, and are then renamed into place (to replace) or hard-linked into place (to create exclusively). Both are atomic on POSIX filesystems and on NFS, so concurrent writers on several machines need no locks.
Attributes:
| Name | Type | Description |
|---|---|---|
root |
Path
|
The store's directory. |
Source code in src/qcstore/backend.py
80 81 82 | |
append
¶
append(path: str, data: bytes) -> None
Append bytes with one write to a file opened for appending.
Source code in src/qcstore/backend.py
117 118 119 120 121 122 123 124 125 126 127 | |
delete
¶
delete(path: str) -> None
Remove a file if it exists.
Source code in src/qcstore/backend.py
141 142 143 | |
exists
¶
exists(path: str) -> bool
Whether a file or directory exists.
Source code in src/qcstore/backend.py
129 130 131 | |
get
¶
get(path: str, start: int = 0) -> bytes
Return a file's bytes from offset start to its end.
Source code in src/qcstore/backend.py
94 95 96 97 98 | |
list
¶
list(path: str) -> list[str]
The visible names directly inside a directory, sorted.
Source code in src/qcstore/backend.py
133 134 135 136 137 138 139 | |
put
¶
put(
path: str, data: bytes, *, replace: bool = False
) -> None
Write a file atomically: a flushed temporary file, renamed or linked in.
Source code in src/qcstore/backend.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |