
    8Qh                     0    d dl Z d dlZd dlZd Zd Zd ZdS )    Nc                   	
 d}i dddddddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(}	 g }t          |d)d*+          5 }t          j        |d,-          }|D ]7

fd.|                                D             }|                    |           8	 d d d            n# 1 swxY w Y   d 	|D ]}|d         | k    r
|d'         	 n	st          d/|             g S 	fd0|D             }|S # t          $ r}t          d1|            g cY d }~S d }~wt          $ r}t          d2|            g cY d }~S d }~ww xY w)3Nz$../files/Products/ProductsOutput.csvzCode article	item_codezCode Famillefamily_codeu   Désignation principalemain_designationActifstatusu
   Catégoriecategoryu   Sous-catégoriessubcategoriesClasseclassz
Code barrebar_codezCode UE articleCode_UEPoidsweightzSous-Famille
sub_familyLongueurlengthGammerangeTaillesizezType 1type_1zType 2type_2zType 3type_3type_4variation_codevariation_nameparent)zType 4zVariation Codeu   Variation DésignatiozProduit Parentr
ISO-8859-1)encoding;	delimiterc                 l    i | ]0\  }}|                     |d           pd                                 1S ) )getstrip).0fr_key
mapped_keyrows      4/var/www/sites/Harken/General/Utils/product_utils.py
<dictcomp>z(get_related_products.<locals>.<dictcomp>(   sN       *
 !4!4!: A A C C      u"   Aucun produit trouvé avec le SKU c                 ,    g | ]}|d          k    |S )r    )r)   product
parent_skus     r-   
<listcomp>z(get_related_products.<locals>.<listcomp>:   s)    ___wx?PT^?^?^G?^?^?^r/   u   Erreur : Fichier non trouvé - z	Erreur : )opencsv
DictReaderitemsappendprintFileNotFoundError	Exception)skuFILE_PATH_CSVmappingproductscsv_filereaderr2   related_productser3   r,   s            @@r-   get_related_productsrE      s   :M 	"#5 		
 	j 	O 	' 	j 	9 	 	 	H 	 	& 	(  	(!" 	(#$ *!1"+  G0!-|<<< 	)^H<<<F ) )   .5mmoo   (((()	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 
 	 	G{#s**$X.
 +  	<s<<===I `___8___   333444						   o!oo						s[   D AB4(D 4B88D ;B8<5D 2D 
ED%E%E2EEEc                 &   d}t           j                            |          st          d| d          	 t	          |dd          5 }t          j        |d          }t          |          }|D ]c}t          |          d	k     r|d
         	                                | k    r/|d         	                                }|rd| c cd d d            S d	 d d d            d S # 1 swxY w Y   d S # t          $ r}t          d|           d }~ww xY w)Nz.../../Harken/files/Products/ProductsOutput.csvzLe fichier CSV 'z' est introuvable.r   r    )moder!   r"   r#      r      z%https://api.huggii.com/Harken/images/z+Erreur lors de la lecture du fichier CSV : )ospathexistsr;   r5   r6   rB   nextlenr(   r<   )r=   	file_pathfile
csv_readerheadersr,   
image_namerD   s           r-   get_image_linkrT   G   s   @I7>>)$$ R P9 P P PQQQK)#=== 	DC888J:&&G! 	T 	Ts88a<< q6<<>>S((!$QJ! TSzSSSS	 	 	 	 	 	 	 	  !	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	$  K K KIaIIJJJKsH   C/ A>C"C/ C"C/ "C&&C/ )C&*C/ /
D9DDc           	          | D ]M}|d         dk    r?|d         |k    r3t          |d          d|d          d|d                     |d         c S Nd S )Nr   GENERAL   z	 ------- z -------rI   )r:   )pricesr=   prices      r-   get_product_pricerZ   d   so      8y  U1X__U1XDDaDD%(DDEEE8OOO4r/   )r6   jsonrJ   rE   rT   rZ   r1   r/   r-   <module>r\      s[    



  				
; ; ;~K K K:    r/   