def get_wiki_save_page(stat_page=False): site = pywikibot.getSite() wiki_save_path = { '_default': u'User:%s/Report' % config.usernames[ site.family.name][site.lang], 'es': u'Usuario:%s/Reporte' % config.usernames[ site.family.name][site.lang], 'it': u'Utente:RevertBot/Report' } save_path = pywikibot.translate(site, wiki_save_path) if stat_page: return pywikibot.Page(site, '%s/%s' % (save_path, pywikibot.translate(site, stat_msg)[0])) if append_date_to_wiki_save_path: t = time.localtime() day = '' if append_day_to_wiki_save_path: day = '_' + str(t[2]) save_path += '%s_%s_%s' % (day, date.monthName(site.language(), t[1]), str(t[0])) return pywikibot.Page(site, save_path)
def get_wiki_save_page(stat_page=False): site = pywikibot.getSite() wiki_save_path = { '_default': u'User:%s/Report' % config.usernames[site.family.name][site.lang], 'es': u'Usuario:%s/Reporte' % config.usernames[site.family.name][site.lang], 'it': u'Utente:RevertBot/Report' } save_path = pywikibot.translate(site, wiki_save_path) if stat_page: return pywikibot.Page( site, '%s/%s' % (save_path, pywikibot.translate(site, stat_msg)[0])) if append_date_to_wiki_save_path: t = time.localtime() day = '' if append_day_to_wiki_save_path: day = '_' + str(t[2]) save_path += day + '_' + date.monthName(site.language(), t[1]) + '_' + str(t[0]) return pywikibot.Page(site, save_path)
def get_stats(): import catlib, pagegenerators msg = pywikibot.translate(pywikibot.getSite(), stat_msg) cat = catlib.Category( pywikibot.getSite(), 'Category:%s' % pywikibot.translate(pywikibot.getSite(), reports_cat)) gen = pagegenerators.CategorizedPageGenerator(cat, recurse=True) output = u"""{| {{prettytable|width=|align=|text-align=left}} ! %s ! %s ! %s ! %s ! %s ! %s |- """ % (msg[1], msg[2], msg[3], 'Google', 'Yahoo', 'Live Search') gnt = 0 ynt = 0 mnt = 0 ent = 0 sn = 0 snt = 0 for page in gen: data = page.get() gn = stat_sum('google', data) yn = stat_sum('yahoo', data) mn = stat_sum('(msn|live)', data) en = len(re.findall('=== \[\[', data)) sn = len(data) gnt += gn ynt += yn mnt += mn ent += en snt += sn if en > 0: output += u"|%s||%s||%s KB||%s||%s||%s\n|-\n" \ % (page.title(asLink=True), en, sn / 1024, gn, yn, mn) output += u"""| |||||||| |- |'''%s'''||%s||%s KB||%s||%s||%s |- |colspan="6" align=right style="background-color:#eeeeee;"|<small>''%s: %s''</small> |} """ % (msg[4], ent, snt / 1024, gnt, ynt, mnt, msg[5], time.strftime("%d " + "%s" % (date.monthName(pywikibot.getSite().language(), time.localtime()[1])) + " %Y")) return output
def get_stats(): import catlib, pagegenerators msg = wikipedia.translate(wikipedia.getSite(), stat_msg) cat = catlib.Category(wikipedia.getSite(), 'Category:%s' % wikipedia.translate(wikipedia.getSite(), reports_cat)) gen = pagegenerators.CategorizedPageGenerator(cat, recurse = True) output = u"""{| {{prettytable|width=|align=|text-align=left}} ! %s ! %s ! %s ! %s ! %s ! %s |- """ % ( msg[1], msg[2], msg[3], 'Google', 'Yahoo', 'Live Search' ) gnt = 0 ; ynt = 0 ; mnt = 0 ; ent = 0 ; sn = 0 ; snt = 0 for page in gen: data = page.get() gn = stat_sum('google', data) yn = stat_sum('yahoo', data) mn = stat_sum('(msn|live)', data) en = len(re.findall('=== \[\[', data)) sn = len(data) gnt += gn ; ynt += yn ; mnt += mn ; ent += en ; snt += sn if en > 0: output += u"|%s||%s||%s KB||%s||%s||%s\n|-\n" % (page.aslink(), en, sn / 1024, gn, yn, mn) output += u"""| |||||||| |- |'''%s'''||%s||%s KB||%s||%s||%s |- |colspan="6" align=right style="background-color:#eeeeee;"|<small>''%s: %s''</small> |} """ % (msg[4], ent, snt / 1024, gnt, ynt, mnt, msg[5], time.strftime("%d " + "%s" % (date.monthName(wikipedia.getSite().language(), time.localtime()[1])) + " %Y")) return output
def get_wiki_save_page(stat_page = False): site = wikipedia.getSite() wiki_save_path = { '_default': u'User:%s/Report' % config.usernames[site.family.name][site.lang], 'it': u'Utente:RevertBot/Report' } save_path = wikipedia.translate(site, wiki_save_path) if stat_page: return wikipedia.Page(site, '%s/%s' % (save_path, wikipedia.translate(site, stat_msg)[0])) if append_date_to_wiki_save_path: t = time.localtime() day = '' if append_day_to_wiki_save_path: day = '_' + str(t[2]) save_path += day + '_' + date.monthName(site.language(), t[1]) + '_' + str(t[0]) return wikipedia.Page(site, save_path)
def get_wiki_save_page(stat_page=False): site = wikipedia.getSite() wiki_save_path = { "_default": u"User:%s/Report" % config.usernames[site.family.name][site.lang], "es": u"Usuario:%s/Reporte" % config.usernames[site.family.name][site.lang], "it": u"Utente:RevertBot/Report", } save_path = wikipedia.translate(site, wiki_save_path) if stat_page: return wikipedia.Page(site, "%s/%s" % (save_path, wikipedia.translate(site, stat_msg)[0])) if append_date_to_wiki_save_path: t = time.localtime() day = "" if append_day_to_wiki_save_path: day = "_" + str(t[2]) save_path += day + "_" + date.monthName(site.language(), t[1]) + "_" + str(t[0]) return wikipedia.Page(site, save_path)