<commit_before>from django.conf.urls.defaults import url, include
from django.utils.translation import ugettext_lazy as _
from livesettings import config_get_group, config_value
from payment.signals import payment_choices
from satchmo_store import shop
from signals_ahoy.signals import collect_urls

config_group = config_get_group('PAYMENT_DUMB')

def add_dumb_urls(sender, patterns=None, **kwargs):
    """
    Payment in satchmo is unfriendly towards us; it only adds urls for modules
    with `PAYMENT_PROCESSOR` in their model.

    (See models.py on why we don't define `PAYMENT_PROCESSOR`.)
    """
    patterns.append(
        url(r'^checkout/%s/' % config_value(config_group, 'URL_BASE'),
            include('%s.urls' % config_value(config_group, 'MODULE').__name__),)
    )

collect_urls.connect(add_dumb_urls, sender=shop)

def add_dumb_method(sender, choices=None, **kwargs):
    """
    The `payment_choices` signal doesn't really allow us cover all the bases -
    `payment.active_gateways()` is the one to hack.

    But it's close.
    """
    if not choices:
        return

    module = config_value(config_group, 'MODULE')
    group = 'PAYMENT_DUMB'

    # repeat logic in `payment.config.labelled_gateway_choices()`
    defaultlabel = module.__name__.split('.')[-1]
    label = _(config_value(group, 'LABEL', default = defaultlabel))
    choices.append((group, label))

payment_choices.connect(add_dumb_method)
<commit_msg>listeners: use string for config_group<commit_after>from django.conf.urls.defaults import url, include
from django.utils.translation import ugettext_lazy as _
from livesettings import config_get_group, config_value
from payment.signals import payment_choices
from satchmo_store import shop
from signals_ahoy.signals import collect_urls

config_group = 'PAYMENT_DUMB'

def add_dumb_urls(sender, patterns=None, **kwargs):
    """
    Payment in satchmo is unfriendly towards us; it only adds urls for modules
    with `PAYMENT_PROCESSOR` in their model.

    (See models.py on why we don't define `PAYMENT_PROCESSOR`.)
    """
    patterns.append(
        url(r'^checkout/%s/' % config_value(config_group, 'URL_BASE'),
            include('%s.urls' % config_value(config_group, 'MODULE').__name__),)
    )

collect_urls.connect(add_dumb_urls, sender=shop)

def add_dumb_method(sender, choices=None, **kwargs):
    """
    The `payment_choices` signal doesn't really allow us cover all the bases -
    `payment.active_gateways()` is the one to hack.

    But it's close.
    """
    if not choices:
        return

    module = config_value(config_group, 'MODULE')

    # repeat logic in `payment.config.labelled_gateway_choices()`
    defaultlabel = module.__name__.split('.')[-1]
    label = _(config_value(config_group, 'LABEL', default = defaultlabel))
    choices.append((config_group, label))

payment_choices.connect(add_dumb_method)

{'fraction_non_alphanumeric': 0.1040943789035392, 'fraction_numerical': 0.0006939625260235947, 'mean_word_length': 4.319188191881919, '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': '4956947', 'n_tokens_mistral': 921, 'n_tokens_neox': 918, 'n_words': 232}