3
=Ad]P  ã               @   sH   d Z ddlZddlmZ ddd„Zdd„ Zdd	„ Zdd
d„Zdd„ ZdS )z1 Utility functions for working with Python Eggs. é    N)Útopological_sortc             C   sZ   t j|ƒ}| j|ƒ\}}t|ƒdkr>|r2||ƒ ntd| ƒ‚x|D ]}| j|ƒ qDW dS )z2 Add all eggs found on the path to a working set. r   zCannot find eggs %sN)Úpkg_resourcesÚEnvironmentÚfind_pluginsÚlenÚSystemErrorÚadd)Úworking_setÚpathZon_errorÚenvironmentÚdistributionsÚerrorsÚdistribution© r   ún/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/envisage-4.7.2-py3.6.egg/envisage/egg_utils.pyÚadd_eggs_on_path   s    


r   c             C   sF   t | |ƒ}t| |ƒ}g }x(|D ] }|j|ƒ}|jt|jƒ ƒƒ qW |S )z. Return entry points in Egg dependency order. )Ú"get_distributions_with_entry_pointÚget_distributions_in_egg_orderÚget_entry_mapÚextendÚlistÚvalues)r	   Úentry_point_namer   Úentry_pointsr   Z	entry_mapr   r   r   Úget_entry_points_in_egg_order!   s    


r   c             C   s2   g }x(| D ] }t |j|ƒƒdkr
|j|ƒ q
W |S )zB Return all distributions that contribute to an entry point.

    r   )r   r   Úappend)r	   r   r   r   r   r   r   r   5   s
    
r   c             C   sN   |dkr| }i }x(|D ] }|j |g ƒ}|jt| |ƒƒ qW t|ƒ}|jƒ  |S )z3 Return all distributions in Egg dependency order. N)Ú
setdefaultr   Úget_requiresr   Úreverse)r	   r   Zgraphr   Úarcsr   r   r   r   B   s    
r   c             C   s<   g }x2|j ƒ D ]&}| j|ƒ}|dk	r|j| j|ƒƒ qW |S )zE Return all of the other distributions that a distribution requires. N)ÚrequiresÚfindr   )r	   r   r    ÚrequirementÚrequiredr   r   r   r   V   s    
r   )N)N)	Ú__doc__r   Ztraits.util.toposortr   r   r   r   r   r   r   r   r   r   Ú<module>   s   

