
mKc           @   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.
iNt
   BadZipfilet   errort
   ZIP_STOREDt   ZIP_DEFLATEDt
   is_zipfilet   ZipInfot   ZipFilet	   PyZipFilet   LargeZipFilec           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s   /usr/lib/python2.6/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   /usr/lib/python2.6/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   /usr/lib/python2.6/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   /usr/lib/python2.6/zipfile.pyt   _EndRecData64   s(    0






c         C   s  |  i  d d  |  i   } y |  i  t d  Wn t j
 o d	 SX|  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   it     t    i   i   Ni   (   R   t   tellt   sizeEndCentDirR   t   NoneR   t   stringEndArchiveR   R   t   structEndArchivet   listt   appendR6   t   maxt   rfindt   _ECD_COMMENT_SIZEt   len(   R   t   filesizeR(   R   t   maxCommentStartt   startt   recDatat   comment(    (    s   /usr/lib/python2.6/zipfile.pyR      s6    %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_typeRH   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   (   RI   t   findt   chrt   ost   sept   replaceR   RJ   R   RK   RH   RL   t   syst   platformRM   R.   RN   RO   RP   RQ   RR   RS   (   t   selfR   RJ   t	   null_byte(    (    s   /usr/lib/python2.6/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-   (   RJ   RP   RU   RV   RW   RL   t   ZIP64_LIMITR   t   packt   calcsizeR@   RN   R.   t   _encodeFilenameFlagst   structFileHeadert   stringFileHeaderRO   RK   RC   (   Rc   t   dtt   dosdatet   dostimeRU   RV   RW   RL   t   fmtR   RP   t   header(    (    s   /usr/lib/python2.6/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   encodeRP   t   UnicodeEncodeError(   Rc   (    (    s   /usr/lib/python2.6/zipfile.pyRi   K  s    #c         C   s*   |  i  d @o |  i i d  S|  i Sd  S(   Ni   s   utf-8(   RP   R   t   decode(   Rc   (    (    s   /usr/lib/python2.6/zipfile.pyt   _decodeFilenameT  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    (   RL   R   R   t   RuntimeErrorRW   RV   RT   (   Rc   RL   R   t   tpt   lnt   countst   idxt   old(    (    s   /usr/lib/python2.6/zipfile.pyt   _decodeExtraZ  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__Re   Rq   Ri   Rx   R   (    (    (    s   /usr/lib/python2.6/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   /usr/lib/python2.6/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(   Rc   t   chR   (    (    s   /usr/lib/python2.6/zipfile.pyt   _crc32  s    c         C   s=   d |  _  d |  _ d |  _ x | D] } |  i |  q" Wd  S(   NixV4igE#ixV4(   t   key0t   key1t   key2t   _UpdateKeys(   Rc   t   pwdt   p(    (    s   /usr/lib/python2.6/zipfile.pyRe     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   (   Rc   t   c(    (    s   /usr/lib/python2.6/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   (   Rc   R   t   k(    (    s   /usr/lib/python2.6/zipfile.pyt   __call__  s    (	   R	   R
   R   R   R   R   Re   R   R   (    (    (    s   /usr/lib/python2.6/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   lastdiscardRK   RV   t   closedt   modeR   t   namet   compreadsizeR   t   zlibt   decompressobjt   dc(   Rc   R   t   zipinfot   decrypt(    (    s   /usr/lib/python2.6/zipfile.pyRe     s$    													c         C   s-   | |  _  d |  _ |  i  o d |  _ n d  S(   Ns   
s   
s   (   s   
(   s   
s   s   
(   R   R   (   Rc   R   (    (    s   /usr/lib/python2.6/zipfile.pyt   set_univ_newlines  s    		
c         C   s   |  S(   N(    (   Rc   (    (    s   /usr/lib/python2.6/zipfile.pyt   __iter__  s    c         C   s$   |  i    } | p t    n | S(   N(   t   readlinet   StopIteration(   Rc   t   nextline(    (    s   /usr/lib/python2.6/zipfile.pyt   next  s    c         C   s   t  |  _ d  S(   N(   R   R   (   Rc   (    (    s   /usr/lib/python2.6/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(   Nii    s   s   
i   (   ii(   s   s   
(   R   R   R   R\   RC   (   Rc   t   nlt   nllenR_   (    (    s   /usr/lib/python2.6/zipfile.pyt   _checkfornewline  s    

 ic         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   
(   Ra   t   maxintR   t   minRC   R   R   R   (   Rc   t   sizeR   R   t   buft   s(    (    s   /usr/lib/python2.6/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?   (   Rc   t   sizehintt   resultt   line(    (    s   /usr/lib/python2.6/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   (   RV   R   R   R;   RK   R   RC   R   R   R   R   R   R   R   t   joint   mapR   t
   decompresst   unconsumed_tailR   t   flush(   Rc   R   t   bytesToReadt   lrt   bytest   newdata(    (    s   /usr/lib/python2.6/zipfile.pyR   4  sL    

		 #	N(   R	   R
   R   R;   Re   R   R   R   R   R   R   R   R   (    (    (    s   /usr/lib/python2.6/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   (   Ry   R   R   R   t   _allowZip64R   t
   _didModifyt   debugt
   NameToInfot   filelistt   compressionR`   R   R;   R   RH   Rs   t
   basestringt   _filePassedR   R   t   fpR   t   getattrt   _GetContentst   _RealGetContentsR   t	   start_dirR    R   (   Rc   t   fileR   R   t
   allowZip64t   keyt   modeDict(    (    s   /usr/lib/python2.6/zipfile.pyRe     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;   (   Rc   (    (    s   /usr/lib/python2.6/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_COMMENTRH   t   _ECD_LOCATIONR    R   R   R   R   R   R   t	   cStringIOt   StringIOt   sizeCentralDirt   stringCentralDirR   R   t   structCentralDirt   _CD_FILENAME_LENGTHR   t   _CD_EXTRA_FIELD_LENGTHRL   t   _CD_COMMENT_LENGTHt   _CD_LOCAL_HEADER_OFFSETRT   R.   RM   RN   RO   RP   RK   RU   RV   RW   RQ   RR   RS   RX   RJ   R   Rx   R   R   R?   R   (   Rc   R   R   t   size_cdt	   offset_cdt   concatt   inferredR(   R   t   centdirR   t   xt   tt   d(    (    s   /usr/lib/python2.6/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   (   Rc   t   lR(   (    (    s   /usr/lib/python2.6/zipfile.pyt   namelist  s
    
 c         C   s   |  i  S(   sJ   Return a list of class ZipInfo instances for files in the
        archive.(   R   (   Rc   (    (    s   /usr/lib/python2.6/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   RJ   R   RW   (   Rc   t   zinfot   date(    (    s   /usr/lib/python2.6/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    (   Rc   t
   chunk_sizeR   t   f(    (    s   /usr/lib/python2.6/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(   Rc   R   t   info(    (    s   /usr/lib/python2.6/zipfile.pyt   getinfo3  s
    c         C   s   | |  _  d S(   s)   Set default password for encrypted files.N(   R   (   Rc   R   (    (    s   /usr/lib/python2.6/zipfile.pyt   setpassword<  s    c         C   s   |  i  | d |  i   S(   s)   Return file bytes (as a string) for name.R   (   R   R   (   Rc   R   R   (    (    s   /usr/lib/python2.6/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(   Ry   R   R   R   R   Rs   R   R   R   RT   R   t   sizeFileHeaderRk   R    R   R   Rj   t   _FH_FILENAME_LENGTHt   _FH_EXTRA_FIELD_LENGTHRI   RP   R;   R   R   R   RX   RU   R   R   R   R   (   Rc   R   R   R   t   zef_fileR   t   fheadert   fnamet   is_encryptedt   zdR   t   ht
   check_bytet   zef(    (    s   /usr/lib/python2.6/zipfile.pyR   D  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(   Rs   R   R   R;   R^   t   getcwdt   _extract_member(   Rc   t   membert   pathR   (    (    s   /usr/lib/python2.6/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  (   Rc   R  t   membersR   R   (    (    s   /usr/lib/python2.6/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.
        ii   i    RZ   R   R   (   R^   R  R_   t   altsepRC   t
   splitdriveR   R   t   normpatht   dirnamet   existst   makedirst   isdirt   mkdirR   R   t   shutilt   copyfileobjR   (   Rc   R  t
   targetpathR   t	   upperdirst   sourcet   target(    (    s   /usr/lib/python2.6/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   Ry   R   RK   R   R   R   RW   Rf   R   R   RT   (   Rc   R   (    (    s   /usr/lib/python2.6/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   RZ   i  l    NR   ii   i   l    i   s   <LLLi    (2   R   Ry   R^   t   statt   S_ISDIRt   st_modet   timet	   localtimet   st_mtimeR;   R  R  R  R_   R  R   RS   R   RK   t   st_sizeRW   RP   R9   RT   R   R   R   RV   RU   R   R?   R   R   t   writeRq   R   R   R   t   compressobjt   Z_DEFAULT_COMPRESSIONt   DEFLATEDR   RC   t   crc32t   compressR   R   R   R   Rg   (   Rc   R   t   arcnameRK   t   stR  t   mtimeRJ   R   R   RU   RV   RW   t   cmprR   t   position(    (    s   /usr/lib/python2.6/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   RJ   i   i  i   s7   Attempt to write to ZIP archive that was already closedl    ii   s   <LLLNi  (#   Rs   R   R$  R%  R   RK   RS   R   Ry   RC   RW   R9   RT   R   R   R   R,  RU   R   R   R)  R*  R+  R-  R   RV   R(  Rq   RP   R   Rg   R   R?   R   R   (   Rc   t   zinfo_or_arcnameR   R   t   co(    (    s   /usr/lib/python2.6/zipfile.pyt   writestr:  s:    
	c         C   s   |  i    d S(   s2   Call the "close()" method in case the user forgot.N(   R   (   Rc   (    (    s   /usr/lib/python2.6/zipfile.pyt   __del__a  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   RJ   RW   Rf   RV   R?   RT   RL   R   Rg   RC   R@   RN   R.   Ri   R   R   RM   RO   RK   RU   RH   RR   RS   t   DeprecationWarningRa   t   stderrRP   R   R(  t   ZIP_FILECOUNT_LIMITR   R   R   R   R   t   ZIP_MAX_COMMENTR   R=   R<   R   R   R   (   Rc   t   countt   pos1R   Rl   Rm   Rn   RL   RW   RV   RT   t
   extra_dataRN   R.   R   RP   R   t   pos2t   centDirCountt   centDirSizet   centDirOffsett   zip64endrect   zip64locrect   msgR   (    (    s   /usr/lib/python2.6/zipfile.pyR   e  s    
 
	&&
		
					
!	

N(   R	   R
   R   R;   R   R   R   Re   R   R   R   R   R   R   R   R   R   R   R  R  R  R   R(  R5  R6  R   (    (    (    s   /usr/lib/python2.6/zipfile.pyR   |  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    it   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   writepyRy   (   Rc   t   pathnamet   basenamet   dirR   t   initnameR  R.  t   dirlistR   R  t   roott   ext(    (    s   /usr/lib/python2.6/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   .pyoiNt	   Compilingi   s   %s/%s(   R^   R  RI  R!  R&  t
   py_compileR   t   compileR;   R   t   PyCompileErrorRE  RH  (
   Rc   RO  RP  t   file_pyt   file_pyct   file_pyoR  RW  t   errt   archivename(    (    s   /usr/lib/python2.6/zipfile.pyRJ    s*    


%
%

(   R	   R
   R   RN  RJ  (    (    (    s   /usr/lib/python2.6/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(   NisE          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   /usr/lib/python2.6/zipfile.pyRb  q  s     R   R   (   s   -ls   -cs   -es   -t(   t   textwrapt   dedentR;   Ra   t   argvt   exitRC   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   /usr/lib/python2.6/zipfile.pyt   main7  sd    	

	
 	  t   __main__(e   R   R   R^   R$  Ra   R  t   binasciiR   R!  R   R,  t   ImportErrorR;   t   __all__t	   ExceptionR    R   R   Rf   R:  R;  R   R   R=   R<   Rh   R:   R    R!   R"   R#   R$   R%   R&   RB   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   Rj   Rk   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   /usr/lib/python2.6/zipfile.pyt   <module>   s   <$
		!	:;  ZcI