
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
ó
•�abc           @   s  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z y d  d l m Z Wn! e k
 r d  d l	 m Z n Xd d l
 m Z d d l m Z m Z m Z m Z m Z m Z d d l m Z m Z m Z e j e ƒ Z d Z d Z d	 e f d
 „  ƒ  YZ d S(   iÿÿÿÿN(   t   Threadi   (   t   DistlibException(   t   HTTPBasicAuthHandlert   Requestt   HTTPPasswordMgrt   urlparset   build_openert   string_types(   t   cached_propertyt   zip_dirt   ServerProxys   https://pypi.python.org/pypit   pypit   PackageIndexc           B   sà   e  Z d  Z d Z d d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d d	 „ Z d d
 „ Z d d „ Z d d d d d d „ Z d „  Z d d „ Z d d „ Z d d d „ Z d „  Z d „  Z d d „ Z RS(   sc   
    This class represents a package index compatible with PyPI, the Python
    Package Index.
    s.   ----------ThIs_Is_tHe_distlib_index_bouNdaRY_$c         C   s  | p	 t  |  _ |  j ƒ  t |  j ƒ \ } } } } } } | sX | sX | sX | d k rn t d |  j ƒ ‚ n  d |  _ d |  _ d |  _ d |  _	 d |  _
 t t j d ƒ �j } x` d D]X }	 y> t j |	 d g d | d	 | ƒ}
 |
 d
 k rú |	 |  _ Pn  Wq· t k
 rq· Xq· WWd QXd S(   s”   
        Initialise an instance.

        :param url: The URL of the index. If not specified, the URL for PyPI is
                    used.
        t   httpt   httpss   invalid repository: %st   wt   gpgt   gpg2s	   --versiont   stdoutt   stderri    N(   R   R   (   R   R   (   t   DEFAULT_INDEXt   urlt   read_configurationR   R   t   Nonet   password_handlert   ssl_verifierR   t   gpg_homet	   rpc_proxyt   opent   ost   devnullt
   subprocesst
   check_callt   OSError(   t   selfR   t   schemet   netloct   patht   paramst   queryt   fragt   sinkt   st   rc(    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyt   __init__$   s(    
!							c         C   s3   d d l  m } d d l m } | ƒ  } | | ƒ S(   ss   
        Get the distutils command for interacting with PyPI configurations.
        :return: the command.
        iÿÿÿÿ(   t   Distribution(   t   PyPIRCCommand(   t   distutils.coreR-   t   distutils.configR.   (   R"   R-   R.   t   d(    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyt   _get_pypirc_commandB   s    	c         C   sy   |  j  ƒ  } |  j | _ | j ƒ  } | j d ƒ |  _ | j d ƒ |  _ | j d d ƒ |  _ | j d |  j ƒ |  _ d S(   sç   
        Read the PyPI access configuration as supported by distutils, getting
        PyPI to do the actual work. This populates ``username``, ``password``,
        ``realm`` and ``url`` attributes from the configuration.
        t   usernamet   passwordt   realmR   t
   repositoryN(   R2   R   R6   t   _read_pypirct   getR3   R4   R5   (   R"   t   ct   cfg(    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyR   L   s    c         C   s0   |  j  ƒ  |  j ƒ  } | j |  j |  j ƒ d S(   sÍ   
        Save the PyPI access configuration. You must have set ``username`` and
        ``password`` attributes before calling this method.

        Again, distutils is used to do the actual work.
        N(   t   check_credentialsR2   t   _store_pypircR3   R4   (   R"   R9   (    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyt   save_configuration[   s    
c         C   s‰   |  j  d k s |  j d k r- t d ƒ ‚ n  t ƒ  } t |  j ƒ \ } } } } } } | j |  j | |  j  |  j ƒ t	 | ƒ |  _
 d S(   sp   
        Check that ``username`` and ``password`` have been set, and raise an
        exception if not.
        s!   username and password must be setN(   R3   R   R4   R   R   R   R   t   add_passwordR5   R   R   (   R"   t   pmt   _R$   (    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyR;   g   s    	!c         C   s€   |  j  ƒ  | j ƒ  | j ƒ  } d | d <|  j | j ƒ  g  ƒ } |  j | ƒ } d | d <|  j | j ƒ  g  ƒ } |  j | ƒ S(   sq  
        Register a distribution on PyPI, using the provided metadata.

        :param metadata: A :class:`Metadata` instance defining at least a name
                         and version number for the distribution to be
                         registered.
        :return: The HTTP response received from PyPI upon submission of the
                request.
        t   verifys   :actiont   submit(   R;   t   validatet   todictt   encode_requestt   itemst   send_request(   R"   t   metadataR1   t   requestt   response(    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyt   registers   s    




c         C   sj   xY t  r[ | j ƒ  } | s Pn  | j d ƒ j ƒ  } | j | ƒ t j d | | f ƒ q W| j ƒ  d S(   sr  
        Thread runner for reading lines of from a subprocess into a buffer.

        :param name: The logical name of the stream (used for logging only).
        :param stream: The stream to read from. This will typically a pipe
                       connected to the output stream of a subprocess.
        :param outbuf: The list to append the read lines to.
        s   utf-8s   %s: %sN(   t   Truet   readlinet   decodet   rstript   appendt   loggert   debugt   close(   R"   t   namet   streamt   outbufR*   (    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyt   _reader‡   s    		c         C   sä   |  j  d d d g } | d k r- |  j } n  | rI | j d | g ƒ n  | d k	 rn | j d d d g ƒ n  t j ƒ  } t j j | t j j	 | ƒ d ƒ } | j d	 d
 d | d | | g ƒ t
 j d d j | ƒ ƒ | | f S(   s‰  
        Return a suitable command for signing a file.

        :param filename: The pathname to the file to be signed.
        :param signer: The identifier of the signer of the file.
        :param sign_password: The passphrase for the signer's
                              private key used for signing.
        :param keystore: The path to a directory which contains the keys
                         used in verification. If not specified, the
                         instance's ``gpg_home`` attribute is used instead.
        :return: The signing command as a list suitable to be
                 passed to :class:`subprocess.Popen`.
        s   --status-fdt   2s   --no-ttys	   --homedirs   --batchs   --passphrase-fdt   0s   .ascs   --detach-signs   --armors   --local-users   --outputs   invoking: %st    N(   R   R   R   t   extendt   tempfilet   mkdtempR   R%   t   joint   basenameRQ   RR   (   R"   t   filenamet   signert   sign_passwordt   keystoret   cmdt   tdt   sf(    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyt   get_sign_command™   s    %c   	      C   s
  i t  j d 6t  j d 6} | d k	 r6 t  j | d <n  g  } g  } t  j | | � } t d |  j d d | j | f ƒ } | j ƒ  t d |  j d d | j | f ƒ } | j ƒ  | d k	 rÜ | j	 j
 | ƒ | j	 j ƒ  n  | j ƒ  | j ƒ  | j ƒ  | j | | f S(   sæ  
        Run a command in a child process , passing it any input data specified.

        :param cmd: The command to run.
        :param input_data: If specified, this must be a byte string containing
                           data to be sent to the child process.
        :return: A tuple consisting of the subprocess' exit code, a list of
                 lines read from the subprocess' ``stdout``, and a list of
                 lines read from the subprocess' ``stderr``.
        R   R   t   stdint   targett   argsN(   R   t   PIPER   t   PopenR    RW   R   t   startR   Rh   t   writeRS   t   waitR^   t
   returncode(	   R"   Rd   t
   input_datat   kwargsR   R   t   pt   t1t   t2(    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyt   run_command¶   s&    
$
$



c   
      C   se   |  j  | | | | ƒ \ } } |  j | | j d ƒ ƒ \ } } }	 | d k ra t d | ƒ ‚ n  | S(   sR  
        Sign a file.

        :param filename: The pathname to the file to be signed.
        :param signer: The identifier of the signer of the file.
        :param sign_password: The passphrase for the signer's
                              private key used for signing.
        :param keystore: The path to a directory which contains the keys
                         used in signing. If not specified, the instance's
                         ``gpg_home`` attribute is used instead.
        :return: The absolute pathname of the file where the signature is
                 stored.
        s   utf-8i    s&   sign command failed with error code %s(   Rg   Rv   t   encodeR   (
   R"   R`   Ra   Rb   Rc   Rd   t   sig_fileR+   R   R   (    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyt	   sign_fileÙ   s    	t   sdistt   sourcec         C   sµ  |  j  ƒ  t j j | ƒ s/ t d | ƒ ‚ n  | j ƒ  | j ƒ  } d }	 | r… |  j sj t	 j
 d ƒ q… |  j | | | | ƒ }	 n  t | d ƒ � }
 |
 j ƒ  } Wd QXt j | ƒ j ƒ  } t j | ƒ j ƒ  } | j i d d 6d d 6| d	 6| d
 6| d 6| d 6ƒ d t j j | ƒ | f g } |	 r�t |	 d ƒ � }
 |
 j ƒ  } Wd QX| j d t j j |	 ƒ | f ƒ t j t j j |	 ƒ ƒ n  |  j | j ƒ  | ƒ } |  j | ƒ S(   s´  
        Upload a release file to the index.

        :param metadata: A :class:`Metadata` instance defining at least a name
                         and version number for the file to be uploaded.
        :param filename: The pathname of the file to be uploaded.
        :param signer: The identifier of the signer of the file.
        :param sign_password: The passphrase for the signer's
                              private key used for signing.
        :param filetype: The type of the file being uploaded. This is the
                        distutils command which produced that file, e.g.
                        ``sdist`` or ``bdist_wheel``.
        :param pyversion: The version of Python which the release relates
                          to. For code compatible with any Python, this would
                          be ``source``, otherwise it would be e.g. ``3.2``.
        :param keystore: The path to a directory which contains the keys
                         used in signing. If not specified, the instance's
                         ``gpg_home`` attribute is used instead.
        :return: The HTTP response received from PyPI upon submission of the
                request.
        s   not found: %ss)   no signing program available - not signedt   rbNt   file_uploads   :actiont   1t   protocol_versiont   filetypet	   pyversiont
   md5_digestt   sha256_digestt   contentt   gpg_signature(   R;   R   R%   t   existsR   RC   RD   R   R   RQ   t   warningRy   R   t   readt   hashlibt   md5t	   hexdigestt   sha256t   updateR_   RP   t   shutilt   rmtreet   dirnameRE   RF   RG   (   R"   RH   R`   Ra   Rb   R€   R�   Rc   R1   Rx   t   ft	   file_dataR‚   Rƒ   t   filest   sig_dataRI   (    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyt   upload_fileð   s>    

		
c   
      C   sä   |  j  ƒ  t j j | ƒ s/ t d | ƒ ‚ n  t j j | d ƒ } t j j | ƒ si t d | ƒ ‚ n  | j ƒ  | j | j	 } } t
 | ƒ j ƒ  } d	 d | f d | f g } d | | f g } |  j | | ƒ }	 |  j |	 ƒ S(
   s2  
        Upload documentation to the index.

        :param metadata: A :class:`Metadata` instance defining at least a name
                         and version number for the documentation to be
                         uploaded.
        :param doc_dir: The pathname of the directory which contains the
                        documentation. This should be the directory that
                        contains the ``index.html`` for the documentation.
        :return: The HTTP response received from PyPI upon submission of the
                request.
        s   not a directory: %rs
   index.htmls   not found: %rs   :actiont
   doc_uploadRT   t   versionR„   (   s   :actionR–   (   R;   R   R%   t   isdirR   R^   R†   RC   RT   R—   R	   t   getvalueRE   RG   (
   R"   RH   t   doc_dirt   fnRT   R—   t   zip_datat   fieldsR“   RI   (    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyt   upload_documentation)  s    

c         C   s|   |  j  d d d g } | d k r- |  j } n  | rI | j d | g ƒ n  | j d | | g ƒ t j d d j | ƒ ƒ | S(	   s|  
        Return a suitable command for verifying a file.

        :param signature_filename: The pathname to the file containing the
                                   signature.
        :param data_filename: The pathname to the file containing the
                              signed data.
        :param keystore: The path to a directory which contains the keys
                         used in verification. If not specified, the
                         instance's ``gpg_home`` attribute is used instead.
        :return: The verifying command as a list suitable to be
                 passed to :class:`subprocess.Popen`.
        s   --status-fdRX   s   --no-ttys	   --homedirs   --verifys   invoking: %sRZ   N(   R   R   R   R[   RQ   RR   R^   (   R"   t   signature_filenamet   data_filenameRc   Rd   (    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyt   get_verify_commandE  s    c         C   sn   |  j  s t d ƒ ‚ n  |  j | | | ƒ } |  j | ƒ \ } } } | d k rd t d | ƒ ‚ n  | d k S(   s6  
        Verify a signature for a file.

        :param signature_filename: The pathname to the file containing the
                                   signature.
        :param data_filename: The pathname to the file containing the
                              signed data.
        :param keystore: The path to a directory which contains the keys
                         used in verification. If not specified, the
                         instance's ``gpg_home`` attribute is used instead.
        :return: True if the signature was verified, else False.
        s0   verification unavailable because gpg unavailablei    i   s(   verify command failed with error code %s(   i    i   (   R   R   R¡   Rv   (   R"   RŸ   R    Rc   Rd   R+   R   R   (    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyt   verify_signature]  s    		c         C   s  | d k r" d } t j d ƒ nM t | t t f ƒ rF | \ } } n d } t t | ƒ ƒ  } t j d | ƒ t | d ƒ �} |  j	 t
 | ƒ ƒ } zÜ | j ƒ  }	 d }
 d } d } d } d |	 k rÜ t |	 d	 ƒ } n  | rõ | | |
 | ƒ n  xy t rp| j |
 ƒ } | sPn  | t | ƒ 7} | j | ƒ | rJ| j | ƒ n  | d
 7} | rø | | |
 | ƒ qø qø WWd | j ƒ  XWd QX| d k r·| | k  r·t d | | f ƒ ‚ n  | r| j ƒ  } | | k rôt d | | | | f ƒ ‚ n  t j d | ƒ n  d S(   s  
        This is a convenience method for downloading a file from an URL.
        Normally, this will be a file from the index, though currently
        no check is made for this (i.e. a file can be downloaded from
        anywhere).

        The method is just like the :func:`urlretrieve` function in the
        standard library, except that it allows digest computation to be
        done during download and checking that the downloaded data
        matched any expected value.

        :param url: The URL of the file to be downloaded (assumed to be
                    available via an HTTP GET request).
        :param destfile: The pathname where the downloaded file is to be
                         saved.
        :param digest: If specified, this must be a (hasher, value)
                       tuple, where hasher is the algorithm used (e.g.
                       ``'md5'``) and ``value`` is the expected value.
        :param reporthook: The same as for :func:`urlretrieve` in the
                           standard library.
        s   No digest specifiedRŠ   s   Digest specified: %st   wbi    iÿÿÿÿi    s   content-lengths   Content-Lengthi   Ns1   retrieval incomplete: got only %d out of %d bytess.   %s digest mismatch for %s: expected %s, got %ss   Digest verified: %s(   R   RQ   RR   t
   isinstancet   listt   tuplet   getattrR‰   R   RG   R   t   infot   intRL   Rˆ   t   lenRn   R�   RS   R   R‹   (   R"   R   t   destfilet   digestt
   reporthookt   digestert   hashert   dfpt   sfpt   headerst	   blocksizet   sizeRˆ   t   blocknumt   blockt   actual(    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyt   download_filev  sV    	
c         C   sW   g  } |  j  r" | j |  j  ƒ n  |  j r> | j |  j ƒ n  t | Œ  } | j | ƒ S(   sÝ   
        Send a standard library :class:`Request` to PyPI and return its
        response.

        :param req: The request to send.
        :return: The HTTP response from PyPI (a standard library HTTPResponse).
        (   R   RP   R   R   R   (   R"   t   reqt   handlerst   opener(    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyRG   Ã  s    		c         C   s<  g  } |  j  } xy | D]q \ } } t | t t f ƒ sC | g } n  xA | D]9 } | j d | d | j d ƒ d | j d ƒ f ƒ qJ Wq WxG | D]? \ } }	 }
 | j d | d | |	 f j d ƒ d |
 f ƒ q’ W| j d | d d f ƒ d j | ƒ } d | } i | d 6t t | ƒ ƒ d	 6} t	 |  j
 | | ƒ S(
   s&  
        Encode fields and files for posting to an HTTP server.

        :param fields: The fields to send as a list of (fieldname, value)
                       tuples.
        :param files: The files to send as a list of (fieldname, filename,
                      file_bytes) tuple.
        s   --s)   Content-Disposition: form-data; name="%s"s   utf-8t    s8   Content-Disposition: form-data; name="%s"; filename="%s"s   
s   multipart/form-data; boundary=s   Content-types   Content-length(   t   boundaryR¤   R¥   R¦   R[   Rw   R^   t   strRª   R   R   (   R"   R�   R“   t   partsR½   t   kt   valuest   vt   keyR`   t   valuet   bodyt   ctR²   (    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyRE   Ó  s4    	
c         C   sb   t  | t ƒ r i | d 6} n  |  j d  k rI t |  j d d ƒ|  _ n  |  j j | | p^ d ƒ S(   NRT   t   timeoutg      @t   and(   R¤   R   R   R   R
   R   t   search(   R"   t   termst   operator(    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyRÉ   þ  s
    N(   t   __name__t
   __module__t   __doc__R½   R   R,   R2   R   R=   R;   RK   RW   Rg   Rv   Ry   R•   Rž   R¡   R¢   R¸   RG   RE   RÉ   (    (    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyR      s*   	
					#8	M		+(   R‰   t   loggingR   RŽ   R   R\   t	   threadingR    t   ImportErrort   dummy_threadingR¼   R   t   compatR   R   R   R   R   R   t   utilR   R	   R
   t	   getLoggerRÌ   RQ   R   t   DEFAULT_REALMt   objectR   (    (    (    s=   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/index.pyt   <module>   s    .