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


import sys
import requests
from brede.config import config
    from docopt import docopt
URL_BASE_WIKIPEDIA = "https://en.wikipedia.org/w/"


class WikiError(Exception):
    """Exception for misspecified wiki."""

    pass


class Wiki(object):
    """Represents an interface to a MediaWiki instance."""

    def __init__(self, wiki=None, url=None):
        """Setup URL etc. to MediaWiki API."""
        if wiki is None and url is None:
            self.wiki = 'Brede'
            self.url_base = URL_BASE_BREDE
        elif url is None:
            if wiki.lower() == 'brede':
                self.wiki = 'Brede'
                self.url_base = URL_BASE_BREDE
            elif wiki.lower() == 'wikipedia':
                self.wiki = 'Wikipedia'
                self.url_base = URL_BASE_WIKIPEDIA
            else:
                raise WikiError(("Wrong 'wiki' specified. ",
                                 "should be 'brede' or 'wikipedia'"))
        else:
            self.url = url


# 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/data/mediawiki.py
import sys
import requests
from brede.config import config
    from docopt import docopt

URL_BASE_WIKIPEDIA = "https://en.wikipedia.org/w/"


class WikiError(Exception):
    """Exception for misspecified wiki."""

    pass


class Wiki(object):
    """Represents an interface to a MediaWiki instance."""

    def __init__(self, wiki=None, url=None):
        """Setup URL etc. to MediaWiki API."""
        if wiki is None and url is None:
            self.wiki = 'Brede'
            self.url_base = URL_BASE_BREDE
        elif url is None:
            if wiki.lower() == 'brede':
                self.wiki = 'Brede'
                self.url_base = URL_BASE_BREDE
            elif wiki.lower() == 'wikipedia':
                self.wiki = 'Wikipedia'
                self.url_base = URL_BASE_WIKIPEDIA
            else:
                raise WikiError(("Wrong 'wiki' specified. ",
                                 "should be 'brede' or 'wikipedia'"))
        else:
            self.url = url


        self.user_agent = config.get('requests', 'user_agent')