Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make default api_url language specific #26

Merged
merged 2 commits into from Mar 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions mediawiki/mediawiki.py
Expand Up @@ -35,13 +35,13 @@ class MediaWiki(object):
:type rate_limit_wait: timedelta
'''

def __init__(self, url='http://en.wikipedia.org/w/api.php', lang='en',
def __init__(self, url='http://{lang}.wikipedia.org/w/api.php', lang='en',
timeout=None, rate_limit=False,
rate_limit_wait=timedelta(milliseconds=50)):
''' Init Function '''
self._version = VERSION
self._api_url = url
self._lang = lang # should this call self.language = lang?
self._api_url = url.format(lang=lang)
self._lang = lang
self._timeout = timeout
self._user_agent = ('python-mediawiki/VERSION-{0}'
'/({1})/BOT').format(VERSION, URL)
Expand Down Expand Up @@ -217,7 +217,7 @@ def memoized(self):
return self._cache

# non-properties
def set_api_url(self, api_url='http://en.wikipedia.org/w/api.php',
def set_api_url(self, api_url='http://{lang}.wikipedia.org/w/api.php',
lang='en'):
''' Set the API URL and language

Expand All @@ -231,7 +231,7 @@ def set_api_url(self, api_url='http://en.wikipedia.org/w/api.php',
'''
old_api_url = self._api_url
old_lang = self._lang
self._api_url = api_url
self._api_url = api_url.format(lang=lang)
self._lang = lang
try:
self._get_site_info()
Expand Down