diff --git a/mwclient/client.py b/mwclient/client.py index 0eb5d41b04799b518e367879a9e8e4360a7914cd..c1cf73780374817c5b730e4d11c15a6665c4f281 100644 --- a/mwclient/client.py +++ b/mwclient/client.py @@ -690,6 +690,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=None, redirects=False, limit=None): """ Perform a full text search. @@ -712,7 +731,6 @@ class Site(object): Returns: mwclient.listings.List: Search results iterator """ - kwargs = dict(listing.List.generate_kwargs('sr', search=search, namespace=namespace, what=what)) if redirects: kwargs['srredirects'] = '1' diff --git a/mwclient/page.py b/mwclient/page.py index 20adf0729fcf5d1df541fd1849888e5159a25eef..7cff32be6f07749d039900912dd86944c3d1e3f7 100644 --- a/mwclient/page.py +++ b/mwclient/page.py @@ -406,7 +406,7 @@ 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): """ List revisions of the current page. @@ -430,7 +430,7 @@ class Page(object): mwclient.listings.List: Revision iterator """ kwargs = dict(mwclient.listing.List.generate_kwargs('rv', startid=startid, endid=endid, start=start, - end=end, user=user, excludeuser=excludeuser)) + end=end, user=user, excludeuser=excludeuser, diffto=diffto)) kwargs['rvdir'] = dir kwargs['rvprop'] = prop if expandtemplates: