Xqt has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/341995 )

Change subject: Add -property option to pagegenerators.py
......................................................................

Add -property option to pagegenerators.py

Change-Id: Ib128f197f2b43d00ea2ad1846a3d1788ad936abe
---
M pywikibot/pagegenerators.py
1 file changed, 23 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/95/341995/1

diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index 98ed579..60c30ba 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -247,6 +247,9 @@
                   Argument can be given as "-unwatched:n" where
                   n is the maximum number of articles to work on.
 
+-property:name    Work on all pages with a given propery name from
+                  Special:PagesWithProp.
+
 -usercontribs     Work on all articles that were edited by a certain user.
                   (Example : -usercontribs:DumZiBoT)
 
@@ -661,6 +664,10 @@
         elif arg == '-unwatched':
             gen = UnwatchedPagesPageGenerator(total=intNone(value),
                                               site=self.site)
+        elif arg == '-property':
+            if not value:
+                value = pywikibot.input('Which property name to be used?')
+            gen = page_with_property_generator(value, site=self.site)
         elif arg == '-usercontribs':
             gen = UserContributionsGenerator(value)
         elif arg == '-withoutinterwiki':
@@ -2168,6 +2175,22 @@
         yield page
 
 
+def page_with_property_generator(name, total=None, site=None):
+    """
+    Special:PagesWithProperty page generator.
+
+    @param name: Property name of pages to be retrieved
+    @type name: str
+    @param total: Maximum number of pages to retrieve in total
+    @type total: int
+    @param site: Site for generator results.
+    @type site: L{pywikibot.site.BaseSite}
+    """
+    if site is None:
+        site = pywikibot.Site()
+    return site.pages_with_property(name, total=total)
+
+
 def WantedPagesPageGenerator(total=100, site=None):
     """
     Wanted page generator.

-- 
To view, visit https://gerrit.wikimedia.org/r/341995
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib128f197f2b43d00ea2ad1846a3d1788ad936abe
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <i...@gno.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to