IDS peak ICV v1.1.0
Loading...
Searching...
No Matches
Archive Class Reference
Inheritance diagram for Archive:

Public Member Functions

None __init__ (self, Dict[str, Archive.AllowedValue]|None data=None)
 
None set (self, str key, AllowedValue value)
 Stores a value under the given key.
 
T get (self, str key, Type[T]|None datatype)
 Retrieves the value stored under the given key.
 
IArchive get_archive (self, str key)
 Retrieves the archive stored under the given key.
 
bool has (self, str key)
 Checks whether a given key exists in the archive.
 
List[str] keys (self)
 Returns all keys currently stored in the archive.
 
IArchive create_archive (self)
 Creates a new, empty archive instance.
 
str __str__ (self)
 Human-readable string representation of the archive.
 
str __repr__ (self)
 
bool __eq__ (self, Any other)
 

Static Public Attributes

 AllowedValue = IArchive.AllowedValue | IArchive
 

Protected Member Functions

bool _compare_values (self, Any lhs, Any rhs)
 
None _validate_value (self, str key, Any value)
 Ensures the provided value matches the allowed types.
 

Protected Attributes

Dict _storage = data
 

Static Protected Attributes

tuple _ALLOWED_SCALARS = (bool, int, float, str, IArchive)
 

Detailed Description

A simple key-value store with type checking, similar to a dict.

Supports only:

  • bool, int, float, str
  • IArchive
  • Lists of the above
Since
ids_peak_icv 1.0

Definition at line 11 of file archive.py.

Constructor & Destructor Documentation

◆ __init__()

None __init__ ( self,
Dict[str, Archive.AllowedValue] | None data = None )

Definition at line 26 of file archive.py.

Member Function Documentation

◆ __eq__()

bool __eq__ ( self,
Any other )

Definition at line 137 of file archive.py.

◆ __repr__()

str __repr__ ( self)

Definition at line 134 of file archive.py.

◆ __str__()

str __str__ ( self)

Human-readable string representation of the archive.

Since
ids_peak_icv 1.0

Definition at line 125 of file archive.py.

◆ _compare_values()

bool _compare_values ( self,
Any lhs,
Any rhs )
protected

Definition at line 150 of file archive.py.

◆ _validate_value()

None _validate_value ( self,
str key,
Any value )
protected

Ensures the provided value matches the allowed types.

Parameters
keyThe key for which the value is being validated.
valueThe value to check.
Exceptions
NotSupportedExceptionIf the type is not supported.

Definition at line 163 of file archive.py.

◆ create_archive()

IArchive create_archive ( self)

Creates a new, empty archive instance.

Since
ids_peak_icv 1.0

Reimplemented from IArchive.

Definition at line 117 of file archive.py.

◆ get()

T get ( self,
str key,
Type[T] | None datatype )

Retrieves the value stored under the given key.

Parameters
keyKey of the value to retrieve.
datatypeThe expected datatype of the value. If None is given, the type check is not executed.
Exceptions
CorruptedExceptionIf the key is not found or the specified datatype is not the type of the stored value.
Returns
The stored value.
Since
ids_peak_icv 1.0

Reimplemented from IArchive.

Definition at line 47 of file archive.py.

◆ get_archive()

IArchive get_archive ( self,
str key )

Retrieves the archive stored under the given key.

Parameters
keyKey of the archive to retrieve.
Exceptions
CorruptedExceptionIf the key is not found or the specified datatype is not of type archive.
Returns
The stored archive.
Since
ids_peak_icv 1.0

Reimplemented from IArchive.

Definition at line 72 of file archive.py.

◆ has()

bool has ( self,
str key )

Checks whether a given key exists in the archive.

Parameters
keyThe key to check.
Returns
True if the key exists, False otherwise.
Since
ids_peak_icv 1.0

Reimplemented from IArchive.

Definition at line 94 of file archive.py.

◆ keys()

List[str] keys ( self)

Returns all keys currently stored in the archive.

Returns
List of keys.
Since
ids_peak_icv 1.0

Reimplemented from IArchive.

Definition at line 106 of file archive.py.

◆ set()

None set ( self,
str key,
AllowedValue value )

Stores a value under the given key.

Parameters
keyKey to store the value under.
valueThe value to store (restricted types only).
Since
ids_peak_icv 1.0

Reimplemented from IArchive.

Definition at line 34 of file archive.py.

Field Documentation

◆ _ALLOWED_SCALARS

_ALLOWED_SCALARS = (bool, int, float, str, IArchive)
staticprotected

Definition at line 161 of file archive.py.

◆ _storage

Dict _storage = data
protected

Definition at line 32 of file archive.py.

◆ AllowedValue

AllowedValue = IArchive.AllowedValue | IArchive
static

Definition at line 24 of file archive.py.