aiida_vasp.utils.extended_dicts#

Extensions of dictionaries.

Module Contents#

Classes#

DictWithAttributes

Extension of the AttributeDict from Aiida.common.

Functions#

delete_keys_from_dict

Delete a key from a nested dictionary.

delete_nested_key

Delete the dictionary entry corresponding to a nested hierarchy of keys.

update_nested_dict

Updated a nested dictionary, where dict1 is updated with values in dict2.

find_key_in_dicts

Find a key in a nested dictionary.

update_nested_dict_node

Utility to update a Dict node in a nested way

API#

class aiida_vasp.utils.extended_dicts.DictWithAttributes(dictionary=None)[source]#

Bases: aiida.common.extendeddicts.AttributeDict

Extension of the AttributeDict from Aiida.common.

This class internally stores values in a dictionary, but exposes the keys also as attributes, i.e. asking for attrdict.key will return the value of attrdict[‘key’] and so on.

If the key is not in the dict a default value will be returned.

Initialization

Recursively turn the dict and all its nested dictionaries into AttributeDict instance.

__getattr__(attr)[source]#

Read a key as an attribute. Return a Default value on missing key.

__setattr__(attr, value)[source]#

Set a key as an attribute.

aiida_vasp.utils.extended_dicts.delete_keys_from_dict(dictionary, keys)[source]#

Delete a key from a nested dictionary.

Extended to support somekey.someotherkey in case we need some restrictions on the nesting.

aiida_vasp.utils.extended_dicts.delete_nested_key(dictionary, keys)[source]#

Delete the dictionary entry corresponding to a nested hierarchy of keys.

aiida_vasp.utils.extended_dicts.update_nested_dict(dict1: dict, dict2: dict, extend_list: bool = False)[source]#

Updated a nested dictionary, where dict1 is updated with values in dict2.

aiida_vasp.utils.extended_dicts.find_key_in_dicts(dictionary: dict, supplied_key: str)[source]#

Find a key in a nested dictionary.

aiida_vasp.utils.extended_dicts.update_nested_dict_node(dict_node: aiida.orm.Dict, update_dict: dict, extend_list: bool = False)[source]#

Utility to update a Dict node in a nested way