o
    i                     @   sz   d dl mZ d dlZd dlmZ d dlZddeeeef  deeef fddZ	deee
e f deeef fd	d
ZdS )    )defaultdictN)Optionalspecial_casesreturnc                 C   s   t d}tt}t|ddd}t|}W d    n1 s w   Y  |d }t|D ]*\}}|d	 }|d}	|	d u rEt }
nt
|	trStdd	 |	D }
|
||< q-|  D ]\}}|| | q\|S )
Nz2ddtrace/contrib/integration_registry/registry.yamlrzutf-8)encodingintegrationsintegration_namedependency_namesc                 s   s    | ]}|  V  qd S N)lower).0dependency_name r   ^/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/contrib/integration_registry/utils.py	<genexpr>   s    z4get_integration_to_dependency_map.<locals>.<genexpr>)pathlibPathr   setopenyaml	safe_load	enumerategetr   
isinstancelistitemsadd)r   REGISTRY_YAML_PATHdependency_mapfregistry_contentintegrations_listindexentryr	   r
   valid_dependency_names
dependencyintegrationr   r   r   !get_integration_to_dependency_map   s"   



r(   integration_to_depsc                 C   s4   i }|   D ]\}}|D ]
}| || < qq|S r   )r   r   )r)   dependency_to_integration_mapr'   dependency_listr&   r   r   r   $invert_integration_to_dependency_map"   s   r,   r   )collectionsr   r   typingr   r   dictstrr   r(   r   r,   r   r   r   r   <module>   s    (*