Avoid crash on empty catalog page
This commit is contained in:
		
							parent
							
								
									fdd8b23118
								
							
						
					
					
						commit
						efa06c9e33
					
				| 
						 | 
					@ -154,10 +154,11 @@ def check_catalog(entity, catalog):
 | 
				
			||||||
                return
 | 
					                return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        html = get_catalog_url(catalog_url)
 | 
					        html = get_catalog_url(catalog_url)
 | 
				
			||||||
        description = get_description_from_page(html)
 | 
					        if html:
 | 
				
			||||||
        if description:
 | 
					            description = get_description_from_page(html)
 | 
				
			||||||
            catalog['description'] = description,
 | 
					            if description:
 | 
				
			||||||
            return
 | 
					                catalog['description'] = description
 | 
				
			||||||
 | 
					                return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for property_id in sorted(catalog_ids):
 | 
					    for property_id in sorted(catalog_ids):
 | 
				
			||||||
        if property_id == 'P350':
 | 
					        if property_id == 'P350':
 | 
				
			||||||
| 
						 | 
					@ -208,6 +209,8 @@ def get_catalog_from_artwork(entity):
 | 
				
			||||||
    return catalog
 | 
					    return catalog
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_description_from_page(html):
 | 
					def get_description_from_page(html):
 | 
				
			||||||
 | 
					    if not html:
 | 
				
			||||||
 | 
					        return
 | 
				
			||||||
    root = lxml.html.fromstring(html)
 | 
					    root = lxml.html.fromstring(html)
 | 
				
			||||||
    div = root.find('.//div[@itemprop="description"]')
 | 
					    div = root.find('.//div[@itemprop="description"]')
 | 
				
			||||||
    if div is not None:
 | 
					    if div is not None:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue