"""Toolbelt settings module. All code related to working with the ~/.autonomic/settings.yml file. This file is useful for storing information for future lookup when dealing with repetitive cooperative tasks. """ from autonomic.config import CONFIG_YAML from autonomic.utils import yaml_dump, yaml_load def add(data): """Add values to the settings file.""" settings = yaml_load(CONFIG_YAML) if settings is None: settings = {} for key in data: settings[key] = data[key] yaml_dump(CONFIG_YAML, settings) def get(key): """Retrieve setting values.""" settings = yaml_load(CONFIG_YAML) try: return settings[key] except Exception: return None