ó
TR¹Nc           @   sx   d  Z  d d l Z d d l Z d d l m Z d	 Z e j d k rb d e f d „  ƒ  YZ e Z n	 e j Z e j	 Z	 d S(
   s©  
The temp module provides a NamedTemporaryFile that can be re-opened on any
platform. Most platforms use the standard Python tempfile.TemporaryFile class,
but MS Windows users are given a custom class.

This is needed because in Windows NT, the default implementation of
NamedTemporaryFile uses the O_TEMPORARY flag, and thus cannot be reopened [1].

1: http://mail.python.org/pipermail/python-list/2005-December/359474.html
iÿÿÿÿN(   t   FileProxyMixint   NamedTemporaryFilet
   gettempdirt   ntt   TemporaryFilec           B   sA   e  Z d  Z d d d d d d „ Z e j Z d „  Z d „  Z RS(   sŠ   
        Temporary file object constructor that works in Windows and supports
        reopening of the temporary file in windows.
        s   w+biÿÿÿÿt    c         C   sR   t  j d | d | d | ƒ \ } } | |  _ t j | | | ƒ |  _ t |  _ d  S(   Nt   suffixt   prefixt   dir(   t   tempfilet   mkstempt   namet   ost   fdopent   filet   Falset   close_called(   t   selft   modet   bufsizeR   R   R   t   fdR   (    (    sC   /home/panlixing/Python_Projects/gaeseries/django/core/files/temp.pyt   __init__   s
    	c         C   sl   |  j  sh t |  _  y |  j j ƒ  Wn t t f k
 r< n Xy |  j |  j ƒ Wqh t k
 rd qh Xn  d  S(   N(   R   t   TrueR   t   closet   OSErrort   IOErrort   unlinkR   (   R   (    (    sC   /home/panlixing/Python_Projects/gaeseries/django/core/files/temp.pyR   %   s    		c         C   s   |  j  ƒ  d  S(   N(   R   (   R   (    (    sC   /home/panlixing/Python_Projects/gaeseries/django/core/files/temp.pyt   __del__1   s    N(	   t   __name__t
   __module__t   __doc__t   NoneR   R   R   R   R   (    (    (    sC   /home/panlixing/Python_Projects/gaeseries/django/core/files/temp.pyR      s   
		(   s   NamedTemporaryFiles
   gettempdir(
   R   R   R	   t   django.core.files.utilsR    t   __all__R   R   R   R   (    (    (    sC   /home/panlixing/Python_Projects/gaeseries/django/core/files/temp.pyt   <module>
   s   !		