# Path: binstar_client/utils/conda.py
# CONDA_PREFIX = sys.prefix
# 
# CONDA_ROOT = get_conda_root()
# 
# Path: binstar_client/utils/yaml.py
# def yaml_load(stream):
#     """Loads a dictionary from a stream"""
#     return safe_load(stream)
# 
# def yaml_dump(data, stream=None):
#     """Dumps an object to a YAML string"""
#     return safe_dump(data, stream=stream, default_flow_style=False)


from os.path import exists, join, dirname, isfile, isdir, abspath, expanduser
from string import Template
    from urllib import quote_plus
    from urllib.parse import quote_plus
from binstar_client.utils.conda import CONDA_PREFIX, CONDA_ROOT
from binstar_client.utils.appdirs import AppDirs, EnvAppDirs
from binstar_client.errors import BinstarError
from .yaml import yaml_load, yaml_dump
        from binstar_client import Binstar
import collections
import logging
import os
import stat
import warnings
import itertools
def get_config(site=None):
    config = DEFAULT_CONFIG.copy()

    file_configs = load_file_configs(SEARCH_PATH)
    for fn in file_configs:
        recursive_update(config, file_configs[fn])

    site = site or config.get('default_site')
    sites = config.get('sites', {})

    if site:
        site = str(site)

        if site not in sites:
            logger.warning('Site alias "%s" does not exist in the config file', site)
        else:
            # This takes whatever keys are set for the site into the top level of the config dict
            recursive_update(config, sites.get(site, {}))

    return config


def save_config(data, config_file):
    data_dir = dirname(config_file)

    try:
        if not exists(data_dir):
            os.makedirs(data_dir)

        with open(config_file, 'w') as fd:

# Path: binstar_client/utils/conda.py
# CONDA_PREFIX = sys.prefix
# 
# CONDA_ROOT = get_conda_root()
# 
# Path: binstar_client/utils/yaml.py
# def yaml_load(stream):
#     """Loads a dictionary from a stream"""
#     return safe_load(stream)
# 
# def yaml_dump(data, stream=None):
#     """Dumps an object to a YAML string"""
#     return safe_dump(data, stream=stream, default_flow_style=False)


# Path: binstar_client/utils/config.py
from os.path import exists, join, dirname, isfile, isdir, abspath, expanduser
from string import Template
    from urllib import quote_plus
    from urllib.parse import quote_plus
from binstar_client.utils.conda import CONDA_PREFIX, CONDA_ROOT
from binstar_client.utils.appdirs import AppDirs, EnvAppDirs
from binstar_client.errors import BinstarError
from .yaml import yaml_load, yaml_dump
        from binstar_client import Binstar
import collections
import logging
import os
import stat
import warnings
import itertools

def get_config(site=None):
    config = DEFAULT_CONFIG.copy()

    file_configs = load_file_configs(SEARCH_PATH)
    for fn in file_configs:
        recursive_update(config, file_configs[fn])

    site = site or config.get('default_site')
    sites = config.get('sites', {})

    if site:
        site = str(site)

        if site not in sites:
            logger.warning('Site alias "%s" does not exist in the config file', site)
        else:
            # This takes whatever keys are set for the site into the top level of the config dict
            recursive_update(config, sites.get(site, {}))

    return config


def save_config(data, config_file):
    data_dir = dirname(config_file)

    try:
        if not exists(data_dir):
            os.makedirs(data_dir)

        with open(config_file, 'w') as fd:

            yaml_dump(data, stream=fd)