[util/store] add docstrings
This commit is contained in:
parent
5da0819610
commit
d2f796baa9
1 changed files with 16 additions and 2 deletions
|
@ -14,14 +14,28 @@ class Store(object):
|
|||
self._data = {}
|
||||
|
||||
def set(self, key, value):
|
||||
"""Set 'key' to 'value', overwriting 'key' if it exists already"""
|
||||
"""Sets key to value, overwriting any existing data for that key
|
||||
|
||||
:param key: the name of the parameter to set
|
||||
:param value: the value to be set
|
||||
"""
|
||||
self._data[key] = {"value": value, "used": False}
|
||||
|
||||
def unused_keys(self):
|
||||
"""Returns a list of unused keys
|
||||
|
||||
:return: a list of keys that are set, but never used
|
||||
:rtype: list of strings
|
||||
"""
|
||||
return [key for key, value in self._data.items() if value["used"] == False]
|
||||
|
||||
def get(self, key, default=None):
|
||||
"""Return the current value of 'key', or 'default' if 'key' is not set"""
|
||||
"""Returns the current value for the specified key, or a default value,
|
||||
if the key is not set
|
||||
|
||||
:param key: the name of the parameter to retrieve
|
||||
:param default: the default value to return, defaults to None
|
||||
"""
|
||||
if key in self._data:
|
||||
self._data[key]["used"] = True
|
||||
return self._data.get(key, {"value": default})["value"]
|
||||
|
|
Loading…
Reference in a new issue