DefinitionsConst

class dsviper.DefinitionsConst

Bases: object

Retrieves registered types and attachments by runtime id.

Note: Not directly instantiable.

attachment_runtime_ids() → ValueSet[ValueUUId]

Return the set of runtime ID for all attachments.

attachments() → list[Attachment]

Return the list of attachments.

check_attachment(attachment_runtime_id: ValueUUId) → Attachment

Return the attachment registered under attachment_runtime_id, or raise if none is.

check_club(runtime_id: ValueUUId) → TypeClub

Return the club registered under runtime_id, or raise if none is.

check_concept(runtime_id: ValueUUId) → TypeConcept

Return the concept registered under runtime_id, or raise if none is.

check_enumeration(runtime_id: ValueUUId) → TypeEnumeration

Return the enum registered under runtime_id, or raise if none is.

check_structure(runtime_id: ValueUUId) → TypeStructure

Return the struct registered under runtime_id, or raise if none is.

check_type(runtime_id: ValueUUId) → Type

Return the type registered under runtime_id, or raise if none is.

club_runtime_ids() → ValueSet[ValueUUId]

Return the set of runtime ID for all clubs.

clubs() → list[TypeClub]

Return the list of clubs.

collector() → DefinitionsCollector

Return an empty DefinitionsCollector bound to these definitions, to feed extract() with.

concept_members(type_concept: TypeConcept) → list[TypeConcept]

Return the concepts a key of type_concept accepts: type_concept and its descendants. A club’s membership plays no part.

concept_runtime_ids() → ValueSet[ValueUUId]

Return the set of runtime ID for all concepts.

concepts() → list[TypeConcept]

Return the list of concepts.

contains(definitions: DefinitionsConst) → bool

Return True if every type and attachment of definitions is already registered here.

copy() → Definitions

Return a mutable Definitions holding the same types and attachments - the way out of the const view. Nothing done to it reaches this one.

discard(namespace: dict | None = None) → None

Remove from a Python namespace the objects inject bound for these definitions. A name bound to anything else is left as it is. None means the __main__ module.

encode(*, stream_codec_instancing: StreamCodecInstancing | None = None) → ValueBlob

Return the blob that encodes the definitions with Codec.STREAM_TOKEN_BINARY if not specified.

enumeration_runtime_ids() → ValueSet[ValueUUId]

Return the set of runtime ID for all enums.

enumerations() → list[TypeEnumeration]

Return the list of enums.

extract(definitions_collector: DefinitionsCollector) → Definitions

Return a new Definitions holding only the types definitions_collector gathered, and the types those depend on.

hexdigest() → str

Return the SHA1 of the definitions, as a hex string.

It hashes the sorted runtime ids of the concepts, clubs, enumerations, structures and attachments. A runtime id covers neither documentation nor a club’s members, so two Definitions differing only there share it.

inject(namespace: dict | None = None) → None

Bind, in a Python namespace - a module, or the dict globals() answers - one object per namespace of the definitions, named as they name it. None means the __main__ module; in an embedded editor, pass globals().

The object holds the namespace’s types under their names, and three views: keys, a concept’s or a club’s key type by its name; attachments, by key concept then name; paths, a structure’s field paths by structure then field. Tuto.User, Tuto.keys.User, Tuto.attachments.User.login, Tuto.paths.Login.nickname. A key concept of another namespace takes that namespace in front: App.attachments.Lib_User.profile.

A name the namespace already binds to something inject did not bind raises ValueError, as do a type named keys, attachments or paths and two key concepts meeting under one name; nothing is bound then. What a previous inject bound under the same name is replaced.

is_equal(definitions: DefinitionsConst) → bool

Return True if definitions holds the same types and attachments.

By runtime ids, so two registries built apart from the same model answer True; documentation and club memberships are not compared. Comparing hexdigest() answers the same question on a string, which is what travels between processes.

query_attachment(attachment_runtime_id: ValueUUId) → Attachment | None

Return the attachment registered under attachment_runtime_id, or None if none is.

query_club(runtime_id: ValueUUId) → TypeClub | None

Return the club registered under runtime_id, or None if none is.

query_concept(runtime_id: ValueUUId) → TypeConcept | None

Return the concept registered under runtime_id, or None if none is.

query_enumeration(runtime_id: ValueUUId) → TypeEnumeration | None

Return the enum registered under runtime_id, or None if none is.

query_structure(runtime_id: ValueUUId) → TypeStructure | None

Return the struct registered under runtime_id, or None if none is.

query_type(runtime_id: ValueUUId) → Type | None

Return the type registered under runtime_id, or None if none is.

query_types(name: str) → list[Type]

Return every type whose name is name, across all namespaces.

runtime_ids() → ValueSet[ValueUUId]

Return the set of runtime ID for all registered types.

structure_runtime_ids() → ValueSet[ValueUUId]

Return the set of runtime ID for all structs.

structures() → list[TypeStructure]

Return the list of structs.

to_dsm_definitions() → DSMDefinitions

Convert and return a DSMDefinitions.

types() → list[Type]

Return the topologically sorted list of types.

write(stream_writing: StreamWriting) → None

Write to a stream.