<commit_before>import logging
import re

from django.utils.translation import ugettext_lazy as _
from django.contrib import admin
from django.core.exceptions import PermissionDenied
from django.http import HttpResponse
from django.utils import timezone
from django.contrib.admin.sites import NotRegistered

from bluebottle.bb_payouts.admin import BaseProjectPayoutAdmin, BaseOrganizationPayoutAdmin
from bluebottle.utils.model_dispatcher import get_project_payout_model, get_organization_payout_model
from bluebottle.utils.admin import export_as_csv_action
from bluebottle.clients import properties
from bluebottle.payouts.models import ProjectPayout

logger = logging.getLogger(__name__)


PROJECT_PAYOUT_MODEL = get_project_payout_model()
ORGANIZATION_PAYOUT_MODEL = get_organization_payout_model()


class PayoutListFilter(admin.SimpleListFilter):
    title = _('Payout rule')
    parameter_name = 'payout_rule'

    def lookups(self, request, model_admin):
        rules = getattr(properties, 'PROJECT_PAYOUT_FEES', {})
        rule_choices = ProjectPayout.PayoutRules.choices

        def _value(label):
            import ipdb; ipdb.set_trace()
            value = re.search(r'\d+', label)
            try:
                return int(value.group(0))
            except:
                return None

        def _label(v, k):
            return "{0}% ({1})".format(int(v*100), k)

        return tuple(sorted(((k, _label(v,k)) for k, v in rules.iteritems()), key=lambda x: _value(x[1])))<commit_msg>Remove debugger<commit_after>import logging
import re

from django.utils.translation import ugettext_lazy as _
from django.contrib import admin
from django.core.exceptions import PermissionDenied
from django.http import HttpResponse
from django.utils import timezone
from django.contrib.admin.sites import NotRegistered

from bluebottle.bb_payouts.admin import BaseProjectPayoutAdmin, BaseOrganizationPayoutAdmin
from bluebottle.utils.model_dispatcher import get_project_payout_model, get_organization_payout_model
from bluebottle.utils.admin import export_as_csv_action
from bluebottle.clients import properties
from bluebottle.payouts.models import ProjectPayout

logger = logging.getLogger(__name__)


PROJECT_PAYOUT_MODEL = get_project_payout_model()
ORGANIZATION_PAYOUT_MODEL = get_organization_payout_model()


class PayoutListFilter(admin.SimpleListFilter):
    title = _('Payout rule')
    parameter_name = 'payout_rule'

    def lookups(self, request, model_admin):
        rules = getattr(properties, 'PROJECT_PAYOUT_FEES', {})
        rule_choices = ProjectPayout.PayoutRules.choices

        def _value(label):
            value = re.search(r'\d+', label)
            try:
                return int(value.group(0))
            except:
                return None

        def _label(v, k):
            return "{0}% ({1})".format(int(v*100), k)

        return tuple(sorted(((k, _label(v,k)) for k, v in rules.iteritems()), key=lambda x: _value(x[1])))
{'fraction_non_alphanumeric': 0.08557951482479785, 'fraction_numerical': 0.0047169811320754715, 'mean_word_length': 4.101374570446735, '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': '5033225', 'n_tokens_mistral': 928, 'n_tokens_neox': 897, 'n_words': 207}