ó
¡¼™\c           @  sH   d  Z  d d l m Z m Z d d l Z d d d „  ƒ  YZ d „  Z d S(   sN   
This module adds context manager for temporary files generated by the tests.
iÿÿÿÿ(   t   print_functiont   divisionNt   TmpFileManagerc           B  sY   e  Z d  Z e d ƒ Z e d ƒ Z e d d „ ƒ Z e d d „ ƒ Z e d „  ƒ Z	 RS(   sP   
    A class to track record of every temporary files created by the tests.
    t    c         C  s   |  j  j | ƒ | S(   N(   t	   tmp_filest   add(   t   clst   name(    (    s7   lib/python2.7/site-packages/sympy/utilities/tmpfiles.pyt   tmp_file   s    c         C  s   |  j  j | ƒ | S(   N(   t   tmp_foldersR   (   R   R   (    (    s7   lib/python2.7/site-packages/sympy/utilities/tmpfiles.pyt
   tmp_folder   s    c         C  sq   x> |  j  r@ |  j  j ƒ  } t j j | ƒ r t j | ƒ q q Wx) |  j rl |  j j ƒ  } t j | ƒ qD Wd  S(   N(	   R   t   popt   ost   patht   isfilet   removeR	   t   shutilt   rmtree(   R   t   filet   folder(    (    s7   lib/python2.7/site-packages/sympy/utilities/tmpfiles.pyt   cleanup   s    (
   t   __name__t
   __module__t   __doc__t   setR   R	   t   classmethodR   R
   R   (    (    (    s7   lib/python2.7/site-packages/sympy/utilities/tmpfiles.pyR   	   s   c           s   ‡  f d †  } | S(   sP   
    A decorator to help test codes remove temporary files after the tests.
    c             s   z ˆ  ƒ  Wd  t  j ƒ  Xd  S(   N(   R   R   (    (   t	   test_func(    s7   lib/python2.7/site-packages/sympy/utilities/tmpfiles.pyt   wrapper_function(   s    (    (   R   R   (    (   R   s7   lib/python2.7/site-packages/sympy/utilities/tmpfiles.pyt   cleanup_tmp_files$   s    (    (   R   t
   __future__R    R   R   R   R   (    (    (    s7   lib/python2.7/site-packages/sympy/utilities/tmpfiles.pyt   <module>   s   