示例#1
0
def write_templates(res):
    import pywikibot
    from common.pywikibot_utils import safe_put

    for dom in [ 'fr','en', 'bn', 'pl' ]:
	if dom=='fr':
	    sep=' '
	elif dom == 'en':
	    sep=','
        else:
            sep = ''

        num, num_q0, num_q2, num_q3, num_q4, num_tr, num_texts, num_disambig = decode_res( res[dom] )
        percent = num_tr*100./(num_texts-num_disambig)
        num_q1 = num - (num_q0 + num_q2 + num_q3 + num_q4 ) 

	site = pywikibot.getSite(dom,fam='wikisource')
        page = pywikibot.Page(site,"Template:PAGES_NOT_PROOFREAD")
        safe_put(page, spaced_int(num_q1,sep), "")
        page = pywikibot.Page(site,"Template:ALL_PAGES")
        safe_put(page, spaced_int(num,sep), "")
        page = pywikibot.Page(site,"Template:PR_TEXTS")
        safe_put(page, spaced_int(num_tr,sep), "")
        page = pywikibot.Page(site,"Template:ALL_TEXTS")
        safe_put(page, spaced_int(num_texts - num_disambig,sep), "")
        page = pywikibot.Page(site,"Template:PR_PERCENT")
        safe_put(page, "%.2f"%percent, "")
示例#2
0
def write_templates(res):
    import pywikibot

    for dom in [ 'fr','en', 'bn', 'pl' ]:
	if dom=='fr':
	    sep=' '
	elif dom == 'en':
	    sep=','
        else:
            sep = ''

        num, num_q0, num_q2, num_q3, num_q4, num_tr, num_texts, num_disambig = decode_res( res[dom] )
        percent = num_tr*100./(num_texts-num_disambig)
        num_q1 = num - (num_q0 + num_q2 + num_q3 + num_q4 ) 

	site = pywikibot.getSite(dom,fam='wikisource')
        page = pywikibot.Page(site,"Template:PAGES_NOT_PROOFREAD")
        page.put(spaced_int(num_q1,sep))
        page = pywikibot.Page(site,"Template:ALL_PAGES")
        page.put(spaced_int(num,sep))
        page = pywikibot.Page(site,"Template:PR_TEXTS")
        page.put(spaced_int(num_tr,sep))
        page = pywikibot.Page(site,"Template:ALL_TEXTS")
        page.put(spaced_int(num_texts - num_disambig,sep))
        page = pywikibot.Page(site,"Template:PR_PERCENT")
        page.put("%.2f"%percent)
示例#3
0
def read_stats(offset):
    f = open(os.path.expanduser("~/public_html/data/new_stats.py"),"r")
    lines = f.readlines()
    f.close()
    t, oldres = eval( lines[offset] )
    for k in oldres.keys():
        oldres[k] = decode_res(oldres[k])
    return t, oldres 
示例#4
0
def read_stats(offset):
    f = open(os.path.expanduser("~/public_html/data/new_stats.py"),"r")
    lines = f.readlines()
    f.close()
    t, oldres = eval( lines[offset] )
    for k in oldres.keys():
        oldres[k] = decode_res(oldres[k])
    return t, oldres 
示例#5
0
def add_rev(line):
    bad_days = {
        'en':range(613,633) , # hesperian bump
        'sv':[942,943,944]}   # misconfiguration

    very_bad_days = range(765,788+1) # bug after code update
    #there's also the toolserver stopping period
    global epoch
    z_time, res = eval(line)
    t_time = z_time/(60*60*24)    
    if not epoch: epoch = t_time
    mtime = t_time - epoch

    total_allpages = 0
    total_num_q0 = 0
    total_num_q2 = 0
    total_num_q3 = 0
    total_num_q4 = 0
    total_all_texts = 0
    total_pr_texts = total_disambig_texts = 0

    d = pylab.date2num( datetime.datetime.fromtimestamp(z_time) )

    all_ok = True

    for dom in res.keys():
        if not dom in names: continue
        count = count_array[dom]
        allpages, num_q0, num_q2, num_q3, num_q4, pr_texts, all_texts, disambig_texts = decode_res( res[dom] )
        ok = True
        bd = bad_days.get(dom)
        if bd and int(mtime) in bd: ok=False
        if int(mtime) in very_bad_days: ok=False
        if ok:
            add_point(count, d, allpages, num_q0, num_q2, num_q3, num_q4, all_texts, pr_texts, disambig_texts)

            if allpages: total_allpages +=allpages
            if num_q0: total_num_q0 += num_q0
            if num_q2: total_num_q2 += num_q2
            if num_q3: total_num_q3 += num_q3
            if num_q4: total_num_q4 += num_q4
            if all_texts: total_all_texts += all_texts
            if pr_texts: total_pr_texts += pr_texts
            if disambig_texts: total_disambig_texts += disambig_texts
        else:
            all_ok=False

    if all_ok:
        count = count_array["total"]
        add_point(count, d, total_allpages, total_num_q0, total_num_q2, total_num_q3, total_num_q4, total_all_texts, total_pr_texts, total_disambig_texts)
示例#6
0
def add_rev(line):
    bad_days = {
        'en': range(613, 633),  # hesperian bump
        'sv': [942, 943, 944]
    }  # misconfiguration

    very_bad_days = range(765, 788 + 1)  # bug after code update
    #there's also the toolserver stopping period
    global epoch
    z_time, res = eval(line)
    t_time = z_time / (60 * 60 * 24)
    if not epoch: epoch = t_time
    mtime = t_time - epoch

    total_allpages = 0
    total_num_q0 = 0
    total_num_q2 = 0
    total_num_q3 = 0
    total_num_q4 = 0
    total_all_texts = 0
    total_pr_texts = total_disambig_texts = 0

    d = pylab.date2num(datetime.datetime.fromtimestamp(z_time))

    all_ok = True

    for dom in res.keys():
        if not dom in names: continue
        count = count_array[dom]
        allpages, num_q0, num_q2, num_q3, num_q4, pr_texts, all_texts, disambig_texts = decode_res(
            res[dom])
        ok = True
        bd = bad_days.get(dom)
        if bd and int(mtime) in bd: ok = False
        if int(mtime) in very_bad_days: ok = False
        if ok:
            add_point(count, d, allpages, num_q0, num_q2, num_q3, num_q4,
                      all_texts, pr_texts, disambig_texts)

            if allpages: total_allpages += allpages
            if num_q0: total_num_q0 += num_q0
            if num_q2: total_num_q2 += num_q2
            if num_q3: total_num_q3 += num_q3
            if num_q4: total_num_q4 += num_q4
            if all_texts: total_all_texts += all_texts
            if pr_texts: total_pr_texts += pr_texts
            if disambig_texts: total_disambig_texts += disambig_texts
        else:
            all_ok = False

    if all_ok:
        count = count_array["total"]
        add_point(count, d, total_allpages, total_num_q0, total_num_q2,
                  total_num_q3, total_num_q4, total_all_texts, total_pr_texts,
                  total_disambig_texts)