vibesketch.document.io¶
Read and write .vsk files.
A document is UTF-8 JSON, indented by two spaces, with a trailing newline,
so a .vsk diffs cleanly under version control. Writing is atomic: the
file is written beside its target and renamed over it, so an interrupted
save never leaves half a document.
Module Attributes
|
The file extension of a vibe-sketch document. |
Functions
|
The document as |
|
Validate already-parsed JSON data as a document. |
|
Read and validate a document: a |
|
Parse and validate a document from JSON text. |
|
An empty document stamped with this application and the current time. |
|
Write |
|
Readable |
|
|
Exceptions
|
A document that is not valid JSON or not a valid vibe-sketch document. |
- exception vibesketch.document.io.DocumentError(errors)¶
Bases:
ValueErrorA document that is not valid JSON or not a valid vibe-sketch document.
errorslists every problem as"location: message", the form the CLI prints and the REST API returns.
- vibesketch.document.io.dumps(document)¶
The document as
.vsktext.
- vibesketch.document.io.load(path)¶
Read and validate a document: a
.qvfarchive or a.vskfile.
- vibesketch.document.io.loads(text)¶
Parse and validate a document from JSON text.
- vibesketch.document.io.new_document(app=None)¶
An empty document stamped with this application and the current time.
- vibesketch.document.io.save(document, path)¶
Write
documenttopathatomically; returns the path written.A
.qvfpath gets a QVF archive (raisingQvfUnavailablewithout qvf-writer), any other a.vsk. A file that exists keeps its permissions; a new one gets the umask’s.
- vibesketch.document.io.validation_errors(error)¶
Readable
location: messagelines for a pydantic validation error.
- vibesketch.document.io.with_edit(document, *, actor, client, summary)¶
documentwith an edit recorded for its next revision.A run of alike edits (same actor, client and summary) folds into one entry, so a drawing session does not leave hundreds. The revision itself is the caller’s to advance: the server’s store does it on commit.