hpcflow.sdk.core.object_list.ObjectList#
- class hpcflow.sdk.core.object_list.ObjectList(objects, descriptor=None)#
-
A list-like class that provides item access via a get method according to attributes or dict-keys.
- Parameters:
objects (sequence) – List of values of some type.
descriptor (str) – Descriptive name for objects in the list.
Methods
Add an object to this object list.
Make an instance of this class from JSON (or YAML) data.
Get a single object from the object list, by specifying the value of the access attribute, and optionally additional keyword-argument attribute values.
Get one or more objects from the object list, by specifying the value of the access attribute, and optionally additional keyword-argument attribute values.
Serialize this object as a dictionary.
Serialize this object as an object structure that can be trivially converted to JSON.
- add_object(obj: T, index: int = -1, *, skip_duplicates: Literal[False] = False) int #
- add_object(obj: T, index: int = -1, *, skip_duplicates: Literal[True]) int | None
Add an object to this object list.
- Parameters:
obj – The object to add.
index – Where to add it. Omit to append.
skip_duplicates – If true, don’t add the object if it is already in the list.
- Return type:
The index of the added object, or
None
if the object was not added.
- classmethod from_json_like(json_like, shared_data=None)#
Make an instance of this class from JSON (or YAML) data.
- Parameters:
json_like (str | Mapping[str, JSONed] | Sequence[Mapping[str, JSONed]] | None) – The data to deserialise.
shared_data (Mapping[str, ObjectList[JSONable]] | None) – Shared context data.
- Return type:
The deserialised object.
- get(**kwargs)#
Get a single object from the object list, by specifying the value of the access attribute, and optionally additional keyword-argument attribute values.
- get_all(**kwargs)#
Get one or more objects from the object list, by specifying the value of the access attribute, and optionally additional keyword-argument attribute values.
- to_json_like(dct=None, shared_data=None, exclude=(), path=None)#
Serialize this object as an object structure that can be trivially converted to JSON. Note that YAML can also be produced from the result of this method; it just requires a different final serialization step.