jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/752245 )
Change subject: category_redirect: resolve pep8-naming issues
......................................................................
category_redirect: resolve pep8-naming issues
Change-Id: If2092dd62a861a36d4c647d6e8e909304178a8e4
---
M scripts/category_redirect.py
1 file changed, 22 insertions(+), 20 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/category_redirect.py b/scripts/category_redirect.py
index 2897a53..1cc02d2 100755
--- a/scripts/category_redirect.py
+++ b/scripts/category_redirect.py
@@ -30,7 +30,7 @@
can be set within a settings file which is scripts.ini by default.
"""
#
-# (C) Pywikibot team, 2008-2021
+# (C) Pywikibot team, 2008-2022
#
# Distributed under the terms of the MIT license.
#
@@ -51,6 +51,9 @@
)
+LOG_SIZE = 7 # Number of items to keep in active log
+
+
class CategoryRedirectBot(ConfigParserBot, SingleSiteBot):
"""Page category update bot.
@@ -133,34 +136,34 @@
self.site))
return self.cat is not None
- def move_contents(self, oldCatTitle, newCatTitle, editSummary):
+ def move_contents(self, old_cat_title, new_cat_title, edit_summary):
"""The worker function that moves pages out of oldCat into
newCat."""
while True:
try:
- oldCat = pywikibot.Category(self.site,
- self.catprefix + oldCatTitle)
- newCat = pywikibot.Category(self.site,
- self.catprefix + newCatTitle)
+ old_cat = pywikibot.Category(self.site,
+ self.catprefix + old_cat_title)
+ new_cat = pywikibot.Category(self.site,
+ self.catprefix + new_cat_title)
param = {
- 'oldCatLink': oldCat.title(),
- 'oldCatTitle': oldCatTitle,
- 'newCatLink': newCat.title(),
- 'newCatTitle': newCatTitle,
+ 'oldCatLink': old_cat.title(),
+ 'oldCatTitle': old_cat_title,
+ 'newCatLink': new_cat.title(),
+ 'newCatTitle': new_cat_title,
}
- summary = editSummary % param
+ summary = edit_summary % param
# Move articles
found, moved = 0, 0
- for article in oldCat.members():
+ for article in old_cat.members():
found += 1
- changed = article.change_category(oldCat, newCat,
+ changed = article.change_category(old_cat, new_cat,
summary=summary)
if changed:
moved += 1
# pass 2: look for template doc pages
for item in pywikibot.data.api.ListGenerator(
- 'categorymembers', cmtitle=oldCat.title(),
+ 'categorymembers', cmtitle=old_cat.title(),
cmprop='title|sortkey', cmnamespace='10',
cmlimit='max'):
doc = pywikibot.Page(pywikibot.Link(item['title']
@@ -169,14 +172,14 @@
doc.get()
except Error:
continue
- changed = doc.change_category(oldCat, newCat,
+ changed = doc.change_category(old_cat, new_cat,
summary=summary)
if changed:
moved += 1
if found:
pywikibot.output('{}: {} found, {} moved'
- .format(oldCat.title(), found, moved))
+ .format(old_cat.title(), found, moved))
return (found, moved)
except ServerError:
pywikibot.output('Server error: retrying in 5 seconds...')
@@ -185,7 +188,7 @@
except Exception:
return (None, None)
- def readyToEdit(self, cat):
+ def ready_to_edit(self, cat):
"""Return True if cat not edited during cooldown period, else
False."""
today = pywikibot.Timestamp.now()
deadline = today + timedelta(days=-self.opt.delay)
@@ -195,7 +198,6 @@
def get_log_text(self):
"""Rotate log text and return the most recent
text."""
- LOG_SIZE = 7 # Number of items to keep in active log
try:
log_text = self.log_page.get()
except NoPageError:
@@ -390,7 +392,7 @@
self.log_text.append(message)
continue
cat_title = cat.title(with_ns=False)
- if not self.readyToEdit(cat):
+ if not self.ready_to_edit(cat):
counts[cat_title] = None
message = i18n.twtranslate(
self.site, 'category_redirect-log-skipping',
@@ -450,7 +452,7 @@
found, moved = self.move_contents(cat_title,
dest.title(with_ns=False),
- editSummary=comment)
+ edit_summary=comment)
if found is None:
message = i18n.twtranslate(
self.site, 'category_redirect-log-move-error', {
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/752245
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: If2092dd62a861a36d4c647d6e8e909304178a8e4
Gerrit-Change-Number: 752245
Gerrit-PatchSet: 1
Gerrit-Owner: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged