ó
©¶"Pc           @   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 d d „  ƒ  YZ d d d „  ƒ  YZ d d l Z d e f d „  ƒ  YZ d d d „  ƒ  YZ d e j f d „  ƒ  YZ d d d „  ƒ  YZ d e j f d „  ƒ  YZ  d S(    i    iÿÿÿÿNc         C   s   d  S(   N(    (   t   msg(    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyt   debug1   s    c         C   s   |  d t  j k S(   Ni   (   t   impt   C_EXTENSION(   t   x(    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyt   <lambda>7   s    t   ntt   posixs   %d%di   s   -vii   t   ArchiveReadErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR   F   s   t   Archivec           B   s˜   e  Z d  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 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   (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyt   __init__[   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   (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR   j   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(    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR   |   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(    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/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   (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyt   contents¦   s    c         C   sñ   | |  _  t | d ƒ |  _ |  j r> |  j j d |  j ƒ n  t |  j ƒ t i  ƒ k re i  |  _ n |  j ƒ  |  _ x | D] } |  j | ƒ q{ W|  j j	 ƒ  } |  j
 | ƒ |  j rÇ |  j | ƒ n  |  j rà |  j | ƒ n  |  j j ƒ  d S(   sç   
        Create an archive file of name 'path'.
        lTOC 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'.
        t   wbt    N(   R   R   R   t   HDRLENt   writet   typet   TOCTMPLTR   t   addt   tellt   save_toct   TRLLENt   save_trailert   update_headerst   close(   R   R   t   lTOCt   tocentryt   tocpos(    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/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   basenamet   AssertionErrorR   R3   R   R   R   R/   R   (	   R   t   entryR=   t   nmt   ptht   pynmt   extR'   t   f(    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR2   Ò   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   R;   (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR4   ç   s    c         C   s   d S(   s$   
        Default - not used
        N(    (   R   R;   (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR6   î   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   R/   R   R   R    t   pack(   R   R;   (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR7   ô   s    N(   R	   R
   t   __doc__R   R.   R   R5   R1   R   R=   t	   _bincacheR   R   R   R)   R+   R<   R2   R4   R6   R7   (    (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR   J   s$   					 			t	   DummyZlibc           B   s    e  Z e Z d  „  Z d „  Z RS(   c         C   s   t  d ‚ d  S(   Ns$   zlib required but cannot be imported(   t   RuntimeError(   R   t   data(    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyt
   decompress  s    c         C   s   t  d ‚ d  S(   Ns$   zlib required but cannot be imported(   RL   (   R   RM   t   lvl(    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyt   compress  s    (   R	   R
   RL   t   errorRN   RP   (    (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyRK   þ   s   	t   ZlibArchivec           B   s{   e  Z d  Z d Z d Z e j d Z d Z i  Z d Z	 d d d d d „ Z 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.
    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  | |  _ | d  k	 rÔ d |  _ | d d d  |  _ n d |  _ d  |  _ t j	 |  | | ƒ |  j r2y d d  l
 a
 Wq@t k
 r.t ƒ  a
 q@Xn d GHt ƒ  a
 |  j rXd d  l a n  d  S(   Ni    i   iÿÿÿÿt   ?t   *i    s   WARNING: compression level=0!!!(   R   t   rangeR   t   intt
   ValueErrort   LEVELt   cryptedt   keyR   R   t   zlibt   ImportErrorRK   t   AES(   R   R   R$   t   levelt   cryptt   i(    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR     s8    	#
								c         C   s0   | t  j t | ƒ d t | ƒ } | t  j  S(   Ni   (   R^   t
   block_sizeR   (   R   RB   t   IV(    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyt   _ivB  s    %c         C   s4  |  j  j | d ƒ \ } } } | d  k r. d  S|  j j |  j | ƒ |  j j | ƒ } |  j r® |  j d  k r~ t	 d ƒ ‚ n  t
 j |  j t
 j |  j | ƒ ƒ j | ƒ } n  y t j | ƒ } Wn/ t j k
 rò |  j sã ‚  n  t	 d ƒ ‚ n Xy t j | ƒ } Wn! t k
 r)t	 d | ƒ ‚ n X| | f S(   Ni    s   decryption key not founds   invalid decryption keys"   PYZ entry '%s' failed to unmarshal(   i    Ni    (   R   R%   R   R   R   R   R   RZ   R[   R]   R^   t   newt   MODE_CFBRd   t   decryptR\   RN   RQ   R"   t   loadst   EOFError(   R   R&   R'   R(   t   lngtht   objt   co(    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR)   F  s(    	0	c         C   s4  |  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,yQ t | d ƒ }	 |	 j	 d ƒ |	 j ƒ  }
 t
 j |
 ƒ j t 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 Xt j t
 j | ƒ |  j ƒ } |  j rût j |  j t j |  j | ƒ ƒ j | ƒ } n  | |  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   R>   R?   R   R   t   IOErrort   OSErrorR   R"   Rh   t   co_filenameR\   RP   RY   RX   Ri   t   AttributeErrort   replacet   compilet   joint   SyntaxErrort   argst   dumpsRZ   R^   Re   R[   Rf   Rd   t   encryptR   R3   R   R   R/   (   R   RA   R=   RB   RC   t   baseRE   R'   t   txtRF   t   bytecodeRk   Rl   t   e(    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR2   \  s>    

*!+	0%c         C   s9   t  j |  | ƒ |  j j t j d |  j |  j ƒ ƒ d S(   s   
        add level
        s   !iBN(   R   R7   R   R/   R    RH   RY   RZ   (   R   R;   (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR7   ~  s    c         C   s;   t  j |  ƒ t j d |  j j d ƒ ƒ \ |  _ |  _ d  S(   Ns   !iBi   (   R   R   R    R!   R   R   RY   RZ   (   R   (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR   …  s    N(   R	   R
   RI   R   R   R   R.   R5   R1   RY   R   R   Rd   R)   R2   R7   R   (    (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyRR     s   *			"	t   Keyfilec           B   s   e  Z d d  „ Z RS(   c         C   s|   | d  k rC t j d } | d d k r6 | d  } n  | d 7} n  t | i d  d 6|  j ƒ t |  d ƒ sx d  |  _ n  d  S(   Ni    iüÿÿÿt   .s   .keyt   __builtins__R[   (   R   t   syst   argvt   execfilet   __dict__t   hasattrR[   (   R   t   fn(    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR   ‹  s    N(   R	   R
   R   R   (    (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR~   Š  s   t   PYZOwnerc           B   s&   e  Z d  Z d „  Z e j d „ Z RS(   s’  
    Load bytecode of Python modules from the executable created by PyInstaller.

    Python bytecode is zipped and appended to the executable.

    NOTE: PYZ format cannot be replaced by zipimport module.

    The problem is that we have no control over zipimport; for instance,
    it doesn't work if the zip file is embedded into a PKG appended
    to an executable, like we create in one-file.
    c         C   sª   y  t  | ƒ |  _ |  j j ƒ  Wn( t t f k
 rJ } t j | ƒ ‚ n X|  j j r“ t t	 d ƒ su t
 ƒ  t	 _ n  t  | d t	 j j ƒ|  _ n  t j j |  | ƒ d  S(   Nt   keyfileR`   (   RR   t   pyzR   Ro   R   t   iut
   OwnerErrorRZ   R…   R   R~   Rˆ   R[   t   OwnerR   (   R   R   R}   (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR   £  s    c   	      C   sy  |  j  j | ƒ } | d  k r" d  S| \ } } | | ƒ } yk | ry t j t j |  j | j d t j ƒ ƒ d ƒ | _ n+ t j |  j | j d t j ƒ d ƒ | _ Wn- t	 k
 rÔ t
 d | t | ƒ f ƒ ‚ n X| rlt j } t j | j ƒ |  j | g | _ t d | | j f ƒ t j | j i t | |  ƒ |  j 6t | | ƒ | 6t j g ƒ } | j | _ n  | | _ | S(   NR   s   __init__.pycs   .pycs.   PYZ entry '%s' (%s) is not a valid code objects"   PYZOwner setting %s's __path__: %s(   R‰   R)   R   RŠ   t   _os_path_joinR   Rs   t   _os_sept   __file__Rr   R]   t   reprR   t   prefixt   _os_path_dirnamet   __path__R   t   PathImportDirectort   PkgInPYZImportert   ExtInPkgImportert   DirOwnert   getmodt   __importsub__t   __co__(	   R   RB   t   newmodt   rsltR'   R|   t   modt	   localpatht   importer(    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR˜   °  s2    $#	!	(   R	   R
   RI   R   R   t
   new_moduleR˜   (    (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR‡   —  s   	R•   c           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   | |  _  | |  _ d  S(   N(   R&   t   owner(   R   R&   R¡   (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR   à  s    	c         C   s:   t  d | |  j d | f ƒ |  j j |  j d | ƒ S(   Ns    PkgInPYZImporter.getmod %s -> %sR   (   R   R&   R¡   R˜   (   R   RB   (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR˜   ä  s    (   R	   R
   R   R˜   (    (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR•   ß  s   	R–   c           B   s   e  Z d  „  Z d „  Z RS(   c         C   s    t  j j |  | ƒ | |  _ d  S(   N(   RŠ   R—   R   R‘   (   R   R   R‘   (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR   ê  s    c         C   s   t  j j |  |  j d | ƒ S(   NR   (   RŠ   R—   R˜   R‘   (   R   RB   (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR˜   î  s    (   R	   R
   R   R˜   (    (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyR–   é  s   	(   s   nts   posix(    (    (    (    (!   t   _verboseR   t   _listdirt   _environR"   R    R   R   R   t   filtert   get_suffixest   _c_suffixesRB   t   builtin_module_namest
   __import__R   t   listdirt   environt   version_infot	   versuffixR‚   RL   R   R   RK   RŠ   RR   R~   RŒ   R‡   R•   R—   R–   (    (    (    sK   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/loader/archive.pyt   <module>$   s4   				´~H
