livery.strongroom._version¶
livery.strongroom._version ¶
The version: provenance over a tree, git's commit with a subject.
A version names a tree, its parents, what produced it, when, a message, the receipt of the call that produced it when there is one, and attachments: blobs a consumer hangs on the version without touching the tree. Its digest is the digest of its canonical JSON.
Reach for livery.strongroom.Version.
Classes:
| Name | Description |
|---|---|
Version |
Provenance over a tree. |
Version
dataclass
¶
Version(tree: Digest, parents: tuple[Digest, ...], producer: Subject, created: str, message: str, receipt: Digest | None = None, attachments: Mapping[str, Digest] = dict())
Provenance over a tree.
Attributes:
| Name | Type | Description |
|---|---|---|
tree |
Digest
|
the content. |
parents |
tuple[Digest, ...]
|
the versions this one continues, in order. |
producer |
Subject
|
who or what produced it. |
created |
str
|
when, as an RFC 3339 UTC instant. |
message |
str
|
free text. |
receipt |
Digest | None
|
the receipt of the producing call, or None. |
attachments |
Mapping[str, Digest]
|
name to blob digest, for a consumer's own metadata. Names obey the portable-name rules. |
Methods:
| Name | Description |
|---|---|
__post_init__ |
|
to_json |
The version as a JSON object. |
from_json |
Decode a version from its JSON value. |
encode |
The version's canonical JSON bytes, which its digest names. |
decode |
Decode a version from its stored bytes. |
digest |
The version's name: the digest of its canonical JSON. |
attachments
class-attribute
instance-attribute
¶
__post_init__ ¶
to_json ¶
The version as a JSON object.
Source code in packages/strongroom/src/livery/strongroom/_version.py
from_json
classmethod
¶
Decode a version from its JSON value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Value
|
the JSON value. |
required |
Returns:
| Type | Description |
|---|---|
Version
|
The version. |
Raises:
| Type | Description |
|---|---|
FormatError
|
when the shape or a field is wrong. |
Source code in packages/strongroom/src/livery/strongroom/_version.py
decode
classmethod
¶
Decode a version from its stored bytes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes
|
the object's bytes. |
required |
Returns:
| Type | Description |
|---|---|
Version
|
The version. |
Raises:
| Type | Description |
|---|---|
FormatError
|
when the bytes are not JSON, not a version, or not canonical. |