# 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 load_token(url):
    for token_dir in TOKEN_DIRS:
        tokenfile = join(token_dir, '%s.token' % quote_plus(url))

        if isfile(tokenfile):
            logger.debug("Found login token: {}".format(tokenfile))
            with open(tokenfile) as fd:
                token = fd.read().strip()

            if token:
                return token
            else:
                logger.debug("Token file is empty: {}".format(tokenfile))
                logger.debug("Removing file: {}".format(tokenfile))
                os.unlink(tokenfile)


def remove_token(args):
    config = get_config(site=args and args.site)
    url = config.get('url', DEFAULT_URL)

    for token_dir in TOKEN_DIRS:
        tokenfile = join(token_dir, '%s.token' % quote_plus(url))
        if isfile(tokenfile):
            os.unlink(tokenfile)


def load_config(config_file):
    if exists(config_file):
        with open(config_file) 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 load_token(url):
    for token_dir in TOKEN_DIRS:
        tokenfile = join(token_dir, '%s.token' % quote_plus(url))

        if isfile(tokenfile):
            logger.debug("Found login token: {}".format(tokenfile))
            with open(tokenfile) as fd:
                token = fd.read().strip()

            if token:
                return token
            else:
                logger.debug("Token file is empty: {}".format(tokenfile))
                logger.debug("Removing file: {}".format(tokenfile))
                os.unlink(tokenfile)


def remove_token(args):
    config = get_config(site=args and args.site)
    url = config.get('url', DEFAULT_URL)

    for token_dir in TOKEN_DIRS:
        tokenfile = join(token_dir, '%s.token' % quote_plus(url))
        if isfile(tokenfile):
            os.unlink(tokenfile)


def load_config(config_file):
    if exists(config_file):
        with open(config_file) as fd:

            data = yaml_load(fd)