diff --git a/mwclient/client.py b/mwclient/client.py index 2b58ccafff5900b583c31f09efd89603c7205aca..ce61821a6b204604bd7f504fcde3c0cb090a07b8 100644 --- a/mwclient/client.py +++ b/mwclient/client.py @@ -696,6 +696,25 @@ class Site(object): toponly='1' if toponly else None)) return listing.List(self, 'recentchanges', 'rc', limit=limit, **kwargs) + def revisions(self, revids, prop = 'ids|timestamp|flags|comment|user', + expandtemplates=False, diffto='prev'): + self.require(1, 12) # version? + if expandtemplates: expandtemplates = '1' + # http://en.wikipedia.org/w/api.php?rvexpandtemplates=False&format=json&list=&rvprop=ids|timestamp|flags|comment|user&rvdiffto=prev&revids=396240352|392544274|396332337&meta=userinfo&action=query&prop=revisions&uiprop=blockinfo|hasmsg + revids_s = '|'.join(map(str,revids)) + kwargs = {'prop':'revisions','rvexpandtemplates':expandtemplates,'format':'json','rvprop':prop, + 'rvdiffto':diffto, 'revids':revids_s} + if (diffto is None) or (diffto == ''): + del kwargs['rvdiffto'] + if (expandtemplates is None) or (expandtemplates == '') or (expandtemplates == 0): + del kwargs['rvexpandtemplates'] + res = self.api('query', **kwargs) + + if res.has_key('query'): + return res['query'] + else: + return None + def search(self, search, namespace='0', what='title', redirects=False, limit=None): kwargs = dict(listing.List.generate_kwargs('sr', search=search, namespace=namespace, what=what)) diff --git a/mwclient/page.py b/mwclient/page.py index a4f2f665056ca140eb3378e13a48332db5fa360a..23c60ca8e749f977645a725e54af268f45b4bad0 100644 --- a/mwclient/page.py +++ b/mwclient/page.py @@ -332,9 +332,9 @@ class Page(object): def revisions(self, startid=None, endid=None, start=None, end=None, dir='older', user=None, excludeuser=None, limit=50, - prop='ids|timestamp|flags|comment|user', expandtemplates=False, section=None): + prop='ids|timestamp|flags|comment|user', expandtemplates=False, section=None, diffto = None): kwargs = dict(listing.List.generate_kwargs('rv', startid=startid, endid=endid, - start=start, end=end, user=user, excludeuser=excludeuser)) + start=start, end=end, user=user, excludeuser=excludeuser, diffto=diffto)) kwargs['rvdir'] = dir kwargs['rvprop'] = prop if expandtemplates: