![]() |
IDS peak ICV v1.2.0
|

Public Member Functions | |
| None | __init__ (self, Dict[str, Archive.AllowedValue]|None data=None) |
| Initializes the archive with optional initial data. | |
| None | set (self, str key, AllowedValue value) |
| Stores a value under the specified key. | |
| T | get (self, str key, Type[T]|None datatype) |
| Returns the value stored under the specified key. | |
| IArchive | get_archive (self, str key) |
| Returns 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) |
| A 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) |
| bool | _is_supported_type (self, Any value) |
| Returns whether the value’s type is supported. | |
Protected Attributes | |
| Dict | _storage = data |
Static Protected Attributes | |
| tuple | _ALLOWED_SCALARS = (bool, int, float, str, IArchive) |
A key-value store with type checking, based on a dict.
Supports only:
Example
from ids_peak_icv.serialization import Archive
archive = Archive()
archive.set("A", 1)
archive.set("B", "Text")
archive.set("C", [1, 2, 3])
sub_archive = Archive()
sub_archive.set("a", 1.2)
sub_archive.set("b", True)
archive.set("D", sub_archive)
Definition at line 11 of file archive.py.
| None __init__ | ( | self, | |
| Dict[str, Archive.AllowedValue] | None | data = None ) |
Initializes the archive with optional initial data.
If data is provided, all entries are validated for supported types before the dict is stored by reference. If data is None, the archive is initially empty.
| data | Optional dictionary of initial key-value pairs. |
| NotSupportedException | An entry in data has an unsupported type. |
Definition at line 42 of file archive.py.
| bool __eq__ | ( | self, | |
| Any | other ) |
Definition at line 187 of file archive.py.
| str __repr__ | ( | self | ) |
Definition at line 180 of file archive.py.
| str __str__ | ( | self | ) |
A string representation of the archive.
Definition at line 171 of file archive.py.
|
protected |
Definition at line 204 of file archive.py.
|
protected |
Returns whether the value’s type is supported.
| value | A value or a list whose type is validated. |
True if the type supported, False otherwise.Definition at line 221 of file archive.py.
| IArchive create_archive | ( | self | ) |
Creates a new, empty archive instance.
Reimplemented from IArchive.
Definition at line 162 of file archive.py.
Returns the value stored under the specified key.
| key | Key of the value to retrieve. |
| datatype | The expected datatype of the value. If None is given, the type check is not executed. |
| CorruptedException | If the key is not found or the specified datatype is not the type of the stored value. |
Reimplemented from IArchive.
Definition at line 89 of file archive.py.
| IArchive get_archive | ( | self, | |
| str | key ) |
Returns the archive stored under the given key.
| key | Key of the archive to retrieve. |
| CorruptedException | The key is not found or the specified datatype is not of type IArchive. |
Reimplemented from IArchive.
Definition at line 115 of file archive.py.
| bool has | ( | self, | |
| str | key ) |
Checks whether a given key exists in the archive.
| key | The key to check. |
Reimplemented from IArchive.
Definition at line 138 of file archive.py.
| List[str] keys | ( | self | ) |
Returns all keys currently stored in the archive.
Reimplemented from IArchive.
Definition at line 151 of file archive.py.
| None set | ( | self, | |
| str | key, | ||
| AllowedValue | value ) |
Stores a value under the specified key.
| key | The key under which to store the value. |
| value | The value to store (restricted types only). |
| NotSupportedException | The value has an unsupported type. |
Reimplemented from IArchive.
Definition at line 70 of file archive.py.
|
staticprotected |
Definition at line 219 of file archive.py.
|
protected |
Definition at line 68 of file archive.py.
|
static |
Definition at line 40 of file archive.py.