DbsTemplate

dbs_classes.DbsTemplate(self, database: IDatabase)

Methods

Name Description
check_higher_level_usage Check if an object is used in a higher level object.
copy Copy (duplicate) an existing object, and give it a new name.
delete Delete an already existing object in the database.
edit Edit an already existing object in the database.
get Return an object of the type of the database with the given name.
list_objects Return a dictionary with info on the objects that currently exist in the database.
save Save an object in the database and all associated files.

check_higher_level_usage

dbs_classes.DbsTemplate.check_higher_level_usage(name: str)

Check if an object is used in a higher level object.

Parameters

name : str

name of the object to be checked

Returns

: list[str]

list of higher level objects that use the object

copy

dbs_classes.DbsTemplate.copy(old_name: str, new_name: str, new_description: str)

Copy (duplicate) an existing object, and give it a new name.

Parameters

old_name : str

name of the existing measure

new_name : str

name of the new measure

new_description : str

description of the new measure

delete

dbs_classes.DbsTemplate.delete(name: str, toml_only: bool = False)

Delete an already existing object in the database.

Parameters

name : str

name of the object to be deleted

toml_only : bool = False

whether to only delete the toml file or the entire folder. If the folder is empty after deleting the toml, it will always be deleted. By default False

Raises

: ValueError

Raise error if object to be deleted is already in use.

edit

dbs_classes.DbsTemplate.edit(object_model: T_OBJECTMODEL)

Edit an already existing object in the database.

Parameters

object_model : Object

object to be edited in the database

Raises

: ValueError

Raise error if name is already in use.

get

dbs_classes.DbsTemplate.get(name: str)

Return an object of the type of the database with the given name.

Parameters

name : str

name of the object to be returned

Returns

: Object

object of the type of the specified object model

list_objects

dbs_classes.DbsTemplate.list_objects()

Return a dictionary with info on the objects that currently exist in the database.

Returns

: dict[str, list[Any]]

A dictionary that contains the keys: name, ‘path’, ‘last_modification_date’, ‘description’, ‘objects’ Each key has a list of the corresponding values, where the index of the values corresponds to the same object.

save

dbs_classes.DbsTemplate.save(
    object_model: T_OBJECTMODEL,
    overwrite: bool = False,
)

Save an object in the database and all associated files.

This saves the toml file and any additional files attached to the object.

Parameters

object_model : Object

object to be saved in the database

overwrite : bool = False

whether to overwrite the object if it already exists in the database, by default False

Raises

: ValueError

Raise error if name is already in use.

Back to top