http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11262
Revision: 11262 Author: legoktm Date: 2013-03-25 12:07:37 +0000 (Mon, 25 Mar 2013) Log Message: ----------- Re-implement showPatrolled option for site.recentchanges. Also reorganized imports and PEP8 fixes
Modified Paths: -------------- branches/rewrite/pywikibot/site.py
Modified: branches/rewrite/pywikibot/site.py =================================================================== --- branches/rewrite/pywikibot/site.py 2013-03-25 12:04:03 UTC (rev 11261) +++ branches/rewrite/pywikibot/site.py 2013-03-25 12:07:37 UTC (rev 11262) @@ -10,19 +10,11 @@ # __version__ = '$Id$'
-import pywikibot -from pywikibot import deprecate_arg -from pywikibot import config -from pywikibot import deprecated -from pywikibot import pagegenerators -from pywikibot.throttle import Throttle -from pywikibot.data import api -from pywikibot.exceptions import * - try: from hashlib import md5 except ImportError: from md5 import md5 +import itertools import os import re import sys @@ -31,11 +23,22 @@ import urllib import json
+import pywikibot +from pywikibot import deprecate_arg +from pywikibot import config +from pywikibot import deprecated +from pywikibot import pagegenerators +from pywikibot.throttle import Throttle +from pywikibot.data import api +from pywikibot.exceptions import * + _logger = "wiki.site"
+ class PageInUse(pywikibot.Error): """Page cannot be reserved for writing due to existing lock."""
+ class LoginStatus(object): """ Enum for Login statuses.
@@ -1417,7 +1420,6 @@ filterRedirects=filterRedirects, namespaces=namespaces, content=content) - import itertools return itertools.chain(*genlist.values()) return blgen
@@ -1459,7 +1461,6 @@ filterRedirects=filterRedirects, namespaces=namespaces, step=step, total=total, content=content) - import itertools return itertools.islice( itertools.chain( self.pagebacklinks( @@ -2199,9 +2200,7 @@ "recentchanges: start must be later than end with reverse=False") rcgen = self._generator(api.ListGenerator, type_arg="recentchanges", rcprop="user|comment|timestamp|title|ids" - "|sizes|redirect|loginfo" - #"|sizes|redirect|patrolled|loginfo" - patrol rights needed - "|flags", + "|sizes|redirect|loginfo|flags", namespaces=namespaces, step=step, total=total) if start is not None: @@ -2224,8 +2223,11 @@ filters = {'minor': showMinor, 'bot': showBot, 'anon': showAnon, - 'redirect': showRedirects,} - #'patrolled': showPatrolled} + 'redirect': showRedirects, + } + if self.has_right('patrol'): + rcgen.request['rcprop'] += '|patrolled' + filters['patrolled'] = showPatrolled rcshow = [] for item in filters: if filters[item] is not None:
pywikipedia-svn@lists.wikimedia.org