Beispiel #1
0
def load_remotes(extra_path=None, load_user=True):
    """Load the YAML remotes file, which sort of combines the Accounts file with part of the
    remotes sections from the main config

    :return: An `AttrDict`
    """

    from os.path import getmtime

    try:
        remotes_file = find_config_file(REMOTES_FILE,
                                        extra_path=extra_path,
                                        load_user=load_user)
    except ConfigurationError:
        remotes_file = None

    if remotes_file is not None and os.path.exists(remotes_file):
        config = AttrDict()
        config.update_yaml(remotes_file)

        if not 'remotes' in config:
            config.remotes = AttrDict()

        config.remotes.loaded = [remotes_file, getmtime(remotes_file)]

        return config
    else:
        return None
Beispiel #2
0
def load_accounts(extra_path=None, load_user=True):
    """Load the yaml account files

    :param load_user:
    :return: An `AttrDict`
    """

    from os.path import getmtime

    try:
        accts_file = find_config_file(ACCOUNTS_FILE,
                                      extra_path=extra_path,
                                      load_user=load_user)
    except ConfigurationError:
        accts_file = None

    if accts_file is not None and os.path.exists(accts_file):
        config = AttrDict()
        config.update_yaml(accts_file)

        if not 'accounts' in config:
            config.remotes = AttrDict()

        config.accounts.loaded = [accts_file, getmtime(accts_file)]
        return config
    else:
        return None