"""Module providing base property functions."""
MAX_TAGS = 5 # Maximum number of tags.
[docs]
class Properties:
"""A class for storing and retrieving properties."""
def __init__(self):
self.properties = {}
[docs]
def get_properties(self):
"""Method to retrieve the properties.
Returns:
:obj:`dict`: The dictionary of current properties.
"""
return self.properties
[docs]
def update_properties(self, properties):
"""Method to update the properties.
Args:
``properties`` (:obj:`dict`): A dictionary of properties.
New properties are added. Old properties are updated. The
keys for the dictionary entries are `name` and up to five
optional tags labeled `tag1`, `tag2`, ..., `tag5`.
Returns:
On successful return, the properties have been updated.
"""
for prop in properties:
if isinstance(prop, tuple):
assert len(prop) <= MAX_TAGS + 1
self.properties = {**self.properties, **properties}