acquaint.store#
Where records live and how code reaches them: the data root, Store and Entity.
Layout under the data root (one folder per entity, one entry file each):
POLICY.md what may be recorded
_tombstones.yaml salted hashes of forgotten entities' identifiers
people/<slug>/PROFILE.md the entry file (required)
people/<slug>/identities.yaml, rules.yaml, links.yaml, trust.yaml, style.md, views.md,
sources.md, log/YYYY-MM.md, research/… (each optional)
projects/<slug>/PROFILE.md (and orgs/, groups/, or any other kind)
Store is a MutableMapping[str, Entity] keyed "<kind dir>/<slug>", where
both parts are lowercase letters, digits and hyphens; nothing else is a key, so no
reference can reach outside the data root. Underneath it is any
MutableMapping[str, str] of relative paths to text: a dol files store by
default, a dict in tests. That mapping is the storage seam.
When the store is on disk, an entity is a real directory whose name matches its key
exactly (case included, even on case-insensitive filesystems) and is not a link.
Listing, moving and removing work on those directories, so hidden files move and go
with their entity. A file that is not valid UTF-8 reads with replacement characters and
is reported, instead of failing every lookup. Entry files the store cannot address (a
capitalised folder, a linked folder, profile.md) are listed by Store.misnamed().
>>> store = Store(files={})
>>> store["people/ada-lovelace"] = {"PROFILE.md": "---\nname: Ada Lovelace\n---\n"}
>>> list(store), store["people/ada-lovelace"].name
(['people/ada-lovelace'], 'Ada Lovelace')
Module Attributes
see |
|
What undecodable bytes read as. |
Functions
|
|
|
The data root: the argument, else |
|
The folder for a kind: |
|
A |
|
Return |
Classes
|
One person, project, org or group: a mapping of its files (relative names to text), plus parsed views of them. |
|
|
Exceptions
An expected failure with a message meant for the person or agent that asked. |
- exception acquaint.store.AcquaintError[source]#
Bases:
ExceptionAn expected failure with a message meant for the person or agent that asked.
- class acquaint.store.Entity(store, key)[source]#
Bases:
MutableMappingOne person, project, org or group: a mapping of its files (relative names to text), plus parsed views of them.
Parsed views are recomputed on access (these are small text files), so an edit made through the mapping is never hidden behind a stale cache. Parse problems are collected in
errors; they never raise.- property aka: list[str]#
Other names this entity goes by, as strings (a scalar
akais one alias, not its letters).
- property identities: list[dict]#
{platform, value, source, status, …}.- Type:
Handles and addresses from
identities.yaml
- property links: list[dict]#
{to, relation, role, since, until, source}.- Type:
Affiliations from
links.yaml
- property rules: list[dict]#
{when, do, set_by, source}.- Type:
Channel and communication rules from
rules.yaml
- property surface_forms: list[str]#
id, name, aka, name parts, handles.
- Type:
Every string a document might use for this entity
- text(name, default='')[source]#
A file’s text, or
defaultwhen the file does not exist.- Return type:
- property trust: list[dict]#
{tier, valid_from, valid_to, review_by, recorded, source, note}(seeacquaint.trust).- Type:
Disclosure tiers from
trust.yaml
- acquaint.store.KIND_DIRS = {'group': 'groups', 'org': 'orgs', 'person': 'people', 'project': 'projects'}#
see
kind_dir().- Type:
The kinds that ship, singular -> folder. The vocabulary is open
- class acquaint.store.Store(data_dir=None, *, files=None)[source]#
Bases:
MutableMappingMutableMapping[str, Entity]over one folder per entity, keyed"<kind dir>/<slug>".>>> store = Store(files={}) >>> store["projects/example"] = {"PROFILE.md": "---\nname: Example\n---\n"} >>> store.find("project:example"), store.find("example") ('projects/example', 'projects/example')
- append_text(key, name, text)[source]#
Append to one of an entity’s files (created if missing); a true append on disk, so concurrent writers do not erase each other.
- Return type:
- exists(key)[source]#
Whether anything is stored under the entity’s folder, with or without an entry file.
- Return type:
- find(ref)[source]#
The store key for
people/ada-lovelace,person:ada-lovelaceor a bareada-lovelace.A bare id that names entities of two kinds is an error: say which, e.g.
project:atlas. Anything that is not a valid key raisesKeyError, so no reference reaches outside the data root.- Return type:
- find_id(slug)[source]#
Every key whose id is
slug, in any kind (ids are lowercase, so the lookup is too).
- location_warning()[source]#
A warning when the data root is, or sits inside, a git repository that is not an acquaint store.
- misnamed()[source]#
Entry files on disk the store cannot address: a folder or file name not in lowercase
kind/id/PROFILE.mdform, or a linked folder.
- acquaint.store.UNREADABLE = '�'#
What undecodable bytes read as. A file containing it is reported as not valid UTF-8.
- acquaint.store.config_path()[source]#
~/.config/acquaint/config.toml(honouringXDG_CONFIG_HOME;%APPDATA%on Windows).- Return type:
- acquaint.store.data_dir(data_dir=None)[source]#
The data root: the argument, else
$ACQUAINT_DATA_DIR, elsedata_dirin config.toml, else~/.local/share/acquaint.An explicit argument may be relative (it is resolved now). The environment variable and the config file must hold absolute paths: a relative one would put profiles wherever the current directory happens to be.
- Return type:
>>> data_dir("profiles").is_absolute() True
- acquaint.store.kind_dir(kind)[source]#
The folder for a kind:
person/people->people; an unknown kind is used as given, pluralised.- Return type:
>>> [kind_dir(k) for k in ("person", "people", "org", "community", "teams")] ['people', 'people', 'orgs', 'communities', 'teams']
- acquaint.store.text_files(root)[source]#
A
dolfiles store underroot, for text.UTF-8 values (undecodable bytes read as U+FFFD instead of raising; a byte-order mark dropped),
\nline endings,/-separated keys on every platform, folders made on write and never on read, and permanent deletes (never to a trash folder, where “forgotten” data would linger).- Return type:
- acquaint.store.validate_key(key)[source]#
Return
keyif it is<kind dir>/<slug>of lowercase letters, digits and hyphens; refuse anything else.- Return type:
>>> validate_key("people/ada-lovelace") 'people/ada-lovelace' >>> try: ... validate_key("../outside/people/someone") ... except AcquaintError as error: ... print(error) not a store key: '../outside/people/someone' (expected <kind>/<id>, e.g. people/ada-lovelace)