jenkins-bot has submitted this change and it was merged.
Change subject: fix textlib.getCategoryLinks() and textlib.replaceCategoryLinks() ......................................................................
fix textlib.getCategoryLinks() and textlib.replaceCategoryLinks()
by adding the 'site' argument
loosely related to bug 58084
Change-Id: I563bb24edb7b1db987b78a2d2ef4d6cb7597289f --- M pywikibot/page.py M scripts/catall.py M scripts/category.py M scripts/commons_link.py M scripts/makecat.py M scripts/replace.py 6 files changed, 13 insertions(+), 8 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py index 3396ed1..55d4c71 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -1630,7 +1630,8 @@ # get list of Category objects the article is in and remove possible # duplicates cats = [] - for cat in pywikibot.textlib.getCategoryLinks(self.text): + for cat in pywikibot.textlib.getCategoryLinks(self.text, + site=self.site): if cat not in cats: cats.append(cat)
@@ -1655,11 +1656,13 @@
if inPlace or self.namespace() == 10: oldtext = self.get(get_redirect=True) - newtext = pywikibot.replaceCategoryInPlace(oldtext, oldCat, newCat) + newtext = pywikibot.replaceCategoryInPlace(oldtext, oldCat, newCat, + site=self.site) else: if newCat: cats[cats.index(oldCat)] = Category(site, newCat.title(), - sortKey=sortKey) + sortKey=sortKey, + site=self.site) else: cats.pop(cats.index(oldCat)) oldtext = self.get(get_redirect=True) diff --git a/scripts/catall.py b/scripts/catall.py index 15dc8cd..e908bd0 100755 --- a/scripts/catall.py +++ b/scripts/catall.py @@ -64,7 +64,8 @@ for p in list: cattitle = "%s:%s" % (site.category_namespace(), p) pllist.append(pywikibot.Page(site, cattitle)) - page.put_async(pywikibot.replaceCategoryLinks(page.get(), pllist), + page.put_async(pywikibot.replaceCategoryLinks(page.get(), pllist, + site=page.site), comment=i18n.twtranslate(site.code, 'catall-changing'))
diff --git a/scripts/category.py b/scripts/category.py index 3923ca0..2d5d754 100755 --- a/scripts/category.py +++ b/scripts/category.py @@ -386,7 +386,7 @@ catpl = self.sorted_by_last_name(catpl, page) pywikibot.output(u'Adding %s' % catpl.title(asLink=True)) cats.append(catpl) - text = pywikibot.replaceCategoryLinks(text, cats) + text = pywikibot.replaceCategoryLinks(text, cats, site=page.site) if not self.save(text, page, newcatTitle): pywikibot.output(u'Page %s not saved.' % page.title(asLink=True)) diff --git a/scripts/commons_link.py b/scripts/commons_link.py index fdc0950..34a7721 100644 --- a/scripts/commons_link.py +++ b/scripts/commons_link.py @@ -83,7 +83,7 @@ text = textlib.replaceCategoryLinks( u'%s{{commons%s|%s}}' % (text, ('', 'cat')[catmode], pagetitle), - cats) + cats, site=page.site) comment = i18n.twtranslate(page.site, 'commons_link%s-template-added' % ('', '-cat')[catmode]) diff --git a/scripts/makecat.py b/scripts/makecat.py index f997906..3db5ecf 100644 --- a/scripts/makecat.py +++ b/scripts/makecat.py @@ -94,7 +94,7 @@ break else: pl.put(pywikibot.replaceCategoryLinks( - text, cats + [actualworkingcat])) + text, cats + [actualworkingcat], site=pl.site)) if cl: if checkforward: for page2 in pl.linkedPages(): diff --git a/scripts/replace.py b/scripts/replace.py index 75b0ccf..ca969dc 100755 --- a/scripts/replace.py +++ b/scripts/replace.py @@ -364,7 +364,8 @@ if self.addedCat not in cats: cats.append(self.addedCat) new_text = pywikibot.replaceCategoryLinks(new_text, - cats) + cats, + site=page.site) # Show the title of the page we're working on. # Highlight the title in purple. pywikibot.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<"
pywikibot-commits@lists.wikimedia.org