<commit_before># -*- coding: utf-8 -*-
import json
import uuid
from collections import OrderedDict
from django.core.exceptions import ObjectDoesNotExist
from django.db import IntegrityError
from django.forms.models import model_to_dict
from django.http import QueryDict
from uppsell.util import to_rfc2822
from uppsell.util.responses import *
from uppsell import models
from uppsell.resources import Resource, ModelResource
from uppsell.response import JsonResponse
from uppsell.util.serialize import model_to_dict
from uppsell.exceptions import *

def get_listings(store):
    for listing in models.Listing.objects.filter(store=store):
        prod, listing_dict = {}, model_to_dict(listing)
        for k, v in model_to_dict(listing.product).items():
            l, p = listing, listing.product

def make_anonymous_customer():
    username = "anon_%s" % str(uuid.uuid4().get_hex().upper()[0:25])
    customer = models.Customer.objects.create(username=username)
    return customer

def format_listing(listing, quantity = None):
    prod_dict, listing_dict = model_to_dict(listing.product), model_to_dict(listing)
    prod_dict['price'] = listing_dict['price']
    prod_dict['shipping'] = listing_dict['shipping']
    prod_dict['tax_rate'] = listing.tax_rate.rate
    prod_dict['group_name'] = listing.product.group.name
    for k in ('name', 'title', 'subtitle', 'description', 'features'):
        if listing_dict[k]: prod_dict[k] = listing_dict[k]
    if prod_dict['features']:<commit_msg>Add tax-rate abbreviation to listing resource<commit_after># -*- coding: utf-8 -*-
import json
import uuid
from collections import OrderedDict
from django.core.exceptions import ObjectDoesNotExist
from django.db import IntegrityError
from django.forms.models import model_to_dict
from django.http import QueryDict
from uppsell.util import to_rfc2822
from uppsell.util.responses import *
from uppsell import models
from uppsell.resources import Resource, ModelResource
from uppsell.response import JsonResponse
from uppsell.util.serialize import model_to_dict
from uppsell.exceptions import *

def get_listings(store):
    for listing in models.Listing.objects.filter(store=store):
        prod, listing_dict = {}, model_to_dict(listing)
        for k, v in model_to_dict(listing.product).items():
            l, p = listing, listing.product

def make_anonymous_customer():
    username = "anon_%s" % str(uuid.uuid4().get_hex().upper()[0:25])
    customer = models.Customer.objects.create(username=username)
    return customer

def format_listing(listing, quantity = None):
    prod_dict, listing_dict = model_to_dict(listing.product), model_to_dict(listing)
    prod_dict['price'] = listing_dict['price']
    prod_dict['shipping'] = listing_dict['shipping']
    prod_dict['tax_rate'] = listing.tax_rate.rate
    prod_dict['tax_rate_abbr'] = listing.tax_rate.abbreviation
    prod_dict['group_name'] = listing.product.group.name
    for k in ('name', 'title', 'subtitle', 'description', 'features'):
        if listing_dict[k]: prod_dict[k] = listing_dict[k]
    if prod_dict['features']:
{'fraction_non_alphanumeric': 0.10840636157091853, 'fraction_numerical': 0.005842259006815969, 'mean_word_length': 5.043137254901961, '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': '1343247', 'n_tokens_mistral': 949, 'n_tokens_neox': 915, 'n_words': 228}