ó
æNXc           @   sR   d  Z  d d l Z d d l m Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   sX   
Context managers for adding things to sys.path temporarily.

Authors:

* Brian Granger
iÿÿÿÿN(   t   cast_bytes_py2t   appended_to_syspathc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s=   A context for appending a directory to sys.path for a second.c         C   s   t  | t j ƒ  ƒ |  _ d  S(   N(   R    t   syst   getdefaultencodingt   dir(   t   selfR   (    (    sT   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/syspathcontext.pyt   __init__    s    c         C   s>   |  j  t j k r1 t j j |  j  ƒ t |  _ n	 t |  _ d  S(   N(   R   R   t   patht   appendt   Truet   addedt   False(   R   (    (    sT   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/syspathcontext.pyt	   __enter__#   s    c         C   s;   |  j  r7 y t j j |  j ƒ Wq7 t k
 r3 q7 Xn  t S(   N(   R
   R   R   t   removeR   t
   ValueErrorR   (   R   t   typet   valuet	   traceback(    (    sT   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/syspathcontext.pyt   __exit__*   s    	(   t   __name__t
   __module__t   __doc__R   R   R   (    (    (    sT   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/syspathcontext.pyR      s   		t   prepended_to_syspathc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s>   A context for prepending a directory to sys.path for a second.c         C   s   t  | t j ƒ  ƒ |  _ d  S(   N(   R    R   R   R   (   R   R   (    (    sT   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/syspathcontext.pyR   6   s    c         C   sA   |  j  t j k r4 t j j d |  j  ƒ t |  _ n	 t |  _ d  S(   Ni    (   R   R   R   t   insertR	   R
   R   (   R   (    (    sT   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/syspathcontext.pyR   9   s    c         C   s;   |  j  r7 y t j j |  j ƒ Wq7 t k
 r3 q7 Xn  t S(   N(   R
   R   R   R   R   R   R   (   R   R   R   R   (    (    sT   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/syspathcontext.pyR   @   s    	(   R   R   R   R   R   R   (    (    (    sT   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/syspathcontext.pyR   3   s   		(   R   R   t   IPython.utils.py3compatR    t   objectR   R   (    (    (    sT   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/syspathcontext.pyt   <module>   s   