ó
¤ –Qc           @   s  d  Z  d Z d Z d d l Z d d l Z d d l Z d d l Z d „  Z e	 d „  e j
 ƒ  ƒ Z x? d D]7 Z e e j k rj e e ƒ Z e j Z e j Z Pqj qj Wd e j d  Z d	 e j d
 k rÒ d
 Z  n  d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   i    iÿÿÿÿNc         C   s   d  S(   N(    (   t   msg(    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyt   debug$   s    c         C   s   |  d t  j k S(   Ni   (   t   impt   C_EXTENSION(   t   x(    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyt   <lambda>*   s    t   ntt   posixs   %d%di   s   -vii   t   ArchiveReadErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyR   9   s   t   Archivec           B   s¤   e  Z d  Z d Z d Z d Z i  Z d Z d Z	 d d d „ Z
 d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s  
    A base class for a repository of python code objects.
    The extract method is used by imputil.ArchiveImporter
    to get code objects by name (fully qualified name), so
    an enduser "import a.b" would become
      extract('a.__init__')
      extract('a.b')
    t   PYL i   i   i    c         C   sr   d |  _ | |  _ | |  _ d d l } | j ƒ  |  _ | d k	 rn t |  j d ƒ |  _ |  j	 ƒ  |  j
 ƒ  n  d S(   sY   
        Initialize an Archive. If path is omitted, it will be an empty Archive.
        iÿÿÿÿNt   rb(   t   Nonet   toct   patht   startR   t	   get_magict   pymagict   opent   libt
   checkmagict   loadtoc(   t   selfR   R   R   (    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyt   __init__M   s    			
c         C   s§   |  j  j |  j ƒ |  j  j t |  j ƒ ƒ |  j k rY t d |  j |  j j	 f ƒ ‚ n  |  j  j t |  j
 ƒ ƒ |  j
 k r“ t d |  j ƒ ‚ n  |  j  j d ƒ d S(   sz   
        Overridable.
        Check to see if the file object self.lib actually has a file
        we understand.
        s!   %s is not a valid %s archive files   %s has version mismatch to dlli   N(   R   t   seekR   t   readt   lent   MAGICR   R   t	   __class__R	   R   (   R   (    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyR   \   s    $$c         C   sk   |  j  j |  j |  j ƒ t j d |  j  j d ƒ ƒ \ } |  j  j |  j | ƒ t j |  j  ƒ |  _	 d S(   sÃ   
        Overridable.
        Default: After magic comes an int (4 byte native) giving the
        position of the TOC within self.lib.
        Default: The TOC is a marshal-able string.
        s   !ii   N(
   R   R   R   t   TOCPOSt   structt   unpackR   t   marshalt   loadR   (   R   t   offset(    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyR   n   s    !c         C   sX   |  j  j | d ƒ \ } } | d k r+ d S|  j j |  j | ƒ | t j |  j ƒ f S(   s*  
        Get the object corresponding to name, or None.
        For use with imputil ArchiveImporter, object is a python code object.
        'name' is the name as specified in an 'import name'.
        'import a.b' will become:
        extract('a') (return None because 'a' is not a code object)
        extract('a.__init__') (return a code object)
        extract('a.b') (return a code object)
        Default implementation:
          self.toc is a dict
          self.toc[name] is pos
          self.lib has the code object marshal-ed at pos
        i    N(   i    N(   R   t   getR   R   R   R   R"   R#   (   R   t   namet   ispkgt   pos(    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyt   extract   s
    c         C   s   |  j  j ƒ  S(   sŸ   
        Return a list of the contents
        Default implementation assumes self.toc is a dict like object.
        Not required by ArchiveImporter.
        (   R   t   keys(   R   (    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyt   contents˜   s    c         C   s   |  j  d k s t ‚ | |  _  t | d ƒ |  _ |  j rS |  j j d |  j ƒ n  t |  j ƒ t i  ƒ k rz i  |  _	 n |  j ƒ  |  _	 d S(   s@   
        Open an empty archive for addition of entries.
        t   wbt    N(
   R   R   t   AssertionErrorR   R   t   HDRLENt   writet   typet   TOCTMPLTR   (   R   R   (    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyt   _start_add_entries¥   s    		c         C   s"   x | D] } |  j  | ƒ q Wd S(   sv  
        Add entries from a logical TOC (without absolute positioning info).
        An entry is an entry in a logical TOC is a tuple,
          entry[0] is name (under which it will be saved).
          entry[1] is fullpathname of the file.
          entry[2] is a flag for it's storage format (True or 1 if compressed)
          entry[3] is the entry's type code.
        N(   t   add(   R   R   t	   toc_entry(    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyt   _add_from_table_of_contents¹   s    	c         C   sF   |  j  j ƒ  } |  j | ƒ |  j r5 |  j | ƒ n  |  j  j ƒ  d S(   s•   
        Finalize an archive which has been opened using _start_add_entries(),
        writing any needed padding and the table of contents.
        N(   R   t   tellt   save_tocR/   t   update_headerst   close(   R   t   toc_pos(    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyt	   _finalizeÅ   s
    	c         C   s(   |  j  | ƒ |  j | ƒ |  j ƒ  d S(   sö   
        Create an archive file of name 'archive_path'.
        logical_toc is a 'logical TOC' - a list of (name, path, ...)
        where name is the internal name, eg 'a'
        and path is a file to get the object from, eg './a.pyc'.
        N(   R3   R6   R<   (   R   t   archive_patht   logical_toc(    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyt   buildÐ   s    c   	      C   sÙ   |  j  d k r' d d l  } | |  _  n  | d } | d } |  j  j j |  j  j j | ƒ ƒ \ } } | d k } | d
 k sƒ t ‚ | |  j j ƒ  f |  j | <t	 | d d ƒ } | j
 d	 ƒ |  j j | j ƒ  ƒ d S(   sM  
        Override this to influence the mechanics of the Archive.
        Assumes entry is a seq beginning with (nm, pth, ...) where
        nm is the key by which we'll be asked for the object.
        pth is the name of where we find the object. Overrides of
        get_obj_from can make use of further elements in entry.
        iÿÿÿÿNi    i   R   s   .pycs   .pyoR   i   (   s   .pycs   .pyo(   t   osR   R   t   splitextt   basenameR.   R   R7   R   R   R   R0   R   (	   R   t   entryR@   t   nmt   ptht   pynmt   extR'   t   f(    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyR4   Ü   s    

*c         C   s   t  j |  j |  j ƒ d S(   sL   
        Default - toc is a dict
        Gets marshaled to self.lib
        N(   R"   t   dumpR   R   (   R   t   tocpos(    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyR8   ñ   s    c         C   sY   |  j  j |  j ƒ |  j  j |  j ƒ |  j  j |  j ƒ |  j  j t j d | ƒ ƒ d S(   s;   
        Default - MAGIC + Python's magic + tocpos
        s   !iN(   R   R   R   R0   R   R   R    t   pack(   R   RJ   (    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyR9   ø   s    N(   R	   R
   t   __doc__R   R/   R   R2   R   R@   t	   _bincacheR   R   R   R)   R+   R3   R6   R<   R?   R4   R8   R9   (    (    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyR   =   s&   										t   ZlibArchivec           B   so   e  Z d  Z d Z d Z e j d Z i  Z d Z d Z	 d d d d „ Z d „  Z d „  Z d	 „  Z d
 „  Z RS(   sÈ   
    ZlibArchive - an archive with compressed entries. Archive is read
    from the executable created by PyInstaller.

    This archive is used for bundling python modules inside the executable.
    t   PYZ i   i   i	   i    c         C   s  | d  k r d } n‰ | d  k rž xz t t | ƒ d d d ƒ D]S } | | d k r> y t | | d ƒ } Wn t k
 r‚ q> n X| |  } Pq> q> Wd } n  | |  _ t j |  | | ƒ d  |  _ |  j |  j	 k ry t
 d ƒ |  _ Wqt k
 rt d ƒ ‚ qXn  d |  _ d  S(   Ni    i   iÿÿÿÿt   ?t   zlibs$   zlib required but cannot be imported(   R   t   rangeR   t   intt
   ValueErrort   LEVELR   R   t	   _mod_zlibt   NO_COMPRESSION_LEVELt
   __import__t   ImportErrort   RuntimeErrort   crypted(   R   R   R$   t   levelt   i(    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyR     s*    	#
			c         C   sØ   |  j  j | d ƒ \ } } } | d  k r. d  S|  j j |  j | ƒ |  j j | ƒ } y |  j j | ƒ } Wn' |  j j	 k
 r– t
 d | ƒ ‚ n Xy t j | ƒ } Wn! t k
 rÍ t
 d | ƒ ‚ n X| | f S(   Ni    s#   PYZ entry '%s' failed to decompresss"   PYZ entry '%s' failed to unmarshal(   i    Ni    (   R   R%   R   R   R   R   R   RV   t
   decompresst   errorRY   R"   t   loadst   EOFError(   R   R&   R'   R(   t   lngtht   objt   co(    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyR)   2  s    c         C   s  |  j  d  k r' d d  l  } | |  _  n  | d } | d } |  j  j j |  j  j j | ƒ ƒ \ } } | d k } y! t | d  d ƒ j ƒ  d } Wn› t t f k
 r/yT t | d ƒ }	 |	 j	 d ƒ |	 j ƒ  }
 t
 j |
 ƒ j |  j j |
 |  j ƒ } WqÈt t t t f k
 r+t d	 | ƒ ‚ qÈXn™ X| j d
 d ƒ } y7 d d  l  } t | |  j  j j |  j | ƒ d ƒ } Wn+ t k
 r¦} d G| d  GH| j GH‚  n X|  j j t
 j | ƒ |  j ƒ } | |  j j ƒ  t | ƒ f |  j | <|  j j | ƒ d  S(   Niÿÿÿÿi    i   R   t   rUs   
R   i   s    bad bytecode in %s and no sources   
t   execs   Syntax error in(   R@   R   R   RA   RB   R   R   t   IOErrort   OSErrorR   R"   R`   t   co_filenameRV   t   compressRU   RT   Ra   t   AttributeErrort   replacet   compilet   joint   SyntaxErrort   argst   dumpsR   R7   R   R   R0   (   R   RC   R@   RD   RE   t   baseRG   R'   t   txtRH   t   bytecodeRc   Rd   t   e(    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyR4   B  s:    

*!+!%c         C   s9   t  j |  | ƒ |  j j t j d |  j |  j ƒ ƒ d S(   s   
        add level
        s   !iBN(   R   R9   R   R0   R    RK   RU   R[   (   R   RJ   (    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyR9   b  s    c         C   s;   t  j |  ƒ t j d |  j j d ƒ ƒ \ |  _ |  _ d  S(   Ns   !iBi   (   R   R   R    R!   R   R   RU   R[   (   R   (    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyR   i  s    N(   R	   R
   RL   R   R   R   R/   R2   RU   RW   R   R   R)   R4   R9   R   (    (    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyRN     s   "		 	(   s   nts   posix(   t   _verboseR   t   _listdirt   _environR"   R    R   t   sysR   t   filtert   get_suffixest   _c_suffixesRD   t   builtin_module_namesRX   t   modt   listdirt   environt   version_infot	   versuffixt   argvRZ   R   t   objectR   RN   (    (    (    sa   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\loader\pyi_archive.pyt   <module>   s(   				Å