<commit_before>import operator

from github import Github as git
from urllib import urlopen

from web.config import properties

def rank_file_changes(flist):
    ire = {}

    for f in flist:
        print('working on file: {0}'.format(f.filename))
        if "/" in f.filename:
            dire = '/'.join(f.filename.split("/")[:-1])
        else:
            dire = '/'

        if ire.get(dire):
            score = ire.get(dire) + f.changes
        else:
            score = f.changes
        ire[dire] = score

    sorted_ire = sorted(ire.iteritems(), key=operator.itemgetter(1))
    sorted_ire.reverse()
    return sorted_ire


def get_lead_maintainer(issue):
    repo = get_repo()
    p = repo.get_pull(issue)
    files = p.get_files()
    lead_maintainer_file = rank_file_changes(files)[0][0]
    maintainer_handle = _maintainer_from_path(lead_maintainer_file)
    return maintainer_handle

def get_all_maintainers(issue):
    repo = get_repo()
    p = repo.get_pull(issue)
    files = p.get_files()
    maintainers = []
    for f in files:
        if "/" in f.filename:
            fpath = '/'.join(f.filename.split("/")[:-1])
        else:
            fpath = '/'
        maintainer = _maintainer_from_path(fpath)
        print maintainer
        if maintainer not in maintainers:
            maintainers.append(maintainer)
    return maintainers


<commit_msg>Optimize reverse sort by letting sorted() do the work of going in reverse<commit_after>import operator

from github import Github as git
from urllib import urlopen

from web.config import properties

def rank_file_changes(flist):
    ire = {}

    for f in flist:
        print('working on file: {0}'.format(f.filename))
        if "/" in f.filename:
            dire = '/'.join(f.filename.split("/")[:-1])
        else:
            dire = '/'

        if ire.get(dire):
            score = ire.get(dire) + f.changes
        else:
            score = f.changes
        ire[dire] = score

    sorted_ire = sorted(ire.iteritems(), key=operator.itemgetter(1), reverse=True)
    return sorted_ire


def get_lead_maintainer(issue):
    repo = get_repo()
    p = repo.get_pull(issue)
    files = p.get_files()
    lead_maintainer_file = rank_file_changes(files)[0][0]
    maintainer_handle = _maintainer_from_path(lead_maintainer_file)
    return maintainer_handle

def get_all_maintainers(issue):
    repo = get_repo()
    p = repo.get_pull(issue)
    files = p.get_files()
    maintainers = []
    for f in files:
        if "/" in f.filename:
            fpath = '/'.join(f.filename.split("/")[:-1])
        else:
            fpath = '/'
        maintainer = _maintainer_from_path(fpath)
        print maintainer
        if maintainer not in maintainers:
            maintainers.append(maintainer)
    return maintainers



{'fraction_non_alphanumeric': 0.11286277319957004, 'fraction_numerical': 0.004299534217126478, 'mean_word_length': 2.4048780487804877, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6461368', 'n_tokens_mistral': 910, 'n_tokens_neox': 890, 'n_words': 204}