ó
©¶"Pc           @   s   d  Z  d d l Z d d l Z d d l m Z d d l m Z e j e	 ƒ Z
 d „  Z d „  Z d d „ Z d „  Z d	 „  Z d S(
   sP   
This module is for the miscellaneous routines which do not fit somewhere else.
iÿÿÿÿN(   t   log(   t   is_winc         C   s@   g  } x3 t  j |  ƒ D]" \ } } } | j t | ƒ ƒ q Wd S(   sE   Returns *.dll, *.so, *.dylib in given directories and subdirectories.N(   t   ost   walkt   extendt   dlls_in_dir(   t	   directoryt   filest   roott   dirs(    (    sG   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/utils/misc.pyt   dlls_in_subdirs    s    c         C   sy   g  } | j  t j t j j |  d ƒ ƒ ƒ | j  t j t j j |  d ƒ ƒ ƒ | j  t j t j j |  d ƒ ƒ ƒ | S(   s0   Returns *.dll, *.so, *.dylib in given directory.s   *.sos   *.dlls   *.dylib(   R   t   globR   t   patht   join(   R   R   (    (    sG   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/utils/misc.pyR   '   s
    %%%c   
      C   s2  | d k r t j d } n  | j t j ƒ } d g } t r½ t j j |  ƒ \ } } | sh |  d }  n  t j d j ƒ  j t j ƒ } t j j |  ƒ \ } } | j ƒ  | k r½ | } q½ n  xn | D]b } |  | } t j j	 | ƒ rê | Sx9 | D]1 } t j j
 | | ƒ }	 t j j	 |	 ƒ rñ |	 Sqñ WqÄ Wd Sd S(   s  
    Try to find 'executable' in the directories listed in 'path' (a
    string listing directories separated by 'os.pathsep'; defaults to
    os.environ['PATH']).

    Returns the complete filename or None if not found.

    Code from http://snippets.dzone.com/posts/show/6313
    t   PATHt    s   .exet   PATHEXTN(   t   NoneR   t   environt   splitt   pathsepR   R   t   splitextt   lowert   isfileR   (
   t
   executableR   t   pathst   extlistt   baset   extt   pathextt   execnamet   pt   f(    (    sG   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/utils/misc.pyt   find_executable0   s*    
	
c          C   sL   g  }  y. d d l  } d g }  d d l } d g }  Wn t k
 rG n X|  S(   s^   
    Try importing codecs and encodings to include unicode support
    in created binary.
    iÿÿÿÿNt   codecst	   encodings(   R"   R#   t   ImportError(   t   modulesR"   R#   (    (    sG   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/utils/misc.pyt   get_unicode_modulesW   s    	c         C   sf   y3 t  |  d ƒ j ƒ  d } t | |  d ƒ } | SWn, t k
 ra } t j | ƒ t d ƒ ‚ n Xd S(   sE   
    Convert source code from Python source file to code object.
    t   rUs   
t   execi
   N(   t   opent   readt   compilet   SyntaxErrort   loggert	   exceptiont
   SystemExit(   t   filenamet   source_code_stringt   code_objectt   e(    (    sG   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/utils/misc.pyt   get_code_objecth   s    (   t   __doc__R   R   t   PyInstallerR    t   loggingt   PyInstaller.compatR   t	   getLoggert   __name__R-   R
   R   R   R!   R&   R4   (    (    (    sG   /home/salopaasi/Documents/Moo/pyinstaller-2.0/PyInstaller/utils/misc.pyt   <module>   s   			'	