def main(): if len(args) != 2: return pagemain = wp.Page(wp.toutf(args[0])) newlink = wp.toutf(args[1]) pywikibot.output("old: " + pagemain.title()) pywikibot.output("new: " + newlink) for page in pagemain.backlinks(content=True): pywikibot.output("processing " + page.title()) txt = page.get() page.put(lre.sub(r"\[\[" + lre.escape(pagemain.title()), "[[" + newlink.replace("_", " "), txt), u"ย้ายลิงก์ไปหน้าใหม่")
def _removePair(self, begin, end): self.subst.append(lre.escape(begin), self.op + begin) self.subst.append(lre.escape(end), end + self.ed)