ó
©¶"Pc           @   sý   d  d l  Z  d  d l Z d  d l Z d  d l m Z d  d l m Z m Z d  d l m	 Z	 d  d l
 j Z e j d ƒ Z d e f d „  ƒ  YZ d d d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   iÿÿÿÿN(   t   depend(   t   PYCOt   caseOk(   t   archives   PyInstaller.build.mft
   OwnerErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR   *   s   t   Ownerc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   sG   
    Base class for loading Python bytecode from different places.
    c         C   s   | |  _  d  S(   N(   t   path(   t   selfR   (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyt   __init__2   s    c         C   s   |  j  S(   N(   R   (   R	   (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyt   __str__5   s    c         C   s   d  S(   N(   t   None(   R	   t   nm(    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyt   getmod8   s    (   R   R   t   __doc__R
   R   R   (    (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR   .   s   		t   BaseDirOwnerc           B   s)   e  Z d  Z d „  Z d e j d „ Z RS(   sM   
    Base class for loading bytecode of Python modules from file system.
    c         C   s
   t  j ƒ  S(   N(   t   impt   get_suffixes(   R	   (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyt   _getsuffixes@   s    c      	   C   sa  | d  k r |  j } n  | d d  f g } |  j | ƒ rs |  j | ƒ rs | j d t j j | d ƒ d | f ƒ n  d  } } xß | D]× \ } } }	 xµ | ƒ  D]ª \ }
 } } | |
 } |  j | ƒ } | d  k	 r |  j | ƒ sæ q n  | t	 j
 k rt j j | t j j |  j | ƒ ƒ S| t	 j k r8| | f } qG| | f } q q W| sW| r„ Pq„ q„ W| d  k r{| d  k r{d  Sd  } | r"|  j | d ƒ } | d  t	 j ƒ  k rÊt j d t | d ƒ q"y | | d ƒ } | d } Wq"t t f k
 rd  } t j d t | d ƒ q"Xn  | d  k sH| rÕ| d | d k  rÕy[ |  j | d ƒ d } t | j d	 d ƒ | d d
 ƒ } | d t } t j d | ƒ WqÕt k
 rÑ} t j | ƒ t d ƒ ‚ qÕXn  | d  k råd  St j j |  j | ƒ } t j j | ƒ s$t j j | ƒ } n  | rE|  j ƒ  | | | ƒ } n |  j ƒ  | | | ƒ } | S(   Ni    R
   i   i   s,   wrong version .py%s found (%s), will use .pyi   s"   bad .py%s found (%s), will use .pys   
s   
t   execs   compiled %si
   (    R   R   t   _isdirt   _caseokt   insertt   osR   t   joint   _modtimeR   t   C_EXTENSIONR    t   modulest   ExtensionModulet	   PY_SOURCEt   _readt	   get_magict   loggert   warnR   t
   ValueErrort   EOFErrort   compilet   replacet   debugt   SyntaxErrort	   exceptiont
   SystemExitt   isabst   abspatht	   _pkgclasst	   _modclass(   R	   R   t   getsuffixest   loadcot	   possiblest   pyt   pyct   ptht   ispkgt   pkgptht   extt   modet   typt   attemptt   modtimet   cot   stufft   et   mod(    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR   C   sj    +

%		&"N(   R   R   R   R   R   t   marshalt   loadsR   (    (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR   <   s   	t   DirOwnerc           B   sG   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   sZ   | d k r t  j ƒ  } n  t  j j | ƒ sF t d t | ƒ ƒ ‚ n  t j |  | ƒ d  S(   Nt    s   %s is not a directory(   R   t   getcwdR   t   isdirR   t   reprR   R
   (   R	   R   (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR
   Ž   s
    c         C   s"   t  j j t  j j |  j | ƒ ƒ S(   N(   R   R   RE   R   (   R	   t   fn(    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR   •   s    c         C   s@   y' t  j t  j j |  j | ƒ ƒ d SWn t k
 r; d  SXd  S(   Ni   (   R   t   statR   R   t   OSErrorR   (   R	   RG   (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR   ˜   s    'c         C   s%   t  t j j |  j | ƒ d ƒ j ƒ  S(   Nt   rb(   t   openR   R   R   t   read(   R	   RG   (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR   ž   s    c         C   s
   t  j j S(   N(   R    R   t	   PkgModule(   R	   (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR-   ¡   s    c         C   s
   t  j j S(   N(   R    R   t   PyModule(   R	   (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR.   ¤   s    c         C   s   t  t j j |  j | ƒ ƒ S(   N(   R   R   R   R   (   R	   RG   (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR   §   s    (	   R   R   R
   R   R   R   R-   R.   R   (    (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyRB   Œ   s   						t   ZipOwnerc           B   sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   si  
    Load bytecode of Python modules from .egg files.

    zipimporter cannot be used here because it has a stupid bug:

      >>> z.find_module("setuptools.setuptools.setuptools.setuptools.setuptools") is not None
      True

    So mf will go into infinite recursion. Instead, we'll reuse
    the BaseDirOwner logic, simply changing the template methods.
    c         C   s]   d d  l  } y | j | d ƒ |  _ Wn! t k
 rH t d | ƒ ‚ n Xt j |  | ƒ d  S(   Niÿÿÿÿt   rs   %s is not a zipfile(   t   zipfilet   ZipFilet   zft   IOErrorR   R   R
   (   R	   R   RQ   (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR
   ·   s    c         C   s"   | j  d d ƒ } t j |  | ƒ S(   Nt   .t   /(   R&   R   R   (   R	   RG   (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR   ¿   s    c         C   sH   | j  d d ƒ } y |  j j | ƒ j } | SWn t k
 rC d  SXd  S(   Ns   \RV   (   R&   RS   t   getinfot	   date_timet   KeyErrorR   (   R	   RG   t   dt(    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR   Ã   s    c         C   s   t  S(   N(   t   True(   R	   RG   (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR   Ì   s    c         C   s   t  S(   N(   R[   (   R	   RG   (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR   Ñ   s    c         C   s"   | j  d d ƒ } |  j j | ƒ S(   Ns   \RV   (   R&   RS   RL   (   R	   RG   (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR   Ö   s    c            s   ‡  f d †  S(   Nc             s   t  j j ˆ  |  Œ S(   N(   R    R   t   PkgInZipModule(   t   args(   R	   (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyt   <lambda>Ü   s    (    (   R	   (    (   R	   sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR-   Û   s    c            s   ‡  f d †  S(   Nc             s   t  j j ˆ  |  Œ S(   N(   R    R   t   PyInZipModule(   R]   (   R	   (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR^   ß   s    (    (   R	   (    (   R	   sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR.   Þ   s    (   R   R   R   R
   R   R   R   R   R   R-   R.   (    (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyRO   «   s   								t   PYZOwnerc           B   s    e  Z d  Z d „  Z d „  Z RS(   s£  
    Class for loading bytecode of Python modules from PYZ files.

    PYZ file is internal PyInstaller format embedded into final executable.

    It is possible to have a custom .spec file which packs a subset of Python
    files into a PYZ file, and then drop it on the disk somewhere. When the PYZ
    file is added to sys.path, PYZOwner will parse it and make the modules
    within it available at import time.

    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&   t  j | ƒ |  _ t j |  | ƒ d  S(   N(   R   t   ZlibArchivet   pyzR   R
   (   R	   R   (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR
   ó   s    c         C   s]   |  j  j | ƒ } | s d  S| \ } } | rD t j j | | |  ƒ St j j | |  j | ƒ S(   N(   Rb   t   extractR   R    R   t   PkgInPYZModuleRN   R   (   R	   R   t   rsltR5   R<   (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR   ÷   s    (   R   R   R   R
   R   (    (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyR`   â   s   	(    (   R   R@   R   t   PyInstallerR    t   PyInstaller.compatR   R   t   PyInstaller.loaderR   t   PyInstaller.logt   logt   loggingt	   getLoggerR!   t	   ExceptionR   R   R   RB   RO   R`   (    (    (    sI   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/depend/owner.pyt   <module>   s   P7