ó
^\kdc           @   sð   d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d d l m Z m	 Z	 m
 Z
 m Z d d l m Z d d l m Z m Z m Z m Z m Z e j e ƒ Z d j ƒ  Z e j d ƒ Z d	 Z d
 e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   BytesIONi   (   t	   sysconfigt   fsencodet   detect_encodingt   ZipFile(   t   finder(   t   FileOperatort   get_export_entryt   convert_patht   get_executablet   in_venvsñ  
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
 <assemblyIdentity version="1.0.0.0"
 processorArchitecture="X86"
 name="%s"
 type="win32"/>

 <!-- Identify the application security requirements. -->
 <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
 <security>
 <requestedPrivileges>
 <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
 </requestedPrivileges>
 </security>
 </trustInfo>
</assembly>s   ^#!.*pythonw?[0-9.]*([ 	].*)?$s{  # -*- coding: utf-8 -*-
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(r'(-script\.pyw|\.exe)?$', '', 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 e Z d „  Z d „  Z d d „ Z d	 „  Z e d
 „  ƒ Z e j d „  ƒ Z e j d k r´ d „  Z n  d d „ Z d d „ Z RS(   s_   
    A class to copy or create scripts from source scripts or callable
    specifications.
    c         C   sg   | |  _  | |  _ | |  _ t |  _ t |  _ t j d k |  _ t	 d ƒ |  _
 | p] t | ƒ |  _ d  S(   Nt   posixt    s   X.Y(   R   s   X.Y(   t
   source_dirt
   target_dirt   add_launcherst   Falset   forcet   clobbert   ost   namet   set_modet   sett   variantsR   t   _fileop(   t   selfR   R   R   t   dry_runt   fileop(    (    sB   /var/www/testScraper/venv/build/pip/pip/_vendor/distlib/scripts.pyt   __init__K   s    					c         C   sg   | j  d t ƒ rc t j d k rc t j j | ƒ \ } } | j d d ƒ } t j j | | ƒ } n  | S(   Nt   guit   ntt   pythont   pythonw(   t   getR   R   R   t   patht   splitt   replacet   join(   R   t
   executablet   optionst   dnt   fn(    (    sB   /var/www/testScraper/venv/build/pip/pip/_vendor/distlib/scripts.pyt   _get_alternate_executableW   s
    !R   c         C   sZ  |  j  r |  j  } n‰ t j ƒ  s- t ƒ  } nq t ƒ  rd t j j t j d ƒ d t j	 d ƒ ƒ } n: t j j t j	 d ƒ d t j	 d ƒ t j	 d ƒ f ƒ } | r¹ |  j
 | | ƒ } n  t | ƒ } d | | d } y | j d	 ƒ Wn! t k
 rt d
 | ƒ ‚ n X| d	 k rVy | j | ƒ WqVt k
 rRt d | | f ƒ ‚ qVXn  | S(   Nt   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	   R
   R   R#   R&   t   get_patht   get_config_varR+   R   t   decodet   UnicodeDecodeErrort
   ValueError(   R   t   encodingt   post_interpR(   R'   t   shebang(    (    sB   /var/www/testScraper/venv/build/pip/pip/_vendor/distlib/scripts.pyt   _get_shebang^   s8    			c         C   s    |  j  t d | j d | j ƒ S(   Nt   modulet   func(   t   script_templatet   dictt   prefixt   suffix(   R   t   entry(    (    sB   /var/www/testScraper/venv/build/pip/pip/_vendor/distlib/scripts.pyt   _get_script_text†   s    c         C   s   t  j j | ƒ } |  j | S(   N(   R   R#   t   basenamet   manifest(   R   t   exenamet   base(    (    sB   /var/www/testScraper/venv/build/pip/pip/_vendor/distlib/scripts.pyt   get_manifestŒ   s    c         C   s�  |  j  o t j d k } t j j d ƒ } | sA | | | } n| | d k r_ |  j d ƒ } n |  j d ƒ } t ƒ  }	 t |	 d ƒ � }
 |
 j d | ƒ Wd  QX|	 j	 ƒ  } | | | | } xÉ| D]Á} t j
 j |  j | ƒ } | rÞt j
 j | ƒ \ } } | j d ƒ r| } n  d | } y |  j j | | ƒ Wqxt k
 rÚt j d	 ƒ d
 | } t j
 j | ƒ r‚t j | ƒ n  t j | | ƒ |  j j | | ƒ t j d ƒ y t j | ƒ WqÛt k
 rÖqÛXqxXnš t j d k r| j d | ƒ rd | | f } n  t j
 j | ƒ rF|  j rFt j d | ƒ qÄ n  |  j j | | ƒ |  j rx|  j j | g ƒ n  | j | ƒ qÄ Wd  S(   NR   s   utf-8t   pyt   tt   ws   __main__.pys   .pys   %s.exes:   Failed to write executable - trying to use .deleteme logics   %s.deletemes0   Able to replace executable using .deleteme logict   .s   %s.%ss   Skipping existing file %s(   R   R   R   t   linesept   encodet   _get_launcherR    R   t   writestrt   getvalueR#   R&   R   t   splitextt
   startswithR   t   write_binary_filet	   Exceptiont   loggert   warningt   existst   removet   renamet   debugt   endswithR   R   t   set_executable_modet   append(   R   t   namesR8   t   script_bytest	   filenamest   extt   use_launcherRK   t   launchert   streamt   zft   zip_dataR   t   outnamet   nt   et   dfname(    (    sB   /var/www/testScraper/venv/build/pip/pip/_vendor/distlib/scripts.pyt   _write_script�   sT    		

#	c   	      C   s  |  j  d d | ƒ} |  j | ƒ j d ƒ } | j } t ƒ  } d |  j k r^ | j | ƒ n  d |  j k rŽ | j d | t j d f ƒ n  d |  j k r¾ | j d | t j d	  f ƒ n  | rß | j	 d
 t
 ƒ rß d } n d } |  j | | | | | ƒ d  S(   Ns   utf-8R(   R   t   Xs   %s%si    s   X.Ys   %s-%si   R   t   pywRG   (   R9   RA   RL   R   R   R   t   addt   syst   versionR"   R   Rj   (	   R   R@   R_   R(   R8   t   scriptR   t   scriptnamesR`   (    (    sB   /var/www/testScraper/venv/build/pip/pip/_vendor/distlib/scripts.pyt   _make_scriptÂ   s    		!!	c         C   s@  t  } t j j |  j t | ƒ ƒ } t j j |  j t j j | ƒ ƒ } |  j r| |  j	 j
 | | ƒ r| t j d | ƒ d  Sy t | d ƒ } Wn& t k
 r· |  j s® ‚  n  d  } n‘ Xt | j ƒ \ } } | j d ƒ | j ƒ  } | s	t j d |  j ƒ  | ƒ d  St j | j d d ƒ ƒ }	 |	 rHt } |	 j d ƒ pBd }
 n  | s£| ra| j ƒ  n  |  j	 j | | ƒ |  j r“|  j	 j | g ƒ n  | j | ƒ n™ t j  d	 | |  j ƒ |  j	 j s)|  j! | |
 ƒ } d
 | k rìd } n d } t j j | ƒ } |  j" | g | | j# ƒ  | | ƒ n  | r<| j ƒ  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!   Rl   RG   ($   R   R   R#   R&   R   R   R   RB   R   R   t   newerRT   RY   t   opent   IOErrorR   t   NoneR   t   readlinet   seekRU   t   get_command_namet   FIRST_LINE_REt   matchR%   t   Truet   groupt   closet	   copy_fileR   R[   R\   t   infoR9   Rj   t   read(   R   Rp   R_   t   adjustRf   t   fR6   t   linest
   first_lineR|   R7   R8   R`   Rg   (    (    sB   /var/www/testScraper/venv/build/pip/pip/_vendor/distlib/scripts.pyt   _copy_scriptÓ   sR    $ 	
		
	%c         C   s
   |  j  j S(   N(   R   R   (   R   (    (    sB   /var/www/testScraper/venv/build/pip/pip/_vendor/distlib/scripts.pyR     s    c         C   s   | |  j  _ d  S(   N(   R   R   (   R   t   value(    (    sB   /var/www/testScraper/venv/build/pip/pip/_vendor/distlib/scripts.pyR     s    R   c         C   sf   t  j d ƒ d k r d } n d } d | | f } t j d d ƒ d } t | ƒ j | ƒ j } | S(	   Nt   Pi   t   64t   32s   %s%s.exeRJ   i   i    (   t   structt   calcsizet   __name__t   rsplitR   t   findt   bytes(   R   t   kindt   bitsR   t   distlib_packaget   result(    (    sB   /var/www/testScraper/venv/build/pip/pip/_vendor/distlib/scripts.pyRM     s    	c         C   sK   g  } t  | ƒ } | d k r1 |  j | | ƒ n |  j | | d | ƒ| 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).
        :param options: A dictionary of options controlling script generation.
        :return: A list of all absolute pathnames written to.
        R(   N(   R   Rw   R‡   Rr   (   R   t   specificationR(   R_   R@   (    (    sB   /var/www/testScraper/venv/build/pip/pip/_vendor/distlib/scripts.pyt   make!  s    c         C   s4   g  } x' | D] } | j  |  j | | ƒ ƒ 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   extendR—   (   R   t   specificationsR(   R_   R–   (    (    sB   /var/www/testScraper/venv/build/pip/pip/_vendor/distlib/scripts.pyt   make_multiple4  s    N(   RŽ   t
   __module__t   __doc__t   SCRIPT_TEMPLATER<   Rw   R'   R}   R   R   R+   R9   RA   t   _DEFAULT_MANIFESTRC   RF   Rj   Rr   R‡   t   propertyR   t   setterR   R   RM   R—   Rš   (    (    (    sB   /var/www/testScraper/venv/build/pip/pip/_vendor/distlib/scripts.pyR   B   s&   	(			2	4(   t   ioR    t   loggingR   t   reRŒ   Rn   t   compatR   R   R   R   t	   resourcesR   t   utilR   R   R   R	   R
   t	   getLoggerRŽ   RT   t   stripRž   t   compileR{   R�   t   objectR   (    (    (    sB   /var/www/testScraper/venv/build/pip/pip/_vendor/distlib/scripts.pyt   <module>   s   "(