
Ebc           @   s;  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m	 Z	 e
 Z e j d k r(y d d l Z d Z d Z e j j j Z d   Z e j j j Z e j j j Z e j j j Z e j j j Z e Z d	   Z Wn# e  k
 rd
   Z d   Z n Xd   Z! n e j! Z! e Z d S(   sm  
    werkzeug.posixemulation
    ~~~~~~~~~~~~~~~~~~~~~~~

    Provides a POSIX emulation for some features that are relevant to
    web applications.  The main purpose is to simplify support for
    systems such as Windows NT that are not 100% POSIX compatible.

    Currently this only implements a :func:`rename` function that
    follows POSIX semantics.  Eg: if the target file already exists it
    will be replaced without asking.

    This module was introduced in 0.6.1 and is not a public interface.
    It might become one in later versions of Werkzeug.

    :copyright: 2007 Pallets
    :license: BSD-3-Clause
iNi   (   t
   to_unicode(   t   get_filesystem_encodingt   nti   c         C   s   t  |  t    }  t  | t    } t |  |  r7 t Sd } t } xM | r | d k  r t |  | t t B } | sF t j	 d  | d 7} qF qF W| S(   Ni    id   gMbP?i   (
   R    R   t   _rename_atomict   Truet   Falset   _MoveFileExt   _MOVEFILE_REPLACE_EXISTINGt   _MOVEFILE_WRITE_THROUGHt   timet   sleep(   t   srct   dstt   retryt   rv(    (    so   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/posixemulation.pyt   _rename'   s    c         C   s   t  d  d d d d d d  } | d k r. t Szz d } t } xc | r | d k  r t |  | d  d  t t B|  } | r t |  } Pq@ t j d  | d 7} q@ W| SWd  t	 |  Xd  S(   Ni    i  s   Werkzeug renameiid   gMbP?i   (
   t   _CreateTransactiont   NoneR   t   _MoveFileTransactedR   R   t   _CommitTransactionR	   R
   t   _CloseHandle(   R   R   t   taR   R   (    (    so   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/posixemulation.pyR   >   s*    	c         C   s   t  S(   N(   R   (   R   R   (    (    so   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/posixemulation.pyR   Z   s    c         C   s   t  S(   N(   R   (   R   R   (    (    so   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/posixemulation.pyR   ]   s    c         C   s   t  |  |  r d  Sy t j |  |  Wn t k
 r } | j t j k rQ   n  d | t j d t j	  f } t j | |  t j |  |  y t j
 |  Wq t k
 r q Xn Xd  S(   Ns   %s-%08xi    (   R   t   ost   renamet   OSErrort   errnot   EEXISTt   randomt   randintt   syst   maxsizet   unlinkt	   Exception(   R   R   t   et   old(    (    so   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/posixemulation.pyR   `   s    ("   t   __doc__R   R   R   R   R	   t   _compatR    t
   filesystemR   R   t   can_rename_open_filet   namet   ctypesR   R   t   windllt   kernel32t   MoveFileExWR   R   t   ktmw32t   CreateTransactionR   t   CommitTransactionR   t   MoveFileTransactedWR   t   CloseHandleR   R   R   R    R   (    (    (    so   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/werkzeug/posixemulation.pyt   <module>   s6   			