aiida_vasp.workchains.v2.common.dictwrap#

Wrapper class to simply updating an Node when configuring inputs of a calculation.

This module is currently not used in the code, but kept here for future reference. It is not clear such wrapper for Dict would truly benefit the usability of the code.

Module Contents#

Classes#

DictWrapper

Wrapper class for a dict

API#

class aiida_vasp.workchains.v2.common.dictwrap.DictWrapper(node, namespace=None, port=None)[source]#

Bases: collections.UserDict

Wrapper class for a dict

Wraps around an Dict node, saved or not, to allow python dict-like in place modifications.

Initialization

Wrapper around a Dict node. Optionally also include a namespace and a port that the underlying Node should be assigned to. The wrapped Dict node is never update in practice and only used as an initial reference data. If there is no change, the same Dict node will be passed as it is under the node property.

Parameters:
  • node – The node to be wrapped.

  • namespace – The namespace that the node should be assigned to.

  • port – The port under the namespace.

A new node is created whenever necessary.

__getattr__(name: str) Any[source]#
property is_updated#
property node#

Returns a node object that represents the stored data.

This can be a stored node (if no update) or an unstore node

__setitem__(key, value)[source]#

Set the value of a key

_ensure_unstored()[source]#

Ensure that self._unstored_node is indeed unstored If it is not the case - we move it to self._stored_node an create a new unstored node.

__delitem__(key) None[source]#

Delete an item

Delete from both the python dictionary and the underlying node

validate()[source]#

Validate the consistency between the node and the python dictionary

classmethod serializer(data, port=None)[source]#

The serializer function can be used for ProcessSpec.input.

Returns a Dict node for the given data.