<commit_before># set encoding=utf-8

from logging import getLogger
log = getLogger('robokassa.receivers')

from django.http import HttpRequest
from django.contrib.sessions.backends.db import SessionStore
from django.contrib.auth.models import AnonymousUser

from oscar.core.loading import get_class, get_model
from oscar.core import prices

from robokassa.signals import result_received, success_page_visited, fail_page_visited

Selector = get_class('partner.strategy', 'Selector')
post_payment = get_class('checkout.signals', 'post_payment')
OrderPlacementMixin = get_class('checkout.mixins', 'OrderPlacementMixin')
CheckoutSessionData = get_class('checkout.utils', 'CheckoutSessionData')
Source = get_model('payment', 'Source')
SourceType = get_model('payment', 'SourceType')

selector = Selector()

class RobokassaOrderPlacement(OrderPlacementMixin):

    def handle_successful_order(self, order):
        log.info("Order with number %s, succesfully placed", order.number)
        if not hasattr(self, 'checkout_session'):  # this is a worst case scenario
            self.view_signal.send(sender=self, order=order, user=order.user,
                    confirmation_not_sent=True)
        else:
            super(RobokassaOrderPlacement, self).handle_successful_order(order)


def place_order(sender, **kwargs):
    """ collect basket, user, shipping_method and address, order_number, total
    and pass them to handle_order_placement, but first add payment events and
    sources """
    request = kwargs.get('request', None) or HttpRequest()
    basket = sender
    user = basket.owner if basket.owner else AnonymousUser()
    guest_email = None
<commit_msg>Fixed initial value for guest_email that breaks database credential.<commit_after># set encoding=utf-8

from logging import getLogger
log = getLogger('robokassa.receivers')

from django.http import HttpRequest
from django.contrib.sessions.backends.db import SessionStore
from django.contrib.auth.models import AnonymousUser

from oscar.core.loading import get_class, get_model
from oscar.core import prices

from robokassa.signals import result_received, success_page_visited, fail_page_visited

Selector = get_class('partner.strategy', 'Selector')
post_payment = get_class('checkout.signals', 'post_payment')
OrderPlacementMixin = get_class('checkout.mixins', 'OrderPlacementMixin')
CheckoutSessionData = get_class('checkout.utils', 'CheckoutSessionData')
Source = get_model('payment', 'Source')
SourceType = get_model('payment', 'SourceType')

selector = Selector()


class RobokassaOrderPlacement(OrderPlacementMixin):

    def handle_successful_order(self, order):
        log.info("Order with number %s, succesfully placed", order.number)
        if not hasattr(self, 'checkout_session'):  # this is a worst case scenario
            self.view_signal.send(sender=self, order=order, user=order.user,
                    confirmation_not_sent=True)
        else:
            super(RobokassaOrderPlacement, self).handle_successful_order(order)


def place_order(sender, **kwargs):
    """ collect basket, user, shipping_method and address, order_number, total
    and pass them to handle_order_placement, but first add payment events and
    sources """
    request = kwargs.get('request', None) or HttpRequest()
    basket = sender
    user = basket.owner if basket.owner else AnonymousUser()
    guest_email = ''

{'fraction_non_alphanumeric': 0.09378698224852071, 'fraction_numerical': 0.000591715976331361, 'mean_word_length': 5.005328596802842, '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': '1513387', 'n_tokens_mistral': 971, 'n_tokens_neox': 961, 'n_words': 253}