ó
~ˆ]c           @   sV   d  d l  Z  d  d l Z d  d l m Z d „  Z e d „  ƒ Z d „  Z d „  Z d S(   iÿÿÿÿN(   t   contextmanagerc         C   sm   t  j j |  ƒ } t j j d ƒ s3 t j d k ri | ri t  j j |  ƒ \ } } | t  j | ƒ k } n  | S(   sQ  
    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.
    t   wint   darwin(   t   ost   patht   existst   syst   platformt
   startswitht   splitt   listdir(   R   t   resultt	   directoryt   basename(    (    s*   lib/python2.7/site-packages/isort/utils.pyt   exists_case_sensitive   s
    'c         c   s7   t  j ƒ  } t  j |  ƒ z	 d VWd t  j | ƒ Xd S(   sP   Context manager for changing dir and restoring previous workdir after exit.
    N(   R   t   getcwdt   chdir(   R   t   curdir(    (    s*   lib/python2.7/site-packages/isort/utils.pyR      s
    	c         C   sd   g  } x* |  D]" } | | k r | j  | ƒ q q Wx* | D]" } | | k r: | j  | ƒ q: q: W| S(   s3    Return a list of items that are in `a` or `b`
    (   t   append(   t   at   bt   ut   item(    (    s*   lib/python2.7/site-packages/isort/utils.pyt   union!   s    c         C   s7   g  } x* |  D]" } | | k r | j  | ƒ q q W| S(   s:    Return a list of items from `a` that are not in `b`.
    (   R   (   R   R   t   dR   (    (    s*   lib/python2.7/site-packages/isort/utils.pyt
   difference.   s
    (   R   R   t
   contextlibR    R   R   R   R   (    (    (    s*   lib/python2.7/site-packages/isort/utils.pyt   <module>   s   		