From 1aadd0b6f4ae8c5a36d90f6c38a057a41b4bbd34 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh <bryan.tongminh@gmail.com> Date: Mon, 12 May 2008 12:23:37 +0000 Subject: [PATCH] Add ext config variable --- mwclient/client.py | 5 +++-- mwclient/ex.py | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/mwclient/client.py b/mwclient/client.py index 791783b..e6d052c 100644 --- a/mwclient/client.py +++ b/mwclient/client.py @@ -34,11 +34,12 @@ class WaitToken(object): class Site(object): api_limit = 500 - def __init__(self, host, path = '/w/', pool = None, retry_timeout = 30, + def __init__(self, host, path = '/w/', ext = '.php', pool = None, retry_timeout = 30, max_retries = 25, wait_callback = lambda *x: None, max_lag = 3, compress = True, force_login = True, do_init = True): self.host = host self.path = path + self.ext = ext self.credentials = None self.compress = compress @@ -163,7 +164,7 @@ class Site(object): return qs def raw_call(self, script, data): - url = self.path + script + '.php' + url = self.path + script + self.ext headers = {'Content-Type': 'application/x-www-form-urlencoded'} if self.compress and gzip: headers['Accept-Encoding'] = 'gzip' diff --git a/mwclient/ex.py b/mwclient/ex.py index 85cadbb..afb77d9 100644 --- a/mwclient/ex.py +++ b/mwclient/ex.py @@ -38,8 +38,9 @@ class ConfiguredSite(client.Site): do_login = 'username' in self.config and 'password' in self.config - client.Site.__init__(self, self.config['host'], - self.config['path'], do_init = not do_login, + client.Site.__init__(self, host = self.config['host'], + path = self.config['path'], ext = self.config.get('ext', '.php'), + do_init = not do_login, retry_timeout = self.config.get('retry_timeout', 30), max_retries = self.config.get('max_retries', -1)) @@ -63,8 +64,9 @@ class ConfiguredPool(list): do_login = 'username' in site and 'password' in site - self.append(client.Site(site['host'], - site['path'], self.pool, do_init = not do_login, + self.append(client.Site(host = site['host'], + path = site['path'], ext = site.get('ext', '.php'), + pool = self.pool, do_init = not do_login, retry_timeout = site.get('retry_timeout', 30), max_retries = site.get('max_retries', -1))) if do_login: -- GitLab