def on_task_filter(self, task, config):
    if (not config):
        return
    identified_by = ('{{ id }}' if (config['identified_by'] == 'auto') else config['identified_by'])
    action_on_best = (entry_actions[config['on_best']] if (config['on_best'] != 'do_nothing') else None)
    action_on_lower = (entry_actions[config['on_lower']] if (config['on_lower'] != 'do_nothing') else None)
    grouped_entries = group_entries((task.accepted + task.undecided), identified_by)
    for (identifier, entries) in grouped_entries.items():
        if (not entries):
            continue
        entries.sort(key=(lambda e: (e['quality'], e.get('proper_count', 0))), reverse=True)
        best = entries.pop(0)
        if action_on_best:
            action_on_best(best, ('has the best quality for identifier %s' % identifier))
        if action_on_lower:
            for entry in entries:
                action_on_lower(entry, ('lower quality for identifier %s' % identifier))
def on_task_filter(self, task, config):
    if (not config):
        return
    identified_by = ('{{ id }}' if (config['identified_by'] == 'auto') else config['identified_by'])
    action_on_best = (entry_actions[config['on_best']] if (config['on_best'] != 'do_nothing') else None)
    action_on_lower = (entry_actions[config['on_lower']] if (config['on_lower'] != 'do_nothing') else None)
    grouped_entries = group_entries((task.accepted + task.undecided), identified_by)
    for (identifier, entries) in grouped_entries.items():
        if (not entries):
            continue
        entries.sort(key=(lambda e: (e['quality'], e.get('proper_count', 0))), reverse=True)
        best = entries.pop(0)
        if action_on_best:
            action_on_best(best, ('has the best quality for identifier %s' % identifier))
        if action_on_lower:
            for entry in entries:
                action_on_lower(entry, ('lower quality for identifier %s' % identifier))