3
uûœ]@  ã               @   sD   d dl Z d dlZd dlmZ dd„ Zedd„ ƒZdd„ Zd	d
„ ZdS )é    N)Úcontextmanagerc             C   sH   t jj| ƒ}tjjdƒs"tjdkrD|rDt jj| ƒ\}}|t j|ƒk}|S )aQ  
    Returns if the given path exists and also matches the case on Windows.

    When finding files that can be imported, it is important for the cases to match because while
    file os.path.exists("module.py") and os.path.exists("MODULE.py") both return True on Windows, Python
    can only import using the case of the real file.
    ÚwinÚdarwin)ÚosÚpathÚexistsÚsysÚplatformÚ
startswithÚsplitÚlistdir)r   ÚresultÚ	directoryÚbasename© r   ú,/tmp/pip-build-fn42xldr/isort/isort/utils.pyÚexists_case_sensitive   s
    r   c             c   s.   t jƒ }t j| ƒ z
dV  W dt j|ƒ X dS )zPContext manager for changing dir and restoring previous workdir after exit.
    N)r   ÚgetcwdÚchdir)r   Úcurdirr   r   r   r      s
    

r   c             C   sH   g }x| D ]}||kr
|j |ƒ q
W x|D ]}||kr*|j |ƒ q*W |S )z3 Return a list of items that are in `a` or `b`
    )Úappend)ÚaÚbÚuÚitemr   r   r   Úunion!   s    

r   c             C   s(   g }x| D ]}||kr
|j |ƒ q
W |S )z: Return a list of items from `a` that are not in `b`.
    )r   )r   r   Údr   r   r   r   Ú
difference.   s
    
r   )r   r   Ú
contextlibr   r   r   r   r   r   r   r   r   Ú<module>   s   