Skip to content

trudag.dotstop.core.item

Classes for managing the items in a TrustableGraph.

Item

Item(
    name: str,
    text: str = "",
    normative: bool = True,
    unresolved_references: list[BaseReference]
    | None = None,
    resolved_references: list[ResolvedReference]
    | None = None,
    validator_config: dict | None = None,
    sme_scores: dict[str, float | dict[str, float | str]]
    | float
    | None = None,
    fallacies: dict[str, Fallacy] | None = None,
    order: ItemOrder | None = None,
)

A representation for a falsifiable statement and its associated properties.

document property

document: str

Document group the item belongs to.

name property

name: str

The name of the item constructed from two parts, separated by a hyphen: DOCUMENT-ID

  • DOCUMENT is the document prefix and may contain any alphanumeric or special character expect . and ". Items with the same document prefix are grouped together in a TrustableGraph.
  • ID is used to uniquely identify the item within a document. ID may contain any alphanumeric or special character except . and -.
Example

Item with a name TSF-ITEM_1 is within the TSF document, uniquely identified in this document as ITEM_1.

normative property

normative: bool

Whether the item represents a normative statement.

sha property

sha: str

The sha256 checksum of the item.

sha256 cached property

sha256: bytes

The sha256 digest of the item.

text property

text: str

The statement associated with a normative item. If the item is not normative this can be any text.

add_namespace

add_namespace(namespace: str) -> None

Namespaces the item by prepending its name with the namespace name, followed by a ..

deserialise

deserialise(data: dict) -> Item

Deserialise a dictionary of data into an item.

has_validator

has_validator() -> bool

Returns True if item has an associated validation config.

header

header(include_name: bool = True) -> str

A short text summary of the item, containing more information than the name.

Parameters:

Name Type Description Default
include_name bool

Prepend the item's name to the header.

True

references

references() -> list[ResolvedReference]

Returns references in resolved form.

Unresolved references are resolved lazily, This is an in-place operation, the unresolved state is lost.

serialise

serialise() -> dict

Serialise the item into a dictionary.

serialise_as_need

serialise_as_need() -> dict

Serialise the item, as a need, into a dictionary.

sha_link(child: Item) -> str

A sha256 checksum of the link between two items.

validation

validation(validator: Validator) -> dict[str, Any]

Computes the validator score for the item if there exists a validator config and returns the validation result object.

ItemOrder dataclass

ItemOrder(group: str | None, order: list[int] | None)

Storage for item ordering properties.

create_default_item_markdown

create_default_item_markdown(name: str, dir: Path) -> Item

Create a default item, writes it in markdown in dir.

item_from_markdown

item_from_markdown(
    item_name: str,
    md_content: str,
    reference_builder: ReferenceBuilder = ReferenceBuilder(),
) -> Item

Creates an item from markdown content.

migrate_to_versioned_schema

migrate_to_versioned_schema(data: dict | tuple) -> dict

This is a conversion function for artifact schemas before the addition of artifact version to be compatible with the artifact schemas after the addition of artifact version This should be removed in the next release, see : https://gitlab.eclipse.org/eclipse/tsf/tsf/-/issues/492

need_as_markdown

need_as_markdown(item: Item, namespace: str) -> str

Creates a markdown string for a needs item.