jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1330645?usp=email )
Change subject: nowcommons: Reuse file usage results
......................................................................
nowcommons: Reuse file usage results
Use the initial usage snapshot for the normal replacement pass.
After it runs, materialize one fresh snapshot for the loose URL-form pass.
This replaces the existence and page queries with one traversal.
Change-Id: Ie4593341caa67dc78e883124806ed0f709dbf7ae
---
M scripts/nowcommons.py
1 file changed, 12 insertions(+), 8 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/nowcommons.py b/scripts/nowcommons.py
index c58a1d6..d62938a 100755
--- a/scripts/nowcommons.py
+++ b/scripts/nowcommons.py
@@ -321,14 +321,18 @@
# If the image is used with the urlname
# the previous function won't work
- if local_file_page.file_is_used and self.opt.replaceloose:
- bot = ImageBot(local_file_page.using_pages(),
- local_file_page.title(with_ns=False,
- as_url=True),
- commons_title,
- always=self.opt.replacealways,
- loose=self.opt.replaceloose)
- bot.run()
+ if self.opt.replaceloose:
+ remaining_pages = list(
+ local_file_page.using_pages())
+ if remaining_pages:
+ bot = ImageBot(
+ remaining_pages,
+ local_file_page.title(with_ns=False,
+ as_url=True),
+ commons_title,
+ always=self.opt.replacealways,
+ loose=self.opt.replaceloose)
+ bot.run()
self.counter['replace'] += 1
else:
pywikibot.info('Please change them manually.')
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1330645?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: Ie4593341caa67dc78e883124806ed0f709dbf7ae
Gerrit-Change-Number: 1330645
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[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]