jenkins-bot has submitted this change and it was merged.
Change subject: Bug 64855 - get.py not ported from compat but added to listpages.py
......................................................................
Bug 64855 - get.py not ported from compat but added to listpages.py
Optionally, page content is retrieved and written to standard output.
This makes it possible to pipe the text to another process.
Change-Id: Ibd4717af9763d4989e36902b0210f411709f9f48
---
M scripts/listpages.py
1 file changed, 23 insertions(+), 6 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/listpages.py b/scripts/listpages.py
index ec22d0e..233160a 100644
--- a/scripts/listpages.py
+++ b/scripts/listpages.py
@@ -1,10 +1,16 @@
# -*- coding: utf-8 -*-
"""
-Print a list of pages, as defined by page generator parameters
+Print a list of pages, as defined by page generator parameters.
+Optionally, it also prints page content to STDOUT.
These parameters are supported to specify which pages titles to print:
¶ms;
+
+-notitle Page title is not printed.
+
+-get Page content is printed.
+
"""
#
# (C) Pywikibot team, 2008-2014
@@ -22,15 +28,26 @@
def main(*args):
gen = None
+ notitle = False
+ page_get = False
+
genFactory = GeneratorFactory()
for arg in pywikibot.handleArgs(*args):
- genFactory.handleArg(arg)
+ if arg == '-notitle':
+ notitle = True
+ elif arg == '-get':
+ page_get = True
+ else:
+ genFactory.handleArg(arg)
+
gen = genFactory.getCombinedGenerator()
if gen:
- i = 0
- for page in gen:
- i += 1
- pywikibot.stdout("%4d: %s" % (i, page.title()))
+ for i, page in enumerate(gen, start=1):
+ if not notitle:
+ pywikibot.stdout("%4d: %s" % (i, page.title()))
+ if page_get:
+ # TODO: catch exceptions
+ pywikibot.output(page.text, toStdout=True)
else:
pywikibot.showHelp()
--
To view, visit
https://gerrit.wikimedia.org/r/131872
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibd4717af9763d4989e36902b0210f411709f9f48
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>