示例#1
0
def action():
    """
    Scan files in match_data to wonder value extremes
    """
    result = find_stored_stat('match_data', find_wonder_func, {})
    new_records = []
    for person in result:
        if result[person][1] == 0:
            continue
        ratio = result[person][0] / result[person][1]
        new_records.append(
            [person, result[person][1], result[person][0], ratio])
    new_records = sorted(new_records, key=itemgetter(0))
    wwon_list = sorted(new_records, key=itemgetter(2))[0:50]
    bwon_list = sorted(new_records, key=itemgetter(2), reverse=True)[0:50]
    wav_list = sorted(new_records, key=itemgetter(3))[0:50]
    bav_list = sorted(new_records, key=itemgetter(3), reverse=True)[0:50]
    out_info = {}
    out_info['highest wonder values'] = stringify(bwon_list, FORMATS)
    out_info['lowest wonder values'] = stringify(wwon_list, FORMATS)
    out_info['highest wonder average'] = stringify(bav_list, FORMATS)
    out_info['lowest wonder average'] = stringify(wav_list, FORMATS)
    odata = gen_html_page(out_info,
                          'Wonder Numbers',
                          'Wonder Numbers',
                          tabhdrs=[['Name', 'Matches', 'Wonder', 'Average']])
    ofile = 'generated_files' + os.sep + 'wonder.html'
    with open(ofile, 'w') as fdesc:
        fdesc.write(odata)
    new_records = stringify(new_records, FORMATS)
    cfile = 'generated_files' + os.sep + 'wonder.csv'
    with open(cfile, 'w') as cdesc:
        for record in new_records:
            cdesc.write(','.join(record) + '\n')
示例#2
0
def hun_compute(username):
    """
    Scan files in question_data and compute hun values for username
    """
    qinfo = get_dir_with_field(username, 'question_data')
    result = find_stored_stat('question_data', name_wrap(qinfo[username]), {})
    new_records = []
    for person in result:
        new_records.append([person, result[person]])
    hun_list = {}
    hun_list['Lowest'] = stringify(
        sorted(new_records, key=itemgetter(1))[0:50], FORMATS)
    hun_list['Highest'] = stringify(
        sorted(new_records, key=itemgetter(1), reverse=True)[1:51], FORMATS)
    for huntype in ['Highest', 'Lowest']:
        out_info = {}
        out_info['x'] = hun_list[huntype]
        odata = gen_html_page(out_info,
                              'HUN',
                              '%s HUN values for %s' % (huntype, username),
                              centered=True,
                              tabhdrs=['Name', 'HUN'])
        ofile = 'generated_files' + os.sep + '%s_HUN_for_%s.html' % (huntype,
                                                                     username)
        with open(ofile, 'w') as fdesc:
            fdesc.write(odata)
    new_records = stringify(sorted(new_records), FORMATS)
    ofile = 'generated_files' + os.sep + 'hun_%s.csv' % username
    with open(ofile, 'w') as fdesc:
        for record in new_records:
            fdesc.write(','.join(record) + '\n')
示例#3
0
def action():
    """
    Generate a csv file and a set of tables matching all optimal scores,
    totals, and averages.
    """
    result = find_stored_stat('match_data', find_oms, {})
    all_peeps = []
    for person in result:
        record = [person]
        record.extend(result[person])
        all_peeps.append(record)
    all_peeps = sorted(all_peeps, key=itemgetter(0))
    new_records = stringify(all_peeps, [])
    cfile = 'generated_files' + os.sep + 'oms.csv'
    with open(cfile, 'w') as cdesc:
        for record in new_records:
            cdesc.write(','.join(record) + '\n')
    list2 = averaged(all_peeps)
    txt_ptr = {'Total': all_peeps, 'Average': list2}
    make_html(txt_ptr)
示例#4
0
def action():
    """
    Scan files in match_data to find smallest wlt cycle
    """
    best = 25
    answers = {}
    result = find_stored_stat('match_data', find_wlt_func, {})
    all_string = ''
    for person in result:
        all_string += person + ',' + fmt_cycles(result[person]) + '\n'
        for cycle in result[person]:
            if cycle[1] < best:
                best = cycle[1]
                answers = {}
            if cycle[1] == best:
                if person in answers:
                    answers[person].append(cycle)
                else:
                    answers[person] = [cycle]
    ocsv_file = 'generated_files' + os.sep + 'wlt_cycles.csv'
    with open(ocsv_file, 'w') as ofile:
        ofile.write(all_string)
    return answers
示例#5
0
def action():
    """
    Scan files in match_data for mops information
    """
    result = find_stored_stat('match_data', find_mops_func, {})
    new_records = []
    for person in result:
        size = len(result[person][0])
        new_records.append(
            [person, result[person][1], size, result[person][0]])
    for column in range(0, 3):
        new_records = sorted(new_records, key=itemgetter(column))
    out_list = []
    for aline in new_records:
        if aline[1] > 100:
            break
        out_list.append([aline[0], str(aline[1])])
    out_info = {}
    out_info['x'] = out_list
    odata = gen_html_page(out_info,
                          'MOPS',
                          'My Own Private Scorigami',
                          centered=True,
                          tabhdrs=['Name', 'Matches Needed'])
    ofile = 'generated_files' + os.sep + 'mops.html'
    ifile = 'html_texts' + os.sep + 'mops.txt'
    odata = inject_text(odata, ifile)
    with open(ofile, 'w') as fdesc:
        fdesc.write(odata)
    ofile = 'generated_files' + os.sep + 'mops.csv'
    with open(ofile, 'w') as cdesc:
        for record in new_records:
            csvrec = [str(i) for i in record[0:3]]
            if record[2] > 0:
                csvrec.extend(xlate_num2score(record[3]))
            cdesc.write(','.join(csvrec) + '\n')