Skip to content

Commit

Permalink
List/Dict: Add value property
Browse files Browse the repository at this point in the history
Add the `value` property to the `List` and `Dict` classes, to make them
more consistent with other base type classes.
  • Loading branch information
mbercx committed Jan 11, 2022
1 parent c743a33 commit 318c627
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions aiida/orm/nodes/data/dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ def __eq__(self, other):
return self.get_dict() == other.get_dict()
return self.get_dict() == other

@property
def value(self):
return self.attributes

@value.setter
def value(self, value):
self.set_dict(value)

def set_dict(self, dictionary):
""" Replace the current dictionary with another one.
Expand Down
8 changes: 8 additions & 0 deletions aiida/orm/nodes/data/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ def __eq__(self, other):
return self.get_list() == other.get_list()
return self.get_list() == other

@property
def value(self):
return self.get_list()

@value.setter
def value(self, value):
self.set_list(value) # pylint: disable=no-member

def append(self, value):
data = self.get_list()
data.append(value)
Expand Down

0 comments on commit 318c627

Please sign in to comment.