Exemplo n.º 1
0
def load_config(path: str, defaults: dict) -> DictObj:
    """Loads the configuration file and any project files loaded in projects_folder if defined

    Args:
        path: full path to config file
        defaults: dictionary filled with default settings

    Returns:
        DictObj filled with settings from config files
    """
    try:
        settings = Settings(defaults, path, '').get_all()
    except FileNotFoundError as exception_object:
        raise FileNotFoundError(
            "{0!s}: not found".format(path)) from exception_object
    except IOError as exception_object:
        raise IOError("{0!s}: not a file".format(path)) from exception_object

    return DictObj(
        merge_dictionaries(
            settings,
            load_projects_folder(
                path,
                settings.get('backup', dict()).get('projects_folder'))))
Exemplo n.º 2
0
 def test_get(self):
     t = Settings({'test': 'test'}, '', '')
     got = t.get('test')
     self.assertEqual('test', got)