Xqt has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1308558?usp=email )
Change subject: [bugfix] Fix -tofile argument in listpages.py
......................................................................
[bugfix] Fix -tofile argument in listpages.py
The -tofile option was documented and used internally by the bot
class (self.opt.tofile), but had two bugs preventing it from working:
* The command-line argument parser never added -tofile to its list
of recognized options, causing it to be rejected as an unknown
parameter.
* When preloading is False and -put is not given, each processed
page's formatted output was immediately popped from output_list
and printed to stdout, leaving output_list empty by the time
teardown() tried to write it to the file specified by -tofile.
Both are fixed: -tofile is now recognized as a valid argument, and
the immediate print/pop behavior is skipped when -tofile is set, so
output_list retains its contents for teardown() to write out.
Bug: T431418
Change-Id: I92f4f1dc06c0b92e81973860fe53fb63657bbf28
---
M scripts/listpages.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
Ivan-r: Looks good to me, but someone else must approve
diff --git a/scripts/listpages.py b/scripts/listpages.py
index 3706506..db99040 100755
--- a/scripts/listpages.py
+++ b/scripts/listpages.py
@@ -220,7 +220,7 @@
f.write(page.text.encode(self.opt.encode))
self.counter['save'] += 1
- if self.opt.preloading is False:
+ if self.opt.preloading is False and not self.opt.tofile:
pywikibot.stdout(self.output_list[-1]
if self.opt.put else self.output_list.pop())
@@ -294,7 +294,7 @@
if not value.strip():
options['notitle'] = True
options['format'] = value
- elif option in ('-encode', '-outputlang', '-save', '-summary'):
+ elif option in ('-encode', '-outputlang', '-save', '-summary',
'-tofile'):
options[opt] = value
elif option == '-put':
page_target = value
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1308558?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I92f4f1dc06c0b92e81973860fe53fb63657bbf28
Gerrit-Change-Number: 1308558
Gerrit-PatchSet: 1
Gerrit-Owner: Nihar_Chakravarti <[email protected]>
Gerrit-Reviewer: Ivan-r <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]