Ñò
•èRc           @   sØ   d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k Z d d k l Z d d k l Z l	 Z	 l
 Z
 d d k l Z d d k l Z l Z l Z l Z e  i e ƒ Z e i d ƒ Z d Z d	 e f d
 „  ƒ  YZ d S(   iÿÿÿÿNi   (   t   DistlibException(   t	   sysconfigt   fsencodet   detect_encoding(   t   finder(   t   FileOperatort   get_export_entryt   convert_patht   get_executables   ^#!.*pythonw?[0-9.]*([ 	].*)?$se  %(shebang)s
if __name__ == '__main__':
    import sys, re

    def _resolve(module, func):
        __import__(module)
        mod = sys.modules[module]
        parts = func.split('.')
        result = getattr(mod, parts.pop(0))
        for p in parts:
            result = getattr(result, p)
        return result

    try:
        sys.argv[0] = re.sub('-script.pyw?$', '', sys.argv[0])

        func = _resolve('%(module)s', '%(func)s')
        rc = func() # None interpreted as 0
    except Exception as e:  # only supporting Python >= 2.6
        sys.stderr.write('%%s\n' %% e)
        rc = 1
    sys.exit(rc)
t   ScriptMakerc           B   s¯   e  Z d  Z e Z d Z e e d d „ Z	 d „  Z
 d d d „ Z d „  Z d „  Z d „  Z e d „  ƒ Z e i d	 „  ƒ Z e i d
 j o d „  Z n d „  Z d „  Z RS(   s_   
    A class to copy or create scripts from source scripts or callable
    specifications.
    c         C   sG   | |  _  | |  _ | |  _ t |  _ t |  _ | p
 t | ƒ |  _ d  S(   N(   t
   source_dirt
   target_dirt   add_launcherst   Falset   forcet   set_modeR   t   _fileop(   t   selfR
   R   R   t   dry_runt   fileop(    (    sV   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/scripts.pyt   __init__8   s    					c         C   sd   d | j oS t  i d j oC t  i i | ƒ \ } } | i d d ƒ } t  i i | | ƒ } n | S(   Nt   guit   ntt   pythont   pythonw(   t   ost   namet   patht   splitt   replacet   join(   R   t
   executablet   flagst   dnt   fn(    (    sV   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/scripts.pyt   _get_alternate_executableA   s
    t    c         C   s  |  i  o |  i  } n§ t i ƒ  p t ƒ  } n t t d ƒ oB t i t i j o/ t i	 i
 t i d ƒ d t i d ƒ ƒ } n; t i	 i
 t i d ƒ d t i d ƒ t i d ƒ f ƒ } | o |  i | | ƒ } n t | ƒ } d | | d	 } y | i d
 ƒ Wn# t j
 o t d | ƒ ‚ n X| d
 j oA y | i | ƒ Wq}t j
 o t d | | f ƒ ‚ q}Xn | S(   Nt   base_prefixt   scriptss   python%st   EXEt   BINDIRs
   python%s%st   VERSIONs   #!s   
s   utf-8s,   The shebang (%r) is not decodable from utf-8s?   The shebang (%r) is not decodable from the script encoding (%r)(   R   R   t   is_python_buildR   t   hasattrt   syst   prefixR%   R   R   R   t   get_patht   get_config_varR#   R   t   decodet   UnicodeDecodeErrort
   ValueError(   R   t   encodingt   post_interpR    R   t   shebang(    (    sV   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/scripts.pyt   _get_shebangH   s:    
#		c         C   s&   |  i  t d | d | i d | i ƒ S(   NR5   t   modulet   func(   t   script_templatet   dictR-   t   suffix(   R   R5   t   entry(    (    sV   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/scripts.pyt   _get_script_textq   s    	c   
      C   s=  |  i  d d | i ƒi d ƒ } |  i | | ƒ } t i i |  i | i ƒ } |  i	 o t i d j } | o\ d | } d | i j o d } |  i
 d ƒ }	 n d } |  i
 d	 ƒ }	 d
 | | f } n |  i i | | d ƒ |  i o |  i i | g ƒ n | i | ƒ | o$ |  i i | |	 ƒ | i | ƒ n d  S(   Ns   utf-8R    R   s   %s.exeR   t   pywt   wt   pyt   ts   %s-script.%s(   R6   R    R0   R=   R   R   R   R   R   R   t   _get_launcherR   t   write_text_fileR   t   set_executable_modet   appendt   write_binary_file(
   R   R<   t	   filenamesR5   t   scriptt   outnamet   use_launchert   exenamet   extt   launcher(    (    sV   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/scripts.pyt   _make_scriptv   s&    !

c         C   sê  t  } t | ƒ } t i i |  i t i i | ƒ ƒ } | i | ƒ t i i |  i | ƒ } |  i	 o, |  i
 i | | ƒ o t i d | ƒ d  Sy t | d ƒ } Wn* t j
 o |  i p ‚  n d  } n— Xt | i ƒ \ } } | i d ƒ | i ƒ  } | p t i d |  i ƒ  | ƒ d  St i | i d d ƒ ƒ }	 |	 o  t } |	 i d ƒ p d }
 n | p, | o | i ƒ  n |  i
 i | | ƒ n,t i d	 | |  i ƒ |  i
 i pó |  i | |
 ƒ } |  i  o t i! d
 j } | ou t i i" | ƒ \ } } | d } d | j o |  i# d ƒ } d } n |  i# d ƒ } d } | | } | | d <n |  i
 i$ | | | i% ƒ  ƒ | o$ |  i
 i$ | | ƒ | i | ƒ q°n | o | i ƒ  n |  i& o |  i
 i' | g ƒ n d  S(   Ns   not copying %s (up-to-date)t   rbi    s"   %s: %s is an empty file (skipping)s   
s   
i   R$   s   copying and adjusting %s -> %sR   s   .exeR   R?   s   -script.pywRA   s
   -script.pyiÿÿÿÿ((   R   R   R   R   R   R   t   basenameRE   R
   R   R   t   newert   loggert   debugt   opent   IOErrorR   t   NoneR   t   readlinet   seekt   warningt   get_command_namet   FIRST_LINE_REt   matchR   t   Truet   groupt   closet	   copy_filet   infoR6   R   R   t   splitextRB   RF   t   readR   RD   (   R   RH   RG   t   adjustRI   t   fR3   t   linest
   first_lineR\   R4   R5   RJ   t   nt   eRK   RM   R;   (    (    sV   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/scripts.pyt   _copy_scriptŒ   sh    $"
	




c         C   s
   |  i  i S(   N(   R   R   (   R   (    (    sV   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/scripts.pyR   Ë   s    c         C   s   | |  i  _ d  S(   N(   R   R   (   R   t   value(    (    sV   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/scripts.pyR   Ï   s    R   c         C   sR   t  i d ƒ d j o
 d } n d } d | | f } t d ƒ i | ƒ i } | S(   Nt   Pi   t   64t   32s   %s%s.exet   distlib(   t   structt   calcsizeR   t   findt   bytes(   R   t   kindt   bitsR   t   result(    (    sV   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/scripts.pyRB   ×   s    
c         C   sG   g  } t  | ƒ } | d j o |  i | | ƒ n |  i | | ƒ | S(   s„  
        Make a script.

        :param specification: The specification, which is either a valid export
                              entry specification (to make a script from a
                              callable) or a filename (to make a script by
                              copying from a source location).
        :return: A list of all absolute pathnames written to,
        N(   R   RV   Rj   RN   (   R   t   specificationRG   R<   (    (    sV   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/scripts.pyt   makeâ   s    
c         C   s1   g  } x$ | D] } | i  |  i | ƒ ƒ q W| S(   sÂ   
        Take a list of specifications and make scripts from them,
        :param specifications: A list of specifications.
        :return: A list of all absolute pathnames written to,
        (   t   extendRx   (   R   t   specificationsRG   Rw   (    (    sV   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/scripts.pyt   make_multipleô   s
     N(   t   __name__t
   __module__t   __doc__t   SCRIPT_TEMPLATER9   RV   R   R]   R   R   R#   R6   R=   RN   Rj   t   propertyR   t   setterR   R   RB   Rx   R{   (    (    (    sV   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/scripts.pyR	   /   s    	)			?	(   t   loggingR   t   reRp   R,   R$   R    t   compatR   R   R   t	   resourcesR   t   utilR   R   R   R   t	   getLoggerR|   RR   t   compileR[   R   t   objectR	   (    (    (    sV   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/scripts.pyt   <module>   s   "