# Path: brede/config.py
# CONFIG_FILENAMES = [
#     'brede.cfg',
#     '~/etc/brede.cfg',
#     '~/brede.cfg']
# DEFAULTS = """
# [requests]
# user_agent = brede
# 
# [data]
# data_dir = ~/brede_data
# """


import json
import requests
import yaml
from itertools import islice
from brede.config import config
    from docopt import docopt
                                       text))


class Watson(object):
    """Interface to IBM Watson.

    The use of this class requires credentials to an IBM Watson instance.

    User, password and API URL are read from the brede.config if it is not
    specified.

    Example
    -------
    >>> try:
    ...     api = Watson()
    ... except WatsonMissingConfig:
    ...     # Watson not available, so we don't test for queries.
    ...     print(True)
    ... else:
    ...     answer = api.ask('Who was called John?')
    ...     'question' in answer
    True

    """

    def __init__(self, user=None, password=None, url=None):
        """Setup credentials for an IBM Watson instance."""
        if user is None and password is None and url is None:
            self.check_config()
        self.user = user or config.get('watson', 'user')

# Path: brede/config.py
# CONFIG_FILENAMES = [
#     'brede.cfg',
#     '~/etc/brede.cfg',
#     '~/brede.cfg']
# DEFAULTS = """
# [requests]
# user_agent = brede
# 
# [data]
# data_dir = ~/brede_data
# """


# Path: brede/api/watson.py
import json
import requests
import yaml
from itertools import islice
from brede.config import config
    from docopt import docopt

                                       text))


class Watson(object):
    """Interface to IBM Watson.

    The use of this class requires credentials to an IBM Watson instance.

    User, password and API URL are read from the brede.config if it is not
    specified.

    Example
    -------
    >>> try:
    ...     api = Watson()
    ... except WatsonMissingConfig:
    ...     # Watson not available, so we don't test for queries.
    ...     print(True)
    ... else:
    ...     answer = api.ask('Who was called John?')
    ...     'question' in answer
    True

    """

    def __init__(self, user=None, password=None, url=None):
        """Setup credentials for an IBM Watson instance."""
        if user is None and password is None and url is None:
            self.check_config()
        self.user = user or config.get('watson', 'user')

        self.password = password or config.get('watson', 'password')