ó
^†êWc           @   s	  d  d l  Z  d  d l Z d  d l Z d  d l Z y d  d l m Z Wn! e k
 rg d  d l m Z n Xd  d l	 Z	 d  d l
 Z
 d  d l Z d  d l Z d  d l Z d  d l m Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z d	 „  Z d
 „  Z d „  Z d S(   iÿÿÿÿN(   t   StringIO(   t   BytesIO(   t   contextmanagerc         c   sV   t  j j |  ƒ } z | t  j |  <d  VWd  | d  k rD t  j |  =n | t  j |  <Xd  S(   N(   t   ost   environt   gett   None(   t   keyt   valuet	   old_value(    (    sl   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_wheelfile.pyR      s    	c          c   s*   t  j ƒ  }  z	 |  VWd  t j |  ƒ Xd  S(   N(   t   tempfilet   mkdtempt   shutilt   rmtree(   t   tempdir(    (    sl   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_wheelfile.pyt   temporary_directory   s    	c         c   s-   t  j |  d ƒ } z	 | VWd  | j ƒ  Xd  S(   Nt   r(   t   zipfilet   ZipFilet   close(   t   patht   zf(    (    sl   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_wheelfile.pyt   readable_zipfile%   s    	c          C   s‹  t  t j d ƒ s" t j d ƒ n  t ƒ  }  t j |  d ƒ } | j d d ƒ | j d d ƒ | j d d	 ƒ | j ƒ  t	 j
 j |  d
 ƒ } | j d t j d ƒ j ƒ  ƒ | j d d ƒ | j d ƒ j ƒ  | j d ƒ j ƒ  y | j d ƒ j ƒ  Wn t	 j
 j k
 rn Xt d ƒ ‚ t | _ y | j d ƒ j ƒ  Wn t	 j
 j k
 rWn Xt d ƒ ‚ | j d d  ƒ | j d ƒ j ƒ  d  S(   Nt   _update_crcs4   No ZIP verification. Missing ZipExtFile._update_crc.t   wt   ones
   first filet   twos   second filet   threes
   third fileR   t   blurbles#   expected exception 'BadWheelFile()'(   t   hasattrR   t
   ZipExtFilet   pytestt   skipR    R   t   writestrR   t   wheelt   installt   VerifyingZipFilet   set_expected_hasht   hashlibt   sha256t   digestt   opent   readt   BadWheelFilet	   Exceptiont   Truet   strictR   (   t   sioR   t   vzf(    (    sl   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_wheelfile.pyt   test_verifying_zipfile/   s4    	
	c          C   sÖ   t  ƒ  }  t j j |  d ƒ } | j d d ƒ | j d d ƒ | j ƒ  y | j ƒ  Wn t k
 ri n Xt d ƒ ‚ t j j |  d ƒ } | j ƒ  | j ƒ  t j j |  d ƒ } t	 | j
 ƒ  ƒ d	 k sÒ t ‚ d  S(
   NR   R   s
   first fileR   s   second files   expected RuntimeErrort   aR   i   (   R    R"   R#   R$   R!   R   t   popt   RuntimeErrorR,   t   lent   infolistt   AssertionError(   R/   R   (    (    sl   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_wheelfile.pyt   test_pop_zipfileV   s    	


c          C   só   t  ƒ  ä }  xU d D]M } t j j |  | ƒ } t j | d d d ƒ } | j | d ƒ Wd  QXq Wt j j |  d ƒ } t d	 d
 ƒ  t j	 j
 | |  ƒ } Wd  QXt | ƒ 7 } x- | j ƒ  D] } | j d  d k sÀ t ‚ qÀ WWd  QXWd  QXd  S(   NR   R   R   R   t   encodings   utf-8s   
t   dummyt   SOURCE_DATE_EPOCHt	   315576060i   i¼  i   (   s   ones   twos   three(   i¼  i   i   (   R   R   R   t   joint   codecsR)   t   writeR   R"   t   archivet   make_wheelfile_innerR   R6   t	   date_timeR7   (   R   t   filenameR   t   fpt   zip_base_namet   zip_filenameR   t   info(    (    sl   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_wheelfile.pyt   test_zipfile_timestampk   s    	c    
      C   s9  t  ƒ  *}  d d f } xk | D]c \ } } t j j |  | ƒ } t j | d d d ƒ } | j | d ƒ Wd  QXt j | | ƒ q Wt j j |  d	 ƒ } t j	 j
 | |  ƒ } t | ƒ q } xg | D]_ \ } } | j t j j |  | ƒ ƒ }	 |	 j | d
 Bd >k st ‚ |	 j t j k sÆ t ‚ qÆ WWd  QXWd  QXd  S(   Nt   fooi¤  t   barií  R   R9   s   utf-8s   
R:   i €  i   (   RI   i¤  (   s   barií  (   R   R   R   R=   R>   R)   R?   t   chmodR"   R@   RA   R   t   getinfot   external_attrR7   t   compress_typeR   t   ZIP_DEFLATED(
   R   t   filesRC   t   modeR   RD   RE   RF   R   RG   (    (    sl   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_wheelfile.pyt   test_zipfile_attributes}   s    	(   R   t   wheel.installR"   t   wheel.archiveR&   R    t   ImportErrort   ioR   R>   R   R   R   R
   t
   contextlibR   R   R   R   R1   R8   RH   RR   (    (    (    sl   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/test/test_wheelfile.pyt   <module>   s(   	
	'		