scistag.datastag.data_stag_vault.DataStagVault¶
- class DataStagVault[source]¶
Bases:
objectThe root access point to a DataStag
Initializer
Methods
Adds given value to the element stored in the database.
Executes a garbage collection removing outdated elements
Deletes an element :type name:
str:param name: The element's name :rtype:bool:return: True on successDeletes a set of elements.
Verifies if given element exists
Finds a list of elements by name :type mask:
str:param mask: The search mask.Tries to read an element from the database :type name:
str:param name: The element's name :type default:Union[str,bool,int,float,bytes,dict,list,ndarray,None] :param default: The default return value if the element does not exist :rtype:Union[str,bool,int,float,bytes,dict,list,ndarray,None] :return: The elementTries to read an element from the database.
Returns the local vault instance
Get the server's working time to compute the deprecation of elements :rtype:
float:return: Time offset since start in secondsReturns the database status :type advanced:
bool:param advanced: Defines if advanced details shall be received as well :return: A dictionary containing the statusReturns all sub folders of folder_name :param name: The main folder :param recursive: Defines if the search shall be recursive.
Returns the data of a set of elements by name.
Tries to receive a list of elements from the vault
Tries to retrieve the data of a list
Tries to remove an element at the beginning of a list :type name:
str:param name: The name's list :type default:Union[str,bool,int,float,bytes,dict,list,ndarray,None] :param default: The default return value if the list is empty or does not exist :type index:int:param index: The index from which the element shall be "popped".Appends an element at the end of a list :type name: str :param name: The element's name :type data: list[StagDataTypes] :param data: The data to be added.
Stores a named element in the database :type name: str :param name: The element's name :type data: StagDataTypes :param data: The data to be added.
Attributes
The sign which defines in which folder a key is located
__annotations____dict____doc____module____weakref__list of weak references to the object (if defined)
local_vaultA dictionary containing all elements
A folder based more fine grained search index
- _get_element_by_name(name, deprecation_time=None)[source]¶
Tries to retrieve a database element
- Parameters
- Return type
DataStagElement | None
- _get_global_name(folder_name, rel_name)[source]¶
Returns the global element name :param folder_name: The folder name :param rel_name: The relative element name :return: Combined global element name
- _get_list_instance(name)[source]¶
Tries to retrieve the element of the type list
- Parameters
name (str) – The element’s name
- Return type
DataStagList | None
- Returns
- _get_round_deprecation_time(dep_time)[source]¶
Returns the deprecation time rounded up to the next second as integer
- Parameters
dep_time (
float) – The deprecation time- Returns
Deprecation time in seconds
- _register_element(name, element)[source]¶
Registers a new element in the global map and the search tree
- Parameters
name (
str) – The element’s nameelement (
DataStagElement) – The element
- _remove_from_deprecation_list(element)[source]¶
Checks whether the element was already in a deprecation list and removes if from that one
- Parameters
element (
DataStagElement) – The element- Returns
True if the element was already existing and had to be removed
- _split_folder_and_name(name)[source]¶
Returns the element’s folder name defined by slashes
- Parameters
name – The elements name
- Returns
The folder and file name
- _update_deprecating_element(element, dep_time=None)[source]¶
Registers the element in the deprecation registry so it can automatically be destroyed once it’s outdated
- Parameters
element (
DataStagElement) – The elementdep_time (
Optional[float]) – The element’s new deprecation time
- add(name, value=1, timeout_s=None, default=0)[source]¶
Adds given value to the element stored in the database. If it does not exist yet, it will be initialized with default. :type name: str :param name: The element’s name :type value: float | int :param value: The value to be added :type timeout_s: float | None :param timeout_s: The timeout for automatic deletion :param default: The default value :rtype: float | int :return: The new value
- collect_garbage()[source]¶
Executes a garbage collection removing outdated elements
- Return type
- Returns
True if at least one time interval passed
- delete(name)[source]¶
Deletes an element :type name:
str:param name: The element’s name :rtype:bool:return: True on success
- delete_multiple(search_masks, recursive=False)[source]¶
Deletes a set of elements. :type search_masks:
list[str] :param search_masks: The element’s names or search masks. May not point directly to the root directory :type recursive:bool:param recursive: Defines if the search shall be executed recursive :rtype:int:return: The count of removed elements
- find(mask, limit=100, relative_names=False, recursive=False)[source]¶
Finds a list of elements by name :type mask:
str:param mask: The search mask. If it contains a folder the mask is only applied to the nested element :type limit:int:param limit: The maximum count of entries :type relative_names:bool:param relative_names: Defines if the relative names shall be returned :type recursive:bool:param recursive: Defines if the search shall continue recursive :return: A list of elements of all valid elements matching the search mask
- get(name, default=None)[source]¶
Tries to read an element from the database :type name:
str:param name: The element’s name :type default:Union[str,bool,int,float,bytes,dict,list,ndarray,None] :param default: The default return value if the element does not exist :rtype:Union[str,bool,int,float,bytes,dict,list,ndarray,None] :return: The element
- get_ex(name, default=None, version_counter=-1)[source]¶
Tries to read an element from the database. Allows to add a version check so only data will be returned if it changed since the last get_ex. :param name: The element’s name :param default: The default return value if the element does not exist :param version_counter: If set then a value will only be returned if the element’s update counter does not match :return: The element’s version, The element
- static get_server_up_time()[source]¶
Get the server’s working time to compute the deprecation of elements :rtype:
float:return: Time offset since start in seconds
- get_status(advanced=False)[source]¶
Returns the database status :type advanced:
bool:param advanced: Defines if advanced details shall be received as well :return: A dictionary containing the status
- get_sub_folders(name, recursive=True)[source]¶
Returns all sub folders of folder_name :param name: The main folder :param recursive: Defines if the search shall be recursive. :return: The list of all nested folders
- get_values_by_name(mask, limit=100, flat=True)[source]¶
Returns the data of a set of elements by name. :type mask:
str:param mask: The search mask. If it contains a folder the mask is only applied to the nested element :type limit:int:param limit: The maximum count of entries :type flat:bool:param flat: Returns a list of all values received without providing the element names :return: A list containing the data and names of all valid elements
- pop(name, default=None, index=0)[source]¶
Tries to remove an element at the beginning of a list :type name:
str:param name: The name’s list :type default:Union[str,bool,int,float,bytes,dict,list,ndarray,None] :param default: The default return value if the list is empty or does not exist :type index:int:param index: The index from which the element shall be “popped”. By default from the front :rtype:Union[str,bool,int,float,bytes,dict,list,ndarray,None] :return: The element which was removed
- push(name, data, timeout_s=None, index=-1)[source]¶
Appends an element at the end of a list :type name: str :param name: The element’s name :type data: list[StagDataTypes] :param data: The data to be added. See StagDataTypes for supported types :type timeout_s: float | None :param timeout_s: The timeout for automatic deletion in seconds :param index: The index at which the elements shall be inserted. By default at the end. :rtype: int :return: The new length of the list
- set(name, data, timeout_s=None)[source]¶
Stores a named element in the database :type name: str :param name: The element’s name :type data: StagDataTypes :param data: The data to be added. See StagDataTypes for supported types :type timeout_s: float | None :param timeout_s: The timeout for automatic deletion :rtype: bool :return: True on success
- FOLDER_SEPARATOR = '.'¶
The sign which defines in which folder a key is located
- global_dictionary: dict[str, scistag.datastag.data_stag_element.DataStagElement]¶
A dictionary containing all elements