U
    <ºc  ã                   @   sB   d dl mZmZ ddlmZ dgZeeeee f dœdd„ZdS )é    )ÚDictÚListé   )ÚPackagingErrorÚ find_first_use_of_broken_modules)ÚexcÚreturnc                 C   sN   t | tƒstdƒ‚i }dd„ | jj ¡ D ƒ}|D ]}| j |¡}|||< q0|S )aÍ  
    Find all broken modules in a PackagingError, and for each one, return the
    dependency path in which the module was first encountered.

    E.g. broken module m.n.o was added to a dependency graph while processing a.b.c,
    then re-encountered while processing d.e.f. This method would return
    {'m.n.o': ['a', 'b', 'c']}

    Args:
        exc: a PackagingError

    Returns: A dict from broken module names to lists of module names in the path.
    z"exception must be a PackagingErrorc                 S   s    g | ]\}}|  d d¡r|‘qS )ÚerrorF)Úget)Ú.0ÚmÚattr© r   úZ/tmp/pip-unpacked-wheel-gikjz4vx/torch/package/analyze/find_first_use_of_broken_modules.pyÚ
<listcomp>   s     z4find_first_use_of_broken_modules.<locals>.<listcomp>)Ú
isinstancer   ÚAssertionErrorZdependency_graphZnodesÚitemsZ
first_path)r   ZusesZbroken_module_namesÚmodule_nameÚpathr   r   r   r      s    
ÿ
N)Útypingr   r   Zpackage_exporterr   Ú__all__Ústrr   r   r   r   r   Ú<module>   s   