/usr/share/parley/plugins/mwclient/ex.py is in parley-data 4:15.12.3-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | import client, http
def read_config(config_files, **predata):
cfg = {}
for config_file in config_files:
cfg.update(_read_config_file(
config_file, predata))
return cfg
def _read_config_file(_config_file, predata):
_file = open(_config_file)
exec _file in globals(), predata
_file.close()
for _k, _v in predata.iteritems():
if not _k.startswith('_'):
yield _k, _v
for _k, _v in locals().iteritems():
if not _k.startswith('_'):
yield _k, _v
class SiteList(object):
def __init__(self):
self.sites = {}
def __getitem__(self, key):
if key not in self.sites:
self.sites[key] = {}
return self.sites[key]
def __iter__(self):
return self.sites.itervalues()
class ConfiguredSite(client.Site):
def __init__(self, *config_files, **kwargs):
self.config = read_config(config_files, sites = SiteList())
if 'name' in kwargs:
self.config.update(self.config['sites'][kwargs['name']])
do_login = 'username' in self.config and 'password' in self.config
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))
if do_login:
self.login(self.config['username'],
self.config['password'])
class ConfiguredPool(list):
def __init__(self, *config_files):
self.config = read_config(config_files, sites = SiteList())
self.pool = http.HTTPPool()
config = dict([(k, v) for k, v in self.config.iteritems()
if k != 'sites'])
for site in self.config['sites']:
cfg = config.copy()
cfg.update(site)
site.update(cfg)
do_login = 'username' in site and 'password' in site
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:
self[-1].login(site['username'], site['password'])
self[-1].config = site
|