ZFS Automatic Snapshot Daemon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
648 B

from typing import Any, Mapping, MutableMapping
_config: MutableMapping[str, Any] = {}
def change(new):
_config.clear()
_config.update(new)
4 years ago
def get(*keys: str, default: Any = None, cursor: Mapping = None):
''' Get configuration value. If multple keys are specified, traverse the
configuration to retrieve the value. If no value was found, return
None. '''
4 years ago
if not cursor:
cursor = _config
4 years ago
first = keys[0]
rest = keys[1:]
4 years ago
value = cursor.get(first)
return (get(rest, default=default, cursor=value)
if value is not None and rest else value)
4 years ago
def reference():
return _config