LockedModel
- class LockedModel
A SysML v2/KerML model interface. Top level elements (typically Packages) can be accessed through the
lookupmethod, e.g.model.lookup("PackageName"). To create a new top level package use thenew_top_level_packagemethod.The object is invalidated once
unlocked, either explicitly or by leaving the outermostwith-block when used as a context manager.Note that
LockedModelis generally not intended to be instantiated directly. Ideally, use eitheropen_modelorempty_model. Alternatively, instantiateUnlockedModeland useUnlockedModel.lock.model : LockedModel = empty_model() ## Alternatively unlocked_model = open_model_unlocked(...) model : LockedModel = unlocked_model.lock()
Members defined in
LockedModel(9 members)
RDiagnostics generated when the model was loaded.
If
pathis empty, yields the (unique) top-level owned member element with namenameif it exists, otherwise returnsNone. Note that elements other than owned member elements, such as imported or inherited ones, are not taken into account.
Creates a (named) new top level package.
Creates a (named) new top level package.
Yields all top level named elements (typically Packages) that are owned members of a root namespace in the model. Note that imported members are not taken into account.
Yields top level owned member elements (typically Packages) loaded from the specified path(or from files below that path if it is a directory). Note that imported members are not taken into account.
Yields all named top level named elements (typically Packages) that are owned members of a root namespace in the model, together with (one of) their names. Note that imported members are not taken into account.
Yields names of all top level named elements (typically Packages) that are owned members of a root namespace in the model. Note that imported members are not taken into account.
Unlocks the model, freeing it up for others to lock.
Attributes
- property diagnostics: syside.Diagnostics
Diagnostics generated when the model was loaded.
Methods
- lookup(name: str, *path: str) syside.Element | None
If
pathis empty, yields the (unique) top-level owned member element with namenameif it exists, otherwise returnsNone. Note that elements other than owned member elements, such as imported or inherited ones, are not taken into account.Otherwise
.lookup(name, name, path1, ..., pathn)is equal to.lookup(name).lookup(path1).[...].lookup(pathn), unless any intermediate value isNone. If any intermediate value isNonethe whole expression evaluates toNone.- Parameters:
name – name of element to find
path – sequence of names to (recursively) lookup
- Returns:
(unique) element with name
nameor None (if not found)- Raises:
RuntimeError – if used after unlocking
TypeError – if trying to recursively look-up into a non-
Namespaceelement.NameError – if the name is ambiguous.
- new_top_level_library_package(name: str) syside.LibraryPackage
Creates a (named) new top level package.
- Parameters:
name – name of the new package
- Returns:
a new
syside.LibraryPackagenamedname(in a new global namespace)- Raises:
RuntimeError – if used after unlocking
- new_top_level_package(name: str) syside.Package
Creates a (named) new top level package.
- Parameters:
name – name of the new package
- Returns:
a new
syside.Packagenamedname(in a new global namespace)- Raises:
RuntimeError – if used after unlocking
- top_elements() Iterator[syside.Element]
Yields all top level named elements (typically Packages) that are owned members of a root namespace in the model. Note that imported members are not taken into account.
- Returns:
sequence of top level elements
- Raises:
RuntimeError – if used after unlocking
- top_elements_from(path: str | pathlib.Path) Iterator[syside.Element]
Yields top level owned member elements (typically Packages) loaded from the specified path(or from files below that path if it is a directory). Note that imported members are not taken into account.
- Parameters:
path – source file or directory path to return elements loaded from
- Returns:
sequence of (top) model elements loaded from source file(s) matching
path- Raises:
RuntimeError – if used after unlocking
- top_named_elements() Iterator[tuple[str, syside.Element]]
Yields all named top level named elements (typically Packages) that are owned members of a root namespace in the model, together with (one of) their names. Note that imported members are not taken into account.
Prefers name over short name.
- Returns:
sequence of (name, element) pairs of named top level elements
- Raises:
RuntimeError – if used after unlocking
- top_names() Iterator[str]
Yields names of all top level named elements (typically Packages) that are owned members of a root namespace in the model. Note that imported members are not taken into account.
Prefers name over short name.
- Returns:
sequence of names of named top level elements
- Raises:
RuntimeError – if used after unlocking
- unlock() syside.preview.UnlockedModel
Unlocks the model, freeing it up for others to lock.
- Returns:
UnlockedModelthat can be used to re-acquire access to the model- Raises:
RuntimeError – if used after unlocking