def get_car_brands_and_ids(car_brand_tags, site):
    results = []
    for car_brand_tag in car_brand_tags:
        car_brand_name = ' '.join(car_brand_tag.string.split())
        car_brand_id = car_brand_tag['value']
        brand, created = Brand.objects.get_or_create(name=car_brand_name)
        site_brand = SiteBrand()
        site_brand.site = site
        site_brand.brand = brand
        site_brand.identifier = car_brand_id
        site_brand.save()
        results.append(site_brand)
    return results
def get_car_brands_and_ids(car_brand_tags, site):
    results = []
    for car_brand_tag in car_brand_tags:
        car_brand_name = ' '.join(car_brand_tag.string.split())
        car_brand_id = car_brand_tag['value']
	brand, created = Brand.objects.get_or_create(name=car_brand_name)
        site_brand = SiteBrand()
	site_brand.site = site
	site_brand.brand = brand
	site_brand.identifier = car_brand_id
	site_brand.save()
        results.append(site_brand)
    return results
Beispiel #3
0
def get_car_brands_and_ids(car_brand_tags, site):
    results = []
    for car_brand_tag in car_brand_tags:
        search = re.search('^(.+) \(\d*\)', car_brand_tag.text.encode('utf-8'))
        if search is None:
            continue
        car_brand_string = search.group(1)
        car_brand_name = ' '.join(car_brand_string.split())
        car_brand_id = car_brand_tag['value']
        brand, created = Brand.objects.get_or_create(name=car_brand_name)
        site_brand = SiteBrand()
        site_brand.site = site
        site_brand.brand = brand
        site_brand.identifier = car_brand_id
        site_brand.save()
        results.append(site_brand)
    return results
def get_car_brands_and_ids(car_brand_tags, site):
    results = []
    for car_brand_tag in car_brand_tags:
        search = re.search('^(.+) \(\d*\)', car_brand_tag.text.encode('utf-8'))
        if search is None:
            continue
        car_brand_string = search.group(1)
        car_brand_name = ' '.join(car_brand_string.split())
        car_brand_id = car_brand_tag['value']
	brand, created = Brand.objects.get_or_create(name=car_brand_name)
        site_brand = SiteBrand()
	site_brand.site = site
	site_brand.brand = brand
	site_brand.identifier = car_brand_id
	site_brand.save()
        results.append(site_brand)
    return results