# Path: solvebio/client.py
# def _handle_api_error(response):
# def _handle_request_error(e):
#     def __init__(self, token=None, token_type='Token'):
#     def __call__(self, r):
#     def __repr__(self):
#     def __init__(self, host=None, token=None, token_type='Token',
#                  include_resources=True):
#     def set_host(self, host=None):
#     def set_token(self, token=None, token_type='Token'):
#     def set_user_agent(self, name=None, version=None):
#     def whoami(self):
#     def get(self, url, params, **kwargs):
#     def post(self, url, data, **kwargs):
#     def delete(self, url, data, **kwargs):
#     def request(self, method, url, **kwargs):
#     def _log_raw_request(self, method, url, **kwargs):
#     def __repr__(self):
# class SolveTokenAuth(AuthBase):
# class SolveClient(object):
# 
# Path: solvebio/cli/credentials.py
# def get_credentials():
#     """
#     Returns the user's stored API key if a valid credentials file is found.
#     Raises CredentialsError if no valid credentials file is found.
#     """
# 
#     try:
#         netrc_obj = netrc(netrc.path())
#         if not netrc_obj.hosts:
#             return None
#     except (IOError, TypeError, NetrcParseError) as e:
#         raise CredentialsError(
#             'Could not open credentials file: ' + str(e))
# 
#     host = as_netrc_machine(solvebio.api_host)
#     if host in netrc_obj.hosts:
#         proto = "http://" if "http://" in solvebio.api_host else "https://"
#         return (proto + host,) + netrc_obj.authenticators(host)
# 
#     # If the preferred host is not the global default, don't try
#     # to select any other.
#     if host != 'api.solvebio.com':
#         return None
# 
#     # If there are no stored credentials for the default host,
#     # but there are other stored credentials, use the first
#     # available option that ends with '.api.solvebio.com',
#     # Otherwise use the first available.
#     for h in netrc_obj.hosts:
#         if h.endswith('.api.solvebio.com'):
#             return ('https://' + h,) + netrc_obj.authenticators(h)
# 
#     # Return the first available
#     host = netrc_obj.hosts.keys()[0]
#     return ('https://' + host,) + netrc_obj.authenticators(host)
# 
# Path: solvebio/cli/credentials.py
# def save_credentials(email, token, token_type='Token', api_host=None):
#     api_host = api_host or solvebio.api_host
# 
#     try:
#         netrc_path = netrc.path()
#         rc = netrc(netrc_path)
#     except (IOError, TypeError, NetrcParseError) as e:
#         raise CredentialsError('Could not open netrc file: ' + str(e))
# 
#     # Overwrites any existing credentials
#     rc.hosts[as_netrc_machine(api_host)] = (email, token_type, token)
#     rc.save(netrc_path)
# 
# Path: solvebio/cli/credentials.py
# def delete_credentials():
#     try:
#         netrc_path = netrc.path()
#         rc = netrc(netrc_path)
#     except (IOError, TypeError, NetrcParseError) as e:
#         raise CredentialsError('Could not open netrc file: ' + str(e))
# 
#     try:
#         del rc.hosts[as_netrc_machine(solvebio.api_host)]
#     except KeyError:
#         pass
#     else:
#         rc.save(netrc_path)


import solvebio
from ..client import client
from .credentials import get_credentials
from .credentials import save_credentials
from .credentials import delete_credentials
    if logged_in:
        # Print information about the current user
        user = client.whoami()
        print_user(user)
        save_credentials(
            user['email'].lower(), client._auth.token,
            client._auth.token_type, solvebio.api_host)
        print('Updated local credentials file.')
    else:
        print('You are not logged-in. Visit '
              'https://docs.solvebio.com/#authentication to get started.')


def logout(*args):
    """
    Delete's the user's locally-stored credentials.
    """
    if get_credentials():
        delete_credentials()
        print('You have been logged out.')
    else:
        print('You are not logged-in.')


def whoami(*args, **kwargs):
    """
    Prints information about the current user.
    Assumes the user is already logged-in.
    """
    try:

# Path: solvebio/client.py
# def _handle_api_error(response):
# def _handle_request_error(e):
#     def __init__(self, token=None, token_type='Token'):
#     def __call__(self, r):
#     def __repr__(self):
#     def __init__(self, host=None, token=None, token_type='Token',
#                  include_resources=True):
#     def set_host(self, host=None):
#     def set_token(self, token=None, token_type='Token'):
#     def set_user_agent(self, name=None, version=None):
#     def whoami(self):
#     def get(self, url, params, **kwargs):
#     def post(self, url, data, **kwargs):
#     def delete(self, url, data, **kwargs):
#     def request(self, method, url, **kwargs):
#     def _log_raw_request(self, method, url, **kwargs):
#     def __repr__(self):
# class SolveTokenAuth(AuthBase):
# class SolveClient(object):
# 
# Path: solvebio/cli/credentials.py
# def get_credentials():
#     """
#     Returns the user's stored API key if a valid credentials file is found.
#     Raises CredentialsError if no valid credentials file is found.
#     """
# 
#     try:
#         netrc_obj = netrc(netrc.path())
#         if not netrc_obj.hosts:
#             return None
#     except (IOError, TypeError, NetrcParseError) as e:
#         raise CredentialsError(
#             'Could not open credentials file: ' + str(e))
# 
#     host = as_netrc_machine(solvebio.api_host)
#     if host in netrc_obj.hosts:
#         proto = "http://" if "http://" in solvebio.api_host else "https://"
#         return (proto + host,) + netrc_obj.authenticators(host)
# 
#     # If the preferred host is not the global default, don't try
#     # to select any other.
#     if host != 'api.solvebio.com':
#         return None
# 
#     # If there are no stored credentials for the default host,
#     # but there are other stored credentials, use the first
#     # available option that ends with '.api.solvebio.com',
#     # Otherwise use the first available.
#     for h in netrc_obj.hosts:
#         if h.endswith('.api.solvebio.com'):
#             return ('https://' + h,) + netrc_obj.authenticators(h)
# 
#     # Return the first available
#     host = netrc_obj.hosts.keys()[0]
#     return ('https://' + host,) + netrc_obj.authenticators(host)
# 
# Path: solvebio/cli/credentials.py
# def save_credentials(email, token, token_type='Token', api_host=None):
#     api_host = api_host or solvebio.api_host
# 
#     try:
#         netrc_path = netrc.path()
#         rc = netrc(netrc_path)
#     except (IOError, TypeError, NetrcParseError) as e:
#         raise CredentialsError('Could not open netrc file: ' + str(e))
# 
#     # Overwrites any existing credentials
#     rc.hosts[as_netrc_machine(api_host)] = (email, token_type, token)
#     rc.save(netrc_path)
# 
# Path: solvebio/cli/credentials.py
# def delete_credentials():
#     try:
#         netrc_path = netrc.path()
#         rc = netrc(netrc_path)
#     except (IOError, TypeError, NetrcParseError) as e:
#         raise CredentialsError('Could not open netrc file: ' + str(e))
# 
#     try:
#         del rc.hosts[as_netrc_machine(solvebio.api_host)]
#     except KeyError:
#         pass
#     else:
#         rc.save(netrc_path)


# Path: solvebio/cli/auth.py
import solvebio
from ..client import client
from .credentials import get_credentials
from .credentials import save_credentials
from .credentials import delete_credentials

    if logged_in:
        # Print information about the current user
        user = client.whoami()
        print_user(user)
        save_credentials(
            user['email'].lower(), client._auth.token,
            client._auth.token_type, solvebio.api_host)
        print('Updated local credentials file.')
    else:
        print('You are not logged-in. Visit '
              'https://docs.solvebio.com/#authentication to get started.')


def logout(*args):
    """
    Delete's the user's locally-stored credentials.
    """
    if get_credentials():
        delete_credentials()
        print('You have been logged out.')
    else:
        print('You are not logged-in.')


def whoami(*args, **kwargs):
    """
    Prints information about the current user.
    Assumes the user is already logged-in.
    """
    try:

        user = client.whoami()