
mKc        	   @   s   d  Z  d d k Z d d k Z d d k Z d d d g Z d d d d d d  Z d d d d d	  Z d
 d d d d  Z d   Z	 d   Z
 e d j o! e e
    Z e i e  n d S(   s  Module/script to "compile" all .py files to .pyc (or .pyo) file.

When called as a script with arguments, this compiles the directories
given as arguments recursively; the -l option prevents it from
recursing into directories.

Without arguments, if compiles all modules on sys.path, without
recursing into subdirectories.  (Even though it should do so for
packages -- for now, you'll have to deal with packages separately.)

See module py_compile for details of the actual byte-compilation.

iNt   compile_dirt   compile_filet   compile_pathi
   i    c         C   su  | p d G|  Gd GHn y t  i |   } Wn% t  i j
 o d G|  GHg  } n X| i   d } x| D]} t  i i |  |  }	 | d j	 o t  i i | |  }
 n d }
 t  i i |	  p' t |	 | | | |  p
 d } qmqj | d j ou | t  i	 j oe | t  i
 j oU t  i i |	  oB t  i i |	  o. t |	 | d |
 | | |  p
 d } qmqj qj W| S(   s  Byte-compile all modules in the given directory tree.

    Arguments (only dir is required):

    dir:       the directory to byte-compile
    maxlevels: maximum recursion level (default 10)
    ddir:      if given, purported directory name (this is the
               directory name that will show up in error messages)
    force:     if 1, force compilation, even if timestamps are up-to-date
    quiet:     if 1, be quiet during compilation

    t   Listings   ...s
   Can't listi   i    N(   t   ost   listdirt   errort   sortt   patht   joint   Nonet   isdirR   t   curdirt   pardirt   islinkR    (   t   dirt	   maxlevelst   ddirt   forcet   rxt   quiett   namest   successt   namet   fullnamet   dfile(    (    s    /usr/lib/python2.6/compileall.pyR       s2    	
   c         C   s  d } t  i i |   } | d
 j	 o t  i i | |  } n d
 } | d
 j	 o | i |   } | o | Sn t  i i |   oj| d  | d }	 }
 |
 d j oD|  t o d p d } t  i |   i	 } y t  i |  i	 } Wn t  i
 j
 o d } n X| | j o | o | S| p d G|  Gd GHn y t i |  d
 | t  } Wny t j
 o t  qt i j
 o/ } | o d G|  Gd GHn | i GHd } qt j
 o } d	 G| GHd } qX| d j o
 d } qqn | S(   s=  Byte-compile file.
    file:      the file to byte-compile
    ddir:      if given, purported directory name (this is the
               directory name that will show up in error messages)
    force:     if 1, force compilation, even if timestamps are up-to-date
    quiet:     if 1, be quiet during compilation

    i   is   .pyt   ct   oi    t	   Compilings   ...t   SorryN(   R   R   t   basenameR
   R	   t   searcht   isfilet	   __debug__t   statt   st_mtimeR   t
   py_compilet   compilet   Truet   KeyboardInterruptt   PyCompileErrort   msgt   IOError(   R   R   R   R   R   R   R   R   t   mot   headt   tailt   cfilet   ftimet   ctimet   okt   errt   e(    (    s    /usr/lib/python2.6/compileall.pyR   =   sJ    
	   

	i   c         C   sh   d } x[ t  i D]P } | p | t i j o |  o	 d GHq | o t | | d | d | } q W| S(   s  Byte-compile all module on sys.path.

    Arguments (all optional):

    skip_curdir: if true, skip current directory (default true)
    maxlevels:   max recursion level (default 0)
    force: as for compile_dir() (default 0)
    quiet: as for compile_dir() (default 0)

    i   s   Skipping current directoryR   N(   t   sysR   R   R   R    R
   (   t   skip_curdirR   R   R   R   R   (    (    s    /usr/lib/python2.6/compileall.pyR   l   s    
 	c         C   s   |  } | o yY | d j o t  i } n t |  } x, | i   } | p Pn | i | d   q: Wq t j
 o d | GH  q Xn | S(   s&   read names in flist and append to argst   -is   Error reading file list %s(   R4   t   stdint   opent   readlinet   appendR*   (   t   argst   flistt   expandedt   fdt   line(    (    s    /usr/lib/python2.6/compileall.pyt   expand_args   s    	c          C   s  d d k  }  y# |  i  t i d d  \ } } WnW |  i j
 oH } | GHd GHd GHd GHd GHd	 GHd
 GHd GHd GHd GHt i d  n Xd } d } d } d } d } d }	 x | D] \ }
 } |
 d j o
 d } n |
 d j o
 | } n |
 d j o
 d } n |
 d j o
 d } n |
 d j o d d k } | i |  } n |
 d j o
 | }	 q q W| oE t |  d j o. t	 i
 i | d  o d GHt i d  qn d } y | p |	 o y |	 o t | |	  } n Wn t j
 o d } n X| ou xr | D]f } t	 i
 i |  o* t | | | | | |  p
 d } qtqt | | | | |  p
 d } qqWqn
 t   } Wn t j
 o d GHd } n X| S(   s   Script main program.iNi   s	   lfqd:x:i:sb   usage: python compileall.py [-l] [-f] [-q] [-d destdir] [-x regexp] [-i list] [directory|file ...]s   -l: don't recurse downs3   -f: force rebuild even if timestamps are up-to-dates   -q: quiet operations7   -d destdir: purported directory name for error messagess4      if no directory arguments, -l sys.path is assumeds<   -x regexp: skip files matching the regular expression regexps:      the regexp is searched for in the full path of the files@   -i list: expand list with its content (file and directory names)i   i
   i    s   -ls   -ds   -fs   -qs   -xs   -is1   -d destdir require exactly one directory arguments   
[interrupt](   t   getoptR4   t   argvR   t   exitR
   t   reR%   t   lenR   R   R   R@   R*   R    R   R   R'   (   RA   t   optsR;   R)   R   R   R   R   R   R<   R   t   aRD   R   t   arg(    (    s    /usr/lib/python2.6/compileall.pyt   main   s|    #  
 
 
 
 + t   __main__(   t   __doc__R   R4   R$   t   __all__R
   R    R   R   R@   RI   t   __name__t   intt   exit_statusRC   (    (    (    s    /usr/lib/python2.6/compileall.pyt   <module>   s   '/		=