def check(revision): title = revision["title"] pywikibot.output(u"check page %s @ %s" % (title, wp.getTime())) revid = revision["revid"] oldrevid = revision["old_revid"] page = wp.Page(title) textnew = page.getOldVersion(revid) textold = u"" if oldrevid == 0 else page.getOldVersion(oldrevid) if site.getRedirectText(textnew): return if site.getRedirectText(textold): textold = "" addedlinks = (set(site.pagelinks_by_text(textnew, title)) - set(site.pagelinks_by_text(textold, title))) disamlinks = [] for link in addedlinks: if ":" in link.title(): continue if link.title().startswith(u"#"): continue try: lname = link.title() if link.isRedirectPage(): link = link.getRedirectTarget() if link.isDisambig(): disamlinks.append(lname) except: wp.error() if disamlinks: save(revision["user"], title, set(disamlinks))
def dowrite(path, data, activedata): pretext = u"ปรับปรุงล่าสุด %s\n\n{{/begin|500}}\n" % wp.getTime() entry = [] cnt = 1 for i in data: entry.append(u"|-\n| %(cnt)d || [[User:%(name)s|%(op)s%(name)s%(ed)s]]" u" %(sys)s %(bot)s || [[Special:Contributions/%(name)s" u"|%(edit)s]]\n" % { "cnt": cnt, "name": i["name"], "sys": "(Admin)" if ("sysop" in i["groups"]) else "", "bot": "(Bot)" if isbot(i) else "", "edit": i["editcount"], "op": '<span style="color:grey">' if (i["name"] not in activedata) else '', "ed": '</span>' if (i["name"] not in activedata) else '', }) cnt += 1 page = pywikibot.Page(site, path) gettext = page.get() dummy, posttext = gettext.split(u"{{/end}}") page.put(pretext + "".join(entry) + "{{/end}}" + posttext, conf.summary) pywikibot.output("done!")
def writetable(table, regex): global contentMain for i in xrange(len(table)): table[i][0] = u"%s %d. [[%s]]" % (tag(i + 1 - table[i][1]), i + 1, table[i][0]) if table[i][1] == sys.maxint: table[i][1] = conf.newcomer table[i] = u" || ".join([unicode(x) for x in table[i]]) contentMain = regex.sub(u"".join(map(lambda x: u"\n|-\n| " + x, table)) + "\n|}\n{{hatnote|" + conf.summary + u" %s}}\n" % wp.getTime(), contentMain)
def main(): """Main function""" if wp.handlearg("pending", args): pywikibot.output("move pending entry") title = conf.pageMinor operation = "minor" else: title = conf.pageMajor operation = "major" header, table, disable = lservice.service(page=wp.Page(title), confpage=wp.Page(conf.datwiki), operation=operation, verify=verify, summary=summaryWithTime, #debug=True, ) report = [] pending = [] for i, line in enumerate(table): putline = "|-\n| " + " || ".join(line) if (operation == "minor") or (not disable[i]): templateStat = conf.notDoneTemplate try: domove(lre.pats["name"].find(line[1], 1), lre.pats["name"].find(line[2], 1)) except: wp.error() else: templateStat = conf.doneTemplate putline += " || %s %s" % (templateStat, wp.getTime()) report.append(putline) else: pending.append(putline) appendTable(conf.pageReport, report) appendTable(conf.pageMinor, pending)
def summaryWithTime(): return u"บอตจัดหมวดหมู่และลิงก์ข้ามภาษา (วิกิสนเทศ) อัตโนมัติ @ %s" % wp.getTime()
def summaryWithTime(): return conf.summary + " @ " + wp.getTime()