DocumentNode¶
- class dsviper.DocumentNode¶
Bases:
objectOne node of a document seen as a tree.
Carries its component name, its value, its type, and what a renderer needs to decide: editable, expandable, and which concrete type it holds.
Note: Not directly instantiable.
- attachment() Attachment¶
Return the attachment the document belongs to.
- children() list[DocumentNode]¶
Return the nodes one level below this one.
- static create_documents(key: ValueKey, attachment_getting: AttachmentGetting) list[DocumentNode]¶
Return the root DocumentNode of each document filed under key.
- document() Value¶
Return the whole document this node is part of: the Value stored under the key, from which the tree was built.
- is_blob_id() bool¶
Return True if the node holds a blob_id.
- is_boolean() bool¶
Return True if the node holds a boolean.
- is_collection() bool¶
Return True if the node holds a collection.
A vector, a map, a set, an optional, an xarray or an any.
Every collection is also a container. A structure, a vec, a mat, a tuple, a map entry and a variant are containers that are not collections.
- is_container() bool¶
Return True if the node stands for a value that holds other nodes.
Every kind but a primitive, an enumeration and a key: a structure, a vec, a mat, a tuple, a vector, a set, a map and its entries, an optional, an xarray, an any and a variant. Its value() is that container, and string_value() summarises it.
- is_double() bool¶
Return True if the node holds a double.
- is_editable() bool¶
Return True if the node carries a value a UI may write - not a container, and not read-only.
- is_enumeration() bool¶
Return True if the node holds an enumeration.
- is_expandable() bool¶
Return True if the node has children to unfold.
- is_float() bool¶
Return True if the node holds a float.
- is_int16() bool¶
Return True if the node holds an int16.
- is_int32() bool¶
Return True if the node holds an int32.
- is_int64() bool¶
Return True if the node holds an int64.
- is_int8() bool¶
Return True if the node holds an int8.
- is_integer() bool¶
Return True if the node holds an integer.
- is_key() bool¶
Return True if the node holds a ValueKey - the type, not the key this document is filed under.
- is_numeric() bool¶
Return True if the node holds a number.
- is_primitive() bool¶
Return True if the node’s kind is ‘Primitive’.
A boolean, a number, a string, a uuid, a blob id, a commit id or a blob.
An enumeration and a key are kinds of their own: they answer False here and False to is_container() too - is_enumeration() and is_key() name them.
- is_readonly() bool¶
Return True if the node refuses a write.
is_editable() is the one a UI binds to: a value a UI may write - not a container, and not read-only.
- is_real() bool¶
Return True if the node holds a real.
- is_string() bool¶
Return True if the node holds a string.
- is_uint16() bool¶
Return True if the node holds a uint16.
- is_uint32() bool¶
Return True if the node holds a uint32.
- is_uint64() bool¶
Return True if the node holds a uint64.
- is_uint8() bool¶
Return True if the node holds a uint8.
- is_uuid() bool¶
Return True if the node holds a uuid.
- parent() DocumentNode | None¶
Return the parent, or None at the root of a document.
- string_component() str¶
Return the label for the node itself: a field name, an index, a map key, or, at the root, the identifier of the attachment the document is filed under. An element of a set has no label and answers ‘-‘.
- string_component_tooltip() str¶
Return the tooltip for the component label: the type representation.
- string_path() str¶
Return the path, rendered for display.
- string_type() str¶
Return the type of the value, rendered for display.
- string_value() str¶
Return the value rendered for display.
A vector, a map or an xarray answers its size (‘2 elements’, ‘1 entry’), an optional or an any whether it holds a value and of which type, a vec, a mat, a tuple or a map entry its representation. A structure answers its representation when its fields are all booleans or numbers, and ‘-’ otherwise; a set answers ‘-‘.
- string_value_tooltip() str¶
Return the tooltip for the value label.
The element type below a vec, a mat, a vector, a set or a map; the key type and the element type for the key and the value of a map entry; the detailed type for a key. Anywhere else, the same text as string_path().
- type() str¶
Return the kind of node.
One of ‘Primitive’, ‘Vec’, ‘Mat’, ‘Tuple’, ‘Optional’, ‘Vector’, ‘Set’, ‘Map’, ‘MapEntry’, ‘XArray’, ‘Any’, ‘Variant’, ‘Enumeration’, ‘Structure’ or ‘Key’.
Not the type of the value, which is string_type().