annals.store#
The document store: a flat set of documents, tags, groups and a recycle bin, as plain files.
Layout under the data root (local or remote, see annals.target):
docs/<id>/meta.json one document: metadata
docs/<id>/<main file> its content (index.html, report.md, ...), plus any assets
trash/<id>/... the same shape; the recycle bin is a move
groups/<gid>.json a named, ordered list of document ids with its own URL
Flat on purpose: agents from many corpora do not share a hierarchy, and every placement
decision costs tokens. Tags and groups carry the structure. Ids are time-sortable and
readable (20261003-203301-starwars-theme-report-3f9a), so a listing is already in
publication order and a URL says what it points to.
Plain files, written whole, because the same tree is written by rsync from another machine and read by the server; there is no index to keep consistent.
Module Attributes
hidden files, caches, compiled python |
Functions
|
Raise |
|
The rendering kind of a file, from its extension. |
|
|
|
UTC timestamp with second precision, the format every meta.json uses. |
|
Lowercase ascii words joined by hyphens; empty input becomes |
Classes
|
Publish, list, read, trash, restore and group documents on a |
- annals.store.DFLT_EXCLUDE = ('.*', '__pycache__', '*.pyc', '*.pyo')#
hidden files, caches, compiled python
- Type:
names never published from a directory
- class annals.store.DocStore(target)[source]#
Bases:
objectPublish, list, read, trash, restore and group documents on a
Target.- add_to_group(gid, doc_ids)[source]#
Append ids to an existing group, keeping order and skipping duplicates.
- Return type:
- list(*, trash=False)[source]#
Every document’s meta, newest first (ids sort by time;
createdbreaks ties).
- make_group(title, doc_ids, *, gid=None)[source]#
Create (or overwrite) a group: a titled, ordered list of document ids.
- Return type:
- meta(doc_id)[source]#
One document’s meta;
in_trashsays which side of the bin it is on.- Return type:
- publish(*sources, title=None, tags=(), source=None, text=None, filename='document.md', exclude=('.*', '__pycache__', '*.pyc', '*.pyo'))[source]#
Publish files (or a directory, or
text) as ONE document; return its meta.One markdown or html file is the common case. A directory is published whole, with
index.html(or the first renderable file) as the page shown.textpublishes a string asfilenameinstead of reading sources.excludelists glob patterns skipped inside a directory (hidden files and caches by default;()keeps all).- Return type:
- read_text(doc_id, rel=None)[source]#
A document’s main file (or one of its files) as text.
- Return type:
- annals.store.check_id(doc_id)[source]#
Raise
ValueErroron an id that could not have come frommk_id().- Return type:
- annals.store.kind_of(filename)[source]#
The rendering kind of a file, from its extension.
- Return type:
- annals.store.mk_id(title, *, when=None)[source]#
YYYYMMDD-HHMMSS-<slug>-<4 hex>: sortable by time, readable in a URL.- Return type: