def mosteditsArt(): """ most edits """ regexArt = lre.genData(conf.tagind, u"บทความแก้ไขมากสุด") regexArtlist = lre.genData(conf.tagind, u"บทความรายชื่อแก้ไขมากสุด") oldtable = getdat(regexArt) oldtablelist = getdat(regexArtlist) table = [] tablelist = [] ptr = 0 patListName = lre.lre(lre.sep(conf.listname)) for page, revisions in site.mostrevisionspages(): if len(tablelist) < 5 and patListName.search(page.title()): tablelist.append([page.title(), getrankold(page.title(), oldtablelist), revisions, firstContributor(page)]) elif len(table) < 10 and not patListName.search(page.title()): table.append([page.title(), getrankold(page.title(), oldtable), revisions, firstContributor(page)]) elif (len(tablelist) >= 5) and (len(table) >= 10): break writetable(table, regexArt) writetable(tablelist, regexArtlist)
def longpages(): """ long pages """ table = [] regexLong = lre.genData(conf.tagind, u"บทความยาวสุด") oldlongpages = getdat(regexLong) for page, length in site.longpages(total=5): table.append([page.title(), getrankold(page.title(), oldlongpages), length]) writetable(table, regexLong)
def mosteditsUser(): """ most edits (user) """ limit = lre.getconf(u"ตารางชาววิกิพีเดียที่เขียนมากที่สุด", contentMain) regexUser = lre.genData(conf.tagind, u"ชาววิกิพีเดียที่เขียนมากที่สุด") oldusers = getdat(regexUser) table = [] for line in pywikibot.Page(site, conf.page500).get().split("\n"): libe = line.strip() if line == u"|-": continue if line.startswith(u"|"): line = [x.strip() for x in line[1:].split(u"||")] name = lre.pats["tspan"].sub("", lre.pats["link"].find(line[1])[2:-2]) cnt = lre.pats["link"].find(line[2], "name")[1:] if int(cnt) < int(limit): break table.append([name, getrankold(name, oldusers), cnt]) writetable(table, regexUser)