Ñò
ïžòKc           @   sŠ  d  Z  d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z y d d k	 Z	 e	 i
 Z
 Wn" e j
 o e Z	 e i
 Z
 n Xd d d d d d d	 d
 d g	 Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ e Z d d >d Z d d >Z d d >d Z d Z d Z d Z d Z e i e ƒ Z d Z d Z d Z d Z d Z d Z  d Z! d Z" d Z# d Z$ d Z% d Z& e i e% ƒ Z' d Z( d Z) d Z* d Z+ d Z, d Z- d Z. d Z/ d Z0 d Z1 d Z2 d Z3 d  Z4 d! Z5 d" Z6 d# Z7 d Z8 d$ Z9 d% Z: d& Z; d' Z< e i e; ƒ Z= d Z> d Z? d Z@ d ZA d ZB d ZC d ZD d ZE d ZF d ZG d ZH d ZI d( ZJ d) ZK e i eJ ƒ ZL d* ZM d+ ZN e i eM ƒ ZO d ZP d ZQ d ZR d ZS d ZT d ZU d ZV d ZW d ZX d ZY d, „  ZZ d- „  Z[ d. „  Z\ d e] f d/ „  ƒ  YZ^ d0 f  d1 „  ƒ  YZ_ d2 f  d3 „  ƒ  YZ` d	 f  d4 „  ƒ  YZa d
 ea f d5 „  ƒ  YZb e d6 „ Zc ed d7 j o ec ƒ  n d S(8   s   
Read and write ZIP files.
iÿÿÿÿNt
   BadZipfilet   errort
   ZIP_STOREDt   ZIP_DEFLATEDt
   is_zipfilet   ZipInfot   ZipFilet	   PyZipFilet   LargeZipFilec           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s   scripts/common/Lib/zipfile.pyR       s   c           B   s   e  Z d  Z RS(   su   
    Raised when writing a zipfile, the zipfile requires ZIP64 extensions
    and those extensions are disabled.
    (   R	   R
   t   __doc__(    (    (    s   scripts/common/Lib/zipfile.pyR      s   i   i   i   i    i   s   <4s4H2LHs   PKi   i   i   i   i   i   i	   s   <4s4B4HL2L5H2Ls   PKi
   i   i   i   i   i   i   i   s   <4s2B4HL2L2Hs   PKs   <4sLQLs   PKs
   <4sQ2H2L4Qs   PKc         C   sO   y5 t  |  d ƒ } t | ƒ } | i ƒ  | o t SWn t j
 o n Xt S(   s?   Quickly see if file is a ZIP file by checking the magic number.t   rb(   t   opent   _EndRecDatat   closet   Truet   IOErrort   False(   t   filenamet   fpint   endrec(    (    s   scripts/common/Lib/zipfile.pyR   ƒ   s    
	c      
   C   s0  |  i  | t d ƒ |  i t ƒ } t i t | ƒ \ } } } } | t j o | S| d j p | d j o t d ƒ ‚ n |  i  | t t d ƒ |  i t ƒ } t i t	 | ƒ \
 } } }	 }
 } } } } } } | t
 j o | S| | t <| | t <| | t <| | t <| | t <| | t <| | t <| S(   sM   
    Read the ZIP64 end-of-archive records and use that to update endrec
    i   i    i   s3   zipfiles that span multiple disks are not supported(   t   seekt   sizeEndCentDir64Locatort   readt   structt   unpackt   structEndArchive64Locatort   stringEndArchive64LocatorR    t   sizeEndCentDir64t   structEndArchive64t   stringEndArchive64t   _ECD_SIGNATUREt   _ECD_DISK_NUMBERt   _ECD_DISK_STARTt   _ECD_ENTRIES_THIS_DISKt   _ECD_ENTRIES_TOTALt	   _ECD_SIZEt   _ECD_OFFSET(   R   t   offsetR   t   datat   sigt   disknot   relofft   diskst   szt   create_versiont   read_versiont   disk_numt   disk_dirt   dircountt	   dircount2t   dirsizet	   diroffset(    (    s   scripts/common/Lib/zipfile.pyt   _EndRecData64�   s(    0






c         C   sˆ  |  i  d d ƒ |  i ƒ  } |  i  t d ƒ |  i ƒ  } | d d !t j o_ | d d j oN t i t | ƒ } t | ƒ } | i	 d ƒ | i	 | t ƒ t
 |  t | ƒ St | d
 t d ƒ } |  i  | d ƒ |  i ƒ  } | i t ƒ } | d j o‰ | | | t !} t t i t | ƒ ƒ } | | t } | t t | ƒ j o7 | i	 | ƒ | i	 | | ƒ t
 |  | | | | ƒ Sn d	 S(   sÔ   Return data from the "End of Central Directory" record, or None.

    The data is a list of the nine items in the ZIP "End of central dir"
    record followed by a tenth item, the file seek offset of this record.i    i   i   iþÿÿÿt     t    i   i   Ni   (   R   t   tellt   sizeEndCentDirR   t   stringEndArchiveR   R   t   structEndArchivet   listt   appendR6   t   maxt   rfindt   _ECD_COMMENT_SIZEt   len(   R   t   filesizeR(   R   t   maxCommentStartt   startt   recDatat   comment(    (    s   scripts/common/Lib/zipfile.pyR   °   s0    %c           B   sG   e  Z d  Z d Z d d d „ Z d „  Z d „  Z d „  Z d „  Z RS(   s>   Class with attributes describing each file in the ZIP archive.t   orig_filenameR   t	   date_timet   compress_typeRG   t   extrat   create_systemR.   t   extract_versiont   reservedt	   flag_bitst   volumet   internal_attrt   external_attrt   header_offsett   CRCt   compress_sizet	   file_sizet	   _raw_timet   NoNamei¼  i   i    c         C   s  | |  _  | i t d ƒ ƒ } | d j o | d | !} n t i d j o) t i | j o | i t i d ƒ } n | |  _ | |  _ t |  _	 d |  _
 d |  _ t i d j o d |  _ n
 d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d  S(   Ni    t   /R8   t   win32i   i   (   RH   t   findt   chrt   ost   sept   replaceR   RI   R   RJ   RG   RK   t   syst   platformRL   R.   RM   RN   RO   RP   RQ   RR   (   t   selfR   RI   t	   null_byte(    (    s   scripts/common/Lib/zipfile.pyt   __init__   s*    	 												c         C   s…  |  i  } | d d d >| d d >B| d B} | d d >| d	 d >B| d d B} |  i d
 @o d } } } n |  i } |  i } |  i } |  i } | t j p | t j ol d } | t i | d t i	 | ƒ d	 | | ƒ } d } d } t
 d |  i ƒ |  _ t
 d |  i ƒ |  _ n |  i ƒ  \ }	 }
 t i t t |  i |  i |
 |  i | | | | | t |	 ƒ t | ƒ ƒ } | |	 | S(   s'   Return the per-file header as a string.i    i¼  i	   i   i   i   i   i   i   i   s   <HHQQl   ÿÿ i-   (   RI   RO   RT   RU   RV   RK   t   ZIP64_LIMITR   t   packt   calcsizeR?   RM   R.   t   _encodeFilenameFlagst   structFileHeadert   stringFileHeaderRN   RJ   RB   (   Rb   t   dtt   dosdatet   dostimeRT   RU   RV   RK   t   fmtR   RO   t   header(    (    s   scripts/common/Lib/zipfile.pyt
   FileHeader&  s0    	&&				 c         C   sx   t  |  i t ƒ oQ y |  i i d ƒ |  i f SWqt t j
 o! |  i i d ƒ |  i d Bf SXn |  i |  i f Sd  S(   Nt   asciis   utf-8i   (   t
   isinstanceR   t   unicodet   encodeRO   t   UnicodeEncodeError(   Rb   (    (    s   scripts/common/Lib/zipfile.pyRh   H  s    #c         C   s*   |  i  d @o |  i i d ƒ S|  i Sd  S(   Ni   s   utf-8(   RO   R   t   decode(   Rb   (    (    s   scripts/common/Lib/zipfile.pyt   _decodeFilenameQ  s    c         C   s‰  |  i  } t i } xp| oh| d | d  ƒ \ } } | d j o0| d j o | d | d d !ƒ } nv | d j o | d | d d	 !ƒ } nO | d
 j o | d | d d !ƒ } n( | d j o
 d } n t d | f ‚ d } |  i d j o | | |  _ | d 7} n |  i d j o | | |  _ | d 7} n |  i d j o$ |  i } | | |  _ | d 7} qrn | | d } q Wd  S(   Ns   <HHi   i   i   s   <QQQi   i   s   <QQi   i   s   <Qi   i    s   Corrupt extra field %sl   ÿÿÿÿ l   ÿÿ (    (   l   ÿÿÿÿ l   ÿÿ (   RK   R   R   t   RuntimeErrorRV   RU   RS   (   Rb   RK   R   t   tpt   lnt   countst   idxt   old(    (    s   scripts/common/Lib/zipfile.pyt   _decodeExtraW  s6    		 
	(   s   orig_filenames   filenames	   date_times   compress_types   comments   extras   create_systems   create_versions   extract_versions   reserveds	   flag_bitss   volumes   internal_attrs   external_attrs   header_offsets   CRCs   compress_sizes	   file_sizes	   _raw_time(   i¼  i   i   i    i    i    (	   R	   R
   R   t	   __slots__Rd   Rp   Rh   Rw   R~   (    (    (    s   scripts/common/Lib/zipfile.pyR   ç   s2                     &	"			t   _ZipDecrypterc           B   sD   e  Z d  Z d „  Z e ƒ  Z d „  Z d „  Z d „  Z d „  Z RS(   s  Class to handle decryption of files stored within a ZIP archive.

    ZIP supports a password-based form of encryption. Even though known
    plaintext attacks have been found against it, it is still useful
    to be able to get data out of such a file.

    Usage:
        zd = _ZipDecrypter(mypwd)
        plain_char = zd(cypher_char)
        plain_text = map(zd, cypher_text)
    c          C   s„   d }  d g d } xj t  d ƒ D]\ } | } xC t  d ƒ D]5 } | d @o | d ?d @|  A} q9 | d ?d @} q9 W| | | <q  W| S(   sâ   Generate a CRC-32 table.

        ZIP encryption uses the CRC32 one-byte primitive for scrambling some
        internal keys. We noticed that a direct implementation is faster than
        relying on binascii.crc32().
        l    q[ i    i   i   i   iÿÿÿ(   t   range(   t   polyt   tablet   it   crct   j(    (    s   scripts/common/Lib/zipfile.pyt   _GenerateCRCTable‰  s      c         C   s%   | d ?d @|  i  | t | ƒ Ad @AS(   s(   Compute the CRC32 primitive on one byte.i   iÿÿÿ iÿ   (   t   crctablet   ord(   Rb   t   chR…   (    (    s   scripts/common/Lib/zipfile.pyt   _crc32�  s    c         C   s=   d |  _  d |  _ d |  _ x | D] } |  i | ƒ q" Wd  S(   NixV4i‰gE#i�xV4(   t   key0t   key1t   key2t   _UpdateKeys(   Rb   t   pwdt   p(    (    s   scripts/common/Lib/zipfile.pyRd   ¡  s    			 c         C   sx   |  i  | |  i ƒ |  _ |  i |  i d @d @|  _ |  i d d d @|  _ |  i  t |  i d ?d @ƒ |  i ƒ |  _ d  S(   Niÿ   l   ÿÿ i„i   i   (   R‹   RŒ   R�   R\   RŽ   (   Rb   t   c(    (    s   scripts/common/Lib/zipfile.pyR�   ¨  s    c         C   sP   t  | ƒ } |  i d B} | | | d Ad ?d @A} t | ƒ } |  i | ƒ | S(   s   Decrypt a single character.i   i   i   iÿ   (   R‰   RŽ   R\   R�   (   Rb   R’   t   k(    (    s   scripts/common/Lib/zipfile.pyt   __call__®  s    (	   R	   R
   R   R‡   Rˆ   R‹   Rd   R�   R”   (    (    (    s   scripts/common/Lib/zipfile.pyR€   |  s   					t
   ZipExtFilec           B   sk   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d d „ Z
 d d	 „ Z d d
 „ Z RS(   sZ   File-like object for reading an archive member.
       Is returned by ZipFile.open().
    c         C   sÃ   | |  _  | |  _ d |  _ d |  _ d |  _ d |  _ t |  _ t |  _ d |  _	 d |  _
 | i |  _ | i |  _ t |  _ d |  _ | i |  _ d	 |  _ |  i t j o t i d ƒ |  _ n d  S(
   Nl    R8   s   
t   ri@   i   iñÿÿÿ(   s   
i   (   t   fileobjt	   decryptert
   bytes_readt	   rawbuffert
   readbuffert
   linebufferR   t   eoft   univ_newlinest   nlSepst   lastdiscardRJ   RU   t   closedt   modeR   t   namet   compreadsizeR   t   zlibt   decompressobjt   dc(   Rb   R—   t   zipinfot   decrypt(    (    s   scripts/common/Lib/zipfile.pyRd   ¼  s$    													c         C   s-   | |  _  d |  _ |  i  o d |  _ n d  S(   Ns   
s   
s   (   s   
(   s   
s   s   
(   Rž   RŸ   (   Rb   Rž   (    (    s   scripts/common/Lib/zipfile.pyt   set_univ_newlinesÔ  s    		
c         C   s   |  S(   N(    (   Rb   (    (    s   scripts/common/Lib/zipfile.pyt   __iter__Ü  s    c         C   s$   |  i  ƒ  } | p t ƒ  ‚ n | S(   N(   t   readlinet   StopIteration(   Rb   t   nextline(    (    s   scripts/common/Lib/zipfile.pyt   nextß  s    c         C   s   t  |  _ d  S(   N(   R   R¡   (   Rb   (    (    s   scripts/common/Lib/zipfile.pyR   æ  s    c         C   sŸ   d \ } } |  i  o |  i |  i  d f d j o |  i  d |  _  n xK |  i D]< } |  i  i | ƒ } | d j o t | ƒ } | | f SqQ Wn | | f S(   Niÿÿÿÿi    s   s   
i   (   iÿÿÿÿiÿÿÿÿ(   s   s   
(   Rœ   R    RŸ   R[   RB   (   Rb   t   nlt   nllenR^   (    (    s   scripts/common/Lib/zipfile.pyt   _checkfornewlineé  s    

 iÿÿÿÿc         C   sL  | d j  o t  i } n | d j o d S|  i ƒ  \ } } | d j o t | | ƒ } n¯ | t |  i ƒ 8} xt | d j  of | d j oY |  i t | d ƒ ƒ } | p Pn |  i | 7_ | t | ƒ 8} |  i ƒ  \ } } qt W| d j  o |  i } d |  _ | S|  i |  } |  i | | | !|  _ |  i | | |  _ | d S(   sZ   Read a line with approx. size. If size is negative,
           read a whole line.
        i    R8   id   s   
(   R`   t   maxintR²   t   minRB   Rœ   R   R    (   Rb   t   sizeR°   R±   t   buft   s(    (    s   scripts/common/Lib/zipfile.pyR¬   ú  s0     		c         C   s>   g  } x1 t  o) |  i ƒ  } | p Pn | i | ƒ q	 W| S(   st   Return a list with all (following) lines. The sizehint parameter
        is ignored in this implementation.
        (   R   R¬   R>   (   Rb   t   sizehintt   resultt   line(    (    s   scripts/common/Lib/zipfile.pyt	   readlines&  s      c         C   sš  | d j o d S|  i  |  i } |  i d  j	 o | d 8} n | d  j	 o  | d j o“ |  i t j o& t |  i ƒ } t | | | ƒ } qí |  i t	 j oI t |  i ƒ | j o
 d } qé t |  i
 ƒ } t | |  i | ƒ } qí n | |  i |  i  j o |  i  |  i } n | d j o|  i i | ƒ } |  i t | ƒ 7_ |  i
 | 7_
 |  i
 o× |  i
 } d |  _
 | o/ |  i d  j	 o d i t |  i | ƒ ƒ } n | ou |  i t	 j oe |  i i | ƒ } |  i i |  _
 |  i o6 t |  i
 ƒ d j o  | |  i i ƒ  7} d  |  _ q)n |  i | 7_ q@n | d  j p t |  i ƒ | j o |  i } d |  _ n |  i |  } |  i | |  _ | S(   Ni    R8   i   (   RU   R™   R˜   t   NoneRJ   R   RB   R›   R´   R   Rš   R¤   R—   R   t   joint   mapR§   t
   decompresst   unconsumed_tailR�   t   flush(   Rb   Rµ   t   bytesToReadt   lrt   bytest   newdata(    (    s   scripts/common/Lib/zipfile.pyR   1  sL    

		 #	N(   R	   R
   R   R¼   Rd   Rª   R«   R¯   R   R²   R¬   R»   R   (    (    (    s   scripts/common/Lib/zipfile.pyR•   ·  s   					,c           B   sæ   e  Z d  Z d Z d e e d „ Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d d „ Z d d d „ Z d d d „ Z d d d d „ Z d „  Z d „  Z d d d „ Z d „  Z d „  Z d „  Z RS(   sd   Class with methods to open, read, write, close, list zip files.

    z = ZipFile(file, mode="r", compression=ZIP_STORED, allowZip64=False)

    file: Either the path to the file, or a file-like object.
          If it is a path, the file will be opened and closed by ZipFile.
    mode: The mode can be either read "r", write "w" or append "a".
    compression: ZIP_STORED (no compression) or ZIP_DEFLATED (requires zlib).
    allowZip64: if True ZipFile will create files with ZIP64 extensions when
                needed, otherwise it will raise an exception when this would
                be necessary.

    R–   c      	   C   sH  | d j o t  d ƒ ‚ n | t j o n/ | t j o t p t  d ‚ q\ n
 t  d ‚ | |  _ t |  _ d |  _ h  |  _ g  |  _	 | |  _
 | i d d	 ƒ d |  _ } d |  _ d	 |  _ t | t ƒ o• d |  _ | |  _ h d
 d 6d d 6d d 6} y t | | | ƒ |  _ Wq�t j
 o; | d j o$ d } } t | | | ƒ |  _ qb‚  q�Xn( d |  _ | |  _ t | d d ƒ |  _ | d j o |  i ƒ  n� | d j o nŒ | d j oQ y$ |  i ƒ  |  i i |  i d ƒ WqDt j
 o |  i i d d ƒ qDXn. |  i p |  i i ƒ  d |  _ n t  d ‚ d S(   s>   Open the ZIP file with mode read "r", write "w" or append "a".R–   t   wt   as(   ZipFile() requires mode "r", "w", or "a"s.   Compression requires the (missing) zlib modules(   That compression method is not supportedi    t   bR8   R   t   wbs   r+bi   R£   i   s   Mode must be "r", "w" or "a"N(   R–   RÆ   RÇ   (   Rx   R   R   R¥   t   _allowZip64R   t
   _didModifyt   debugt
   NameToInfot   filelistt   compressionR_   R¢   R¼   R�   RG   Rr   t
   basestringt   _filePassedR   R   t   fpR   t   getattrt   _GetContentst   _RealGetContentsR   t	   start_dirR    R   (   Rb   t   fileR¢   RÏ   t
   allowZip64t   keyt   modeDict(    (    s   scripts/common/Lib/zipfile.pyRd   Š  s\    											
		

c         C   sO   y |  i  ƒ  Wn: t j
 o. |  i p |  i i ƒ  d |  _ n ‚  n Xd S(   sO   Read the directory, making sure we close the file if the format
        is bad.N(   RÕ   R    RÑ   RÒ   R   R¼   (   Rb   (    (    s   scripts/common/Lib/zipfile.pyRÔ   Å  s    
c         C   s  |  i  } t | ƒ } | p t d ‚ n |  i d j o	 | GHn | t } | t } | t |  _ | t | | } | t	 t
 j o | t t 8} n |  i d j o | | } d G| G| G| GHn | | |  _ | i |  i d ƒ | i | ƒ } t i | ƒ } d } x| | j  oó| i t ƒ }	 |	 d d !t j o t d ‚ n t i t |	 ƒ }	 |  i d j o	 |	 GHn | i |	 t ƒ }
 t |
 ƒ } | i |	 t ƒ | _ | i |	 t ƒ | _ |	 t | _ |	 d d !\ | _ | _ | _  | _! | _" | _# } } | _$ | _% | _& |	 d	 d
 !\ | _' | _( | _) | | _* | d ?d | d ?d	 @| d @| d ?| d ?d @| d @d f | _+ | i, ƒ  | i | | _ | i- ƒ  | _. |  i/ i0 | ƒ | |  i1 | i. <| t |	 t |	 t |	 t } |  i d j o d G| GHqqWd S(   s/   Read in the table of contents for the ZIP file.s   File is not a zip filei   i   s   given, inferred, offseti    i   s&   Bad magic number for central directoryi   i   i   i	   i¼  i   i   i   i?   t   totalN(2   RÒ   R   R    RÌ   R%   R&   t   _ECD_COMMENTRG   t   _ECD_LOCATIONR    R   R   R   RÖ   R   R   t	   cStringIOt   StringIOt   sizeCentralDirt   stringCentralDirR   R   t   structCentralDirt   _CD_FILENAME_LENGTHR   t   _CD_EXTRA_FIELD_LENGTHRK   t   _CD_COMMENT_LENGTHt   _CD_LOCAL_HEADER_OFFSETRS   R.   RL   RM   RN   RO   RJ   RT   RU   RV   RP   RQ   RR   RW   RI   R~   Rw   R   RÎ   R>   RÍ   (   Rb   RÒ   R   t   size_cdt	   offset_cdt   concatt   inferredR(   RÛ   t   centdirR   t   xt   tt   d(    (    s   scripts/common/Lib/zipfile.pyRÕ   Ð  s\    		


 	I	&
"c         C   s.   g  } x! |  i  D] } | i | i ƒ q W| S(   s+   Return a list of file names in the archive.(   RÎ   R>   R   (   Rb   t   lR(   (    (    s   scripts/common/Lib/zipfile.pyt   namelist  s
    
 c         C   s   |  i  S(   sJ   Return a list of class ZipInfo instances for files in the
        archive.(   RÎ   (   Rb   (    (    s   scripts/common/Lib/zipfile.pyt   infolist  s    c         C   sJ   d d	 GHx: |  i  D]/ } d | i d  } d | i | | i f GHq Wd S(
   s+   Print a table of contents for the zip file.s   %-46s %19s %12ss	   File Names   Modified    t   Sizes   %d-%02d-%02d %02d:%02d:%02di   s   %-46s %s %12dN(   s	   File Names   Modified    Rò   (   RÎ   RI   R   RV   (   Rb   t   zinfot   date(    (    s   scripts/common/Lib/zipfile.pyt   printdir  s
    	
 c         C   si   d } x\ |  i  D]Q } y1 |  i | i d ƒ } x | i | ƒ o q1 WWq t j
 o | i SXq Wd S(   s%   Read all the files and check the CRC.i   i   R–   Ni   (   RÎ   R   R   R   R    (   Rb   t
   chunk_sizeRó   t   f(    (    s   scripts/common/Lib/zipfile.pyt   testzip#  s    
  	c         C   s7   |  i  i | ƒ } | d j o t d | ƒ ‚ n | S(   s,   Return the instance of ZipInfo given 'name'.s(   There is no item named %r in the archiveN(   RÍ   t   getR¼   t   KeyError(   Rb   R£   t   info(    (    s   scripts/common/Lib/zipfile.pyt   getinfo0  s
    c         C   s   | |  _  d S(   s)   Set default password for encrypted files.N(   R�   (   Rb   R�   (    (    s   scripts/common/Lib/zipfile.pyt   setpassword9  s    c         C   s   |  i  | d | ƒ i ƒ  S(   s)   Return file bytes (as a string) for name.R–   (   R   R   (   Rb   R£   R�   (    (    s   scripts/common/Lib/zipfile.pyR   =  s    c         C   sb  | d j o t  d ‚ n |  i p t  d ‚ n |  i o |  i } n t |  i d ƒ } t | t ƒ o
 | } n |  i | ƒ } | i | i	 d ƒ | i
 t ƒ } | d d !t j o t d	 ‚ n t i t | ƒ } | i
 | t ƒ } | t o | i
 | t ƒ n | | i j o t d
 | i | f ‚ n | i d @} d }	 | o¿ | p |  i } n | p t  d | ‚ n t | ƒ }	 | i
 d ƒ }
 t |	 |
 d d !ƒ } | i d @o | i d ?d @} n | i d ?d @} t | d ƒ | j o t  d | ƒ ‚ qn |	 d j o t | | ƒ } n t | | |	 ƒ } d | j o | i t ƒ n | S(   s#   Return file-like object for 'name'.R–   t   Ut   rUs&   open() requires mode "r", "U", or "rU"s3   Attempt to read ZIP archive that was already closedR   i    i   s    Bad magic number for file headers3   File name in directory "%s" and header "%s" differ.i   s6   File %s is encrypted, password required for extractioni   i   iÿ   i   i   s   Bad password for file(   R–   Rþ   s   rUN(   Rx   RÒ   RÑ   R   R   Rr   R   Rü   R   RS   R   t   sizeFileHeaderRj   R    R   R   Ri   t   _FH_FILENAME_LENGTHt   _FH_EXTRA_FIELD_LENGTHRH   RO   R¼   R�   R€   R¾   RW   RT   R‰   R•   Rª   R   (   Rb   R£   R¢   R�   t   zef_fileRó   t   fheadert   fnamet   is_encryptedt   zdRÄ   t   ht
   check_bytet   zef(    (    s   scripts/common/Lib/zipfile.pyR   A  sZ    



c         C   sS   t  | t ƒ p |  i | ƒ } n | d j o t i ƒ  } n |  i | | | ƒ S(   s#  Extract a member from the archive to the current working directory,
           using its full name. Its file information is extracted as accurately
           as possible. `member' may be a filename or a ZipInfo object. You can
           specify a different directory using `path'.
        N(   Rr   R   Rü   R¼   R]   t   getcwdt   _extract_member(   Rb   t   membert   pathR�   (    (    s   scripts/common/Lib/zipfile.pyt   extract�  s
    c         C   sE   | d j o |  i ƒ  } n x! | D] } |  i | | | ƒ q$ Wd S(   sõ   Extract all members from the archive to the current working
           directory. `path' specifies a different directory to extract to.
           `members' is optional and must be a subset of the list returned
           by namelist().
        N(   R¼   Rð   R  (   Rb   R  t   membersR�   R¨   (    (    s   scripts/common/Lib/zipfile.pyt
   extractall�  s
     c         C   sy  | d t  i i t  i i f j o1 t t  i i | ƒ d ƒ d j o | d  } n | i d d j o  t  i i | | i d ƒ } n t  i i | | i ƒ } t  i i | ƒ } t  i i	 | ƒ } | o% t  i i
 | ƒ o t  i | ƒ n | i d d j o) t  i i | ƒ p t  i | ƒ n | S|  i | d | ƒ} t | d ƒ } t i | | ƒ | i ƒ  | i ƒ  | S(   sb   Extract the ZipInfo object 'member' to a physical
           file on the path targetpath.
        iÿÿÿÿi   i    RY   R�   RÉ   (   R]   R  R^   t   altsepRB   t
   splitdriveR   R½   t   normpatht   dirnamet   existst   makedirst   isdirt   mkdirR   R×   t   shutilt   copyfileobjR   (   Rb   R  t
   targetpathR�   t	   upperdirst   sourcet   target(    (    s   scripts/common/Lib/zipfile.pyR  ©  s(    ## 

c         C   s  | i  |  i j o |  i o d G| i  GHq1 n |  i d j o t d ‚ n |  i p t d ‚ n | i t j o t o t d ‚ n | i t	 t f j o t d ‚ n | i
 t j o |  i p t d ƒ ‚ qÛ n | i t j o |  i p t d	 ƒ ‚ q	n d
 S(   s6   Check for errors before writing a file to the archive.s   Duplicate name:RÆ   RÇ   s    write() requires mode "w" or "a"s4   Attempt to write ZIP archive that was already closeds.   Compression requires the (missing) zlib modules(   That compression method is not supporteds'   Filesize would require ZIP64 extensionss+   Zipfile size would require ZIP64 extensionsN(   RÆ   RÇ   (   R   RÍ   RÌ   R¢   Rx   RÒ   RJ   R   R¥   R   RV   Re   RÊ   R   RS   (   Rb   Ró   (    (    s   scripts/common/Lib/zipfile.pyt   _writecheckÎ  s(    






c         C   sª  |  i  p t d ƒ ‚ n t i | ƒ } t i | i ƒ } t i | i ƒ } | d d !} | d j o
 | } n t i
 i t i
 i | ƒ d ƒ } x, | d t i t i f j o | d } q– W| o | d 7} n t | | ƒ } | d d @d >| _ | d j o |  i | _ n
 | | _ | i | _ d | _ |  i  i ƒ  | _ |  i | ƒ t |  _ | oV d | _ d | _ d | _ |  i i | ƒ | |  i | i  <|  i  i! | i" ƒ  ƒ d St# | d	 ƒ }	 d | _ }
 d | _ } d | _ } |  i  i! | i" ƒ  ƒ | i t$ j o t% i& t% i' t% i( d
 ƒ } n d } x{ |	 i) d ƒ } | p Pn | t* | ƒ } t+ | |
 ƒ d @}
 | o# | i, | ƒ } | t* | ƒ } n |  i  i! | ƒ q?|	 i- ƒ  | o9 | i. ƒ  } | t* | ƒ } |  i  i! | ƒ | | _ n
 | | _ |
 | _ | | _ |  i  i ƒ  } |  i  i/ | i d d ƒ |  i  i! t0 i1 d | i | i | i ƒ ƒ |  i  i/ | d ƒ |  i i | ƒ | |  i | i  <d S(   sL   Put the bytes from filename into the archive under the name
        arcname.s7   Attempt to write to ZIP archive that was already closedi    i   i   RY   iÿÿ  l    NR   iñÿÿÿi   i   l   ÿÿ i   s   <LLLi    (2   RÒ   Rx   R]   t   statt   S_ISDIRt   st_modet   timet	   localtimet   st_mtimeR¼   R  R  R  R^   R  R   RR   RÏ   RJ   t   st_sizeRV   RO   R9   RS   R   R   RË   RU   RT   RÎ   R>   RÍ   R   t   writeRp   R   R   R¥   t   compressobjt   Z_DEFAULT_COMPRESSIONt   DEFLATEDR   RB   t   crc32t   compressR   RÁ   R   R   Rf   (   Rb   R   t   arcnameRJ   t   stR  t   mtimeRI   Ró   RÒ   RT   RU   RV   t   cmprR¶   t   position(    (    s   scripts/common/Lib/zipfile.pyR(  å  sˆ    

" 						
			c         C   sÄ  t  | t ƒ pA t d | d t i t i ƒ  ƒ d  ƒ } |  i | _ d | _ n | } |  i p t d ƒ ‚ n t	 | ƒ | _
 |  i i ƒ  | _ |  i | ƒ t |  _ t | ƒ d @| _ | i t j oG t i t i t i d ƒ } | i | ƒ | i ƒ  } t	 | ƒ | _ n | i
 | _ |  i i ƒ  | _ |  i i | i ƒ  ƒ |  i i | ƒ |  i i ƒ  | i d	 @o/ |  i i t i d
 | i | i | i
 ƒ ƒ n |  i i  | ƒ | |  i! | i" <d S(   s¬   Write a file into the archive.  The contents is the string
        'bytes'.  'zinfo_or_arcname' is either a ZipInfo instance or
        the name of the file in the archive.R   RI   i   i€  i   s7   Attempt to write to ZIP archive that was already closedl   ÿÿ iñÿÿÿi   s   <LLLNi  €(#   Rr   R   R$  R%  RÏ   RJ   RR   RÒ   Rx   RB   RV   R9   RS   R   R   RË   R,  RT   R   R¥   R)  R*  R+  R-  RÁ   RU   R(  Rp   RO   R   Rf   RÎ   R>   RÍ   R   (   Rb   t   zinfo_or_arcnameRÄ   Ró   t   co(    (    s   scripts/common/Lib/zipfile.pyt   writestr7  s:    
	c         C   s   |  i  ƒ  d S(   s2   Call the "close()" method in case the user forgot.N(   R   (   Rb   (    (    s   scripts/common/Lib/zipfile.pyt   __del__^  s    c         C   sà  |  i  d j o d S|  i d j o“|  i o‰d } |  i  i ƒ  } xà|  i D]Õ} | d } | i } | d d d >| d d >B| d	 B} | d
 d >| d d >B| d d	 B} g  } | i t j p | i	 t j o0 | i
 | i ƒ | i
 | i	 ƒ d } d }	 n | i } | i	 }	 | i t j o | i
 | i ƒ d }
 n
 | i }
 | i } | o\ t i d d t | ƒ d d t | ƒ | Œ | } t d | i ƒ } t d | i ƒ } n | i } | i } y… | i ƒ  \ } } t i t t | | i | | i | | i | | | i |	 | t | ƒ t | ƒ t | i ƒ d | i | i |
 ƒ } WnŒ t j
 o€ t i t t | | i | | i | i  | i | | | i |	 | t | i! ƒ t | ƒ t | i ƒ d | i | i |
 f IJ‚  n X|  i  i" | ƒ |  i  i" | ƒ |  i  i" | ƒ |  i  i" | i ƒ qN W|  i  i ƒ  } | } | | } | } | t# j p | t j p | t j o™ t i t$ t% d d d d d | | | | ƒ } |  i  i" | ƒ t i t& t' d | d ƒ } |  i  i" | ƒ t( | d ƒ } t( | d ƒ } t( | d ƒ } n t |  i ƒ t) j o2 |  i* d j o d t) } n |  i t)  |  _ n t i t+ t, d d | | | | t |  i ƒ ƒ	 } |  i  i" | ƒ |  i  i" |  i ƒ |  i  i- ƒ  n |  i. p |  i  i/ ƒ  n d |  _  d S(   sJ   Close the file, and for mode "w" and "a" write the ending
        records.NRÆ   RÇ   i    i   i¼  i	   i   i   i   i   i   l   ÿÿ s   <HHt   Qi   i-   i,   iÿÿ  s3   Archive comment is too long; truncating to %d bytes(   RÆ   RÇ   (0   RÒ   R¼   R¢   RË   R9   RÎ   RI   RV   Re   RU   R>   RS   RK   R   Rf   RB   R?   RM   R.   Rh   Râ   Rá   RL   RN   RJ   RT   RG   RQ   RR   t   DeprecationWarningR`   t   stderrRO   R   R(  t   ZIP_FILECOUNT_LIMITR   R   R   R   R´   t   ZIP_MAX_COMMENTRÌ   R<   R;   RÁ   RÑ   R   (   Rb   t   countt   pos1Ró   Rk   Rl   Rm   RK   RV   RU   RS   t
   extra_dataRM   R.   R   RO   Rë   t   pos2t   centDirCountt   centDirSizet   centDirOffsett   zip64endrect   zip64locrect   msgR   (    (    s   scripts/common/Lib/zipfile.pyR   b  s´    
 
	&&
		
					
!	

N(   R	   R
   R   R¼   RÒ   R   R   Rd   RÔ   RÕ   Rð   Rñ   Rõ   Rø   Rü   Rý   R   R   R  R  R  R   R(  R5  R6  R   (    (    (    s   scripts/common/Lib/zipfile.pyR   y  s*   ;		@							N	%	R	'	c           B   s#   e  Z d  Z d d „ Z d „  Z RS(   sD   Class to create ZIP archives with Python library files and packages.R8   c         C   sü  t  i i | ƒ \ } } t  i i | ƒ oit  i i | d ƒ } t  i i | ƒ oˆ| o d | | f } n | } |  i o d G| Gd G| GHn |  i | d d !| ƒ \ } } |  i o d G| GHn |  i | | ƒ t  i	 | ƒ } | i
 d ƒ x˜| D]× }	 t  i i | |	 ƒ }
 t  i i |	 ƒ \ } } t  i i |
 ƒ o: t  i i t  i i |
 d ƒ ƒ o |  i |
 | ƒ qÓqü | d j oJ |  i |
 d d !| ƒ \ } } |  i o d G| GHn |  i | | ƒ qü qü Wqø|  i o d	 G| GHn xt  i	 | ƒ D]Š }	 t  i i | |	 ƒ }
 t  i i |	 ƒ \ } } | d j oJ |  i |
 d d !| ƒ \ } } |  i o d G| GHn |  i | | ƒ qqWne | d d j o t d
 ‚ n |  i | d d !| ƒ \ } } |  i o d G| GHn |  i | | ƒ d S(   s,  Add all files from "pathname" to the ZIP archive.

        If pathname is a package directory, search the directory and
        all package subdirectories recursively for all *.py and enter
        the modules into the archive.  If pathname is a plain
        directory, listdir *.py and enter all modules.  Else, pathname
        must be a Python *.py file and the module will be put into the
        archive.  Added modules are always module.pyo or module.pyc.
        This method will compile the module.py into module.pyc if
        necessary.
        s   __init__.pys   %s/%ss   Adding package int   asi    iýÿÿÿt   Addings   .pys   Adding files from directorys.   Files added with writepy() must end with ".py"s   Adding fileN(   R]   R  t   splitR  R½   t   isfileRÌ   t   _get_codenameR(  t   listdirt   removet   splitextt   writepyRx   (   Rb   t   pathnamet   basenamet   dirR£   t   initnameR  R.  t   dirlistR   R  t   roott   ext(    (    s   scripts/common/Lib/zipfile.pyRN  Ô  s^    

 "

 


c   
   	   C   sD  | d } | d } | d } t  i i | ƒ o/ t  i | ƒ i t  i | ƒ i j o
 | } nª t  i i | ƒ p% t  i | ƒ i t  i | ƒ i j  oj d d k } |  i o d G| GHn y | i | | d t	 ƒ Wn  | i
 j
 o } | i GHn X| } n | } t  i i | ƒ d }	 | o d | |	 f }	 n | |	 f S(	   s   Return (filename, archivename) for the path.

        Given a module name path, return the correct file path and
        archive name, compiling if necessary.  For example, given
        /python/lib/string, return (/python/lib/string.pyc, string).
        s   .pys   .pycs   .pyoiÿÿÿÿNt	   Compilingi   s   %s/%s(   R]   R  RI  R!  R&  t
   py_compileRÌ   t   compileR¼   R   t   PyCompileErrorRE  RH  (
   Rb   RO  RP  t   file_pyt   file_pyct   file_pyoR  RW  t   errt   archivename(    (    s   scripts/common/Lib/zipfile.pyRJ    s*    


%
%

(   R	   R
   R   RN  RJ  (    (    (    s   scripts/common/Lib/zipfile.pyR   Ñ  s   Ac   
   
      sõ  d d  k  } | i d ƒ } |  d  j o t i d }  n |  p |  d d j o | GHt i d ƒ n |  d d j oT t |  ƒ d	 j o | GHt i d ƒ n t |  d d
 ƒ } | i ƒ  | i	 ƒ  n%|  d d j oO t |  ƒ d	 j o | GHt i d ƒ n t |  d d
 ƒ } | i
 ƒ  d GHnÅ|  d d j ot |  ƒ d j o | GHt i d ƒ n t |  d d
 ƒ } |  d	 } x» | i ƒ  D]­ } | i d ƒ o t i i | | d	 ƒ } n t i i | | ƒ } t i i | ƒ } t i i | ƒ p t i | ƒ n t | d ƒ } | i | i | ƒ ƒ | i	 ƒ  q‘W| i	 ƒ  n¢ |  d d j o� t |  ƒ d j  o | GHt i d ƒ n ‡  f d †  ‰  t |  d d d t ƒ} x. |  d	 D]" }	 ˆ  | |	 t i i |	 ƒ ƒ q½W| i	 ƒ  n d  S(   NiÿÿÿÿsE          Usage:
            zipfile.py -l zipfile.zip        # Show listing of a zipfile
            zipfile.py -t zipfile.zip        # Test if a zipfile is valid
            zipfile.py -e zipfile.zip target # Extract zipfile into target dir
            zipfile.py -c zipfile.zip src ... # Create zipfile from sources
        i   i    s   -ls   -cs   -es   -ti   R–   s   Done testingi   s   ./RÉ   c            s�   t  i i | ƒ o |  i | | t ƒ n` t  i i | ƒ oL xI t  i | ƒ D]4 } ˆ  |  t  i i | | ƒ t  i i | | ƒ ƒ qM Wn d  S(   N(   R]   R  RI  R(  R   R  RK  R½   (   t   zfR  t   zippatht   nm(   t   addToZip(    s   scripts/common/Lib/zipfile.pyRb  n  s     RÆ   RØ   (   s   -ls   -cs   -es   -t(   t   textwrapt   dedentR¼   R`   t   argvt   exitRB   R   Rõ   R   Rø   Rð   t
   startswithR]   R  R½   R  R  R  R   R(  R   R   RP  (
   t   argsRc  t   USAGER_  t   outR  t   tgtt   tgtdirRÒ   t   src(    (   Rb  s   scripts/common/Lib/zipfile.pyt   main4  sd    	

	
 	  t   __main__(e   R   R   R]   R$  R`   R  t   binasciiRÞ   R!  R¥   R,  t   ImportErrorR¼   t   __all__t	   ExceptionR    R   R   Re   R:  R;  R   R   R<   R;   Rg   R:   R    R!   R"   R#   R$   R%   R&   RA   RÜ   RÝ   Râ   Rá   Rà   t   _CD_SIGNATUREt   _CD_CREATE_VERSIONt   _CD_CREATE_SYSTEMt   _CD_EXTRACT_VERSIONt   _CD_EXTRACT_SYSTEMt   _CD_FLAG_BITSt   _CD_COMPRESS_TYPEt   _CD_TIMEt   _CD_DATEt   _CD_CRCt   _CD_COMPRESSED_SIZEt   _CD_UNCOMPRESSED_SIZERã   Rä   Rå   t   _CD_DISK_NUMBER_STARTt   _CD_INTERNAL_FILE_ATTRIBUTESt   _CD_EXTERNAL_FILE_ATTRIBUTESRæ   Ri   Rj   R   t   _FH_SIGNATUREt   _FH_EXTRACT_VERSIONt   _FH_EXTRACT_SYSTEMt   _FH_GENERAL_PURPOSE_FLAG_BITSt   _FH_COMPRESSION_METHODt   _FH_LAST_MOD_TIMEt   _FH_LAST_MOD_DATEt   _FH_CRCt   _FH_COMPRESSED_SIZEt   _FH_UNCOMPRESSED_SIZER  R  R   R   R   R   R   R   t   _CD64_SIGNATUREt   _CD64_DIRECTORY_RECSIZEt   _CD64_CREATE_VERSIONt   _CD64_EXTRACT_VERSIONt   _CD64_DISK_NUMBERt   _CD64_DISK_NUMBER_STARTt   _CD64_NUMBER_ENTRIES_THIS_DISKt   _CD64_NUMBER_ENTRIES_TOTALt   _CD64_DIRECTORY_SIZEt   _CD64_OFFSET_START_CENTDIRR   R6   R   t   objectR   R€   R•   R   R   Rn  R	   (    (    (    s   scripts/common/Lib/zipfile.pyt   <module>   sÂ   <$
		!	7•;Âÿ ÿ ZcI