<commit_before># -*- coding: utf-8 -*-
# This file is part of Shoop.
#
# Copyright (c) 2012-2015, Shoop Ltd. All rights reserved.
#
# This source code is licensed under the AGPLv3 license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import unicode_literals

import random
from collections import Counter
from decimal import Decimal

import six
from django.contrib import messages
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _

from shoop.core.models import OrderLineType, PaymentMethod, ShippingMethod
from shoop.core.order_creator.source import OrderSource, SourceLine
from shoop.front.basket.storage import BasketCompatibilityError, get_storage
from shoop.utils.numbers import parse_decimal_string
from shoop.utils.objects import compare_partial_dicts


class BasketLine(SourceLine):
    def __init__(self, source=None, **kwargs):
        # TODO: (TAX) Remove following asserts maybe?
        assert "shop_id" not in kwargs
        assert "product_id" not in kwargs
        assert "supplier_id" not in kwargs
        self.__in_init = True
        super(BasketLine, self).__init__(source, **kwargs)
        self.__in_init = False

    @property
    def shop_product(self):
        """
        ShopProduct object of this line.

        :rtype: shoop.core.models.product_shops.ShopProduct
        """
        return self.product.get_shop_instance(self.shop)

    def cache_info(self, request):
        product = self.product
        # TODO: ensure shop identity?
        price_info = product.get_price_info(request, quantity=self.quantity)
        self.unit_price = price_info.unit_base_price
        self.total_discount = price_info.discount_amount
        assert self.total_price == price_info.price
        # TODO: (TAX) Cache also taxes for BasketLine? (with product.get_taxed_price)
        self.net_weight = product.net_weight
        self.gross_weight = product.gross_weight
        self.shipping_mode = product.shipping_mode
        self.sku = product.sku
        self.text = product.safe_translation_getter("name", any_language=True)

    @property
    def type(self):
        if self.product:
            return OrderLineType.PRODUCT
        else:<commit_msg>Remove outdated tax TODO comment<commit_after># -*- coding: utf-8 -*-
# This file is part of Shoop.
#
# Copyright (c) 2012-2015, Shoop Ltd. All rights reserved.
#
# This source code is licensed under the AGPLv3 license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import unicode_literals

import random
from collections import Counter
from decimal import Decimal

import six
from django.contrib import messages
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _

from shoop.core.models import OrderLineType, PaymentMethod, ShippingMethod
from shoop.core.order_creator.source import OrderSource, SourceLine
from shoop.front.basket.storage import BasketCompatibilityError, get_storage
from shoop.utils.numbers import parse_decimal_string
from shoop.utils.objects import compare_partial_dicts


class BasketLine(SourceLine):
    def __init__(self, source=None, **kwargs):
        # TODO: (TAX) Remove following asserts maybe?
        assert "shop_id" not in kwargs
        assert "product_id" not in kwargs
        assert "supplier_id" not in kwargs
        self.__in_init = True
        super(BasketLine, self).__init__(source, **kwargs)
        self.__in_init = False

    @property
    def shop_product(self):
        """
        ShopProduct object of this line.

        :rtype: shoop.core.models.product_shops.ShopProduct
        """
        return self.product.get_shop_instance(self.shop)

    def cache_info(self, request):
        product = self.product
        # TODO: ensure shop identity?
        price_info = product.get_price_info(request, quantity=self.quantity)
        self.unit_price = price_info.unit_base_price
        self.total_discount = price_info.discount_amount
        assert self.total_price == price_info.price
        self.net_weight = product.net_weight
        self.gross_weight = product.gross_weight
        self.shipping_mode = product.shipping_mode
        self.sku = product.sku
        self.text = product.safe_translation_getter("name", any_language=True)

    @property
    def type(self):
        if self.product:
            return OrderLineType.PRODUCT
        else:
{'fraction_non_alphanumeric': 0.07284916201117318, 'fraction_numerical': 0.004469273743016759, 'mean_word_length': 3.3372093023255816, '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': '1658797', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1256, 'n_words': 364}