ž 7’ReLc @sddlZddlZddlZddlZddlZddlZyddlmZWn"ek r€ddl mZYnXddl m Z ddl m Z mZmZmZmZmZddlmZmZmZejeƒZdZdZGd d „d eƒZdS( iN(uThreadi(uDistlibException(uHTTPBasicAuthHandleruRequestuHTTPPasswordMgruurlparseu build_openeru string_types(ucached_propertyuzip_diru ServerProxyuhttps://pypi.python.org/pypiupypicBs|EeZdZdZdZd)dd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z d)dd„Zdd„Zd)d)dddd„Zdd„Zdd„Zdd „Zd)d)d!d"„Zd#d$„Zd%d&„Zd)d'd(„Zd)S(*u PackageIndexuc This class represents a package index compatible with PyPI, the Python Package Index. s.----------ThIs_Is_tHe_distlib_index_bouNdaRY_$c Cs|p t|_|jƒt|jƒ\}}}}}}|sX|sX|sX|d krntd|jƒ‚nd |_d |_d |_d |_ d |_ t t j dƒk}xad D]Y} y>tj| dgd|d |ƒ} | d krú| |_PnWq·tk rYq·Xq·WWd QXd S(u” Initialise an instance. :param url: The URL of the index. If not specified, the URL for PyPI is used. uhttpuhttpsuinvalid repository: %suwugpg2ugpgu --versionustdoutustderriN(uhttpuhttps(ugpg2ugpg(u DEFAULT_INDEXuurluread_configurationuurlparseuDistlibExceptionuNoneupassword_handleru ssl_verifierugpgugpg_homeu rpc_proxyuopenuosudevnullu subprocessu check_calluOSError( uselfuurluschemeunetlocupathuparamsuqueryufragusinkusurc((u2/tmp/pip-zej_zi-build/pip/_vendor/distlib/index.pyu__init__$s( !          uPackageIndex.__init__cCs3ddlm}ddlm}|ƒ}||ƒS(us Get the distutils command for interacting with PyPI configurations. :return: the command. i(u Distribution(u PyPIRCCommand(udistutils.coreu Distributionudistutils.configu PyPIRCCommand(uselfu Distributionu PyPIRCCommandud((u2/tmp/pip-zej_zi-build/pip/_vendor/distlib/index.pyu_get_pypirc_command@s u PackageIndex._get_pypirc_commandcCsy|jƒ}|j|_|jƒ}|jdƒ|_|jdƒ|_|jddƒ|_|jd|jƒ|_dS(uç Read the PyPI access configuration as supported by distutils, getting PyPI to do the acutal work. This populates ``username``, ``password``, ``realm`` and ``url`` attributes from the configuration. uusernameupasswordurealmupypiu repositoryN(u_get_pypirc_commanduurlu repositoryu _read_pypircugetuusernameupasswordurealm(uselfucucfg((u2/tmp/pip-zej_zi-build/pip/_vendor/distlib/index.pyuread_configurationJs   uPackageIndex.read_configurationcCs0|jƒ|jƒ}|j|j|jƒdS(uÍ 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(ucheck_credentialsu_get_pypirc_commandu _store_pypircuusernameupassword(uselfuc((u2/tmp/pip-zej_zi-build/pip/_vendor/distlib/index.pyusave_configurationYs  uPackageIndex.save_configurationcCs‰|jdks|jdkr-tdƒ‚ntƒ}t|jƒ\}}}}}}|j|j||j|jƒt |ƒ|_ dS(up Check that ``username`` and ``password`` have been set, and raise an exception if not. u!username and password must be setN( uusernameuNoneupassworduDistlibExceptionuHTTPPasswordMgruurlparseuurlu add_passwordurealmuHTTPBasicAuthHandlerupassword_handler(uselfupmu_unetloc((u2/tmp/pip-zej_zi-build/pip/_vendor/distlib/index.pyucheck_credentialses  !uPackageIndex.check_credentialscCs€|jƒ|jƒ|jƒ}d|d<|j|jƒgƒ}|j|ƒ}d|d<|j|jƒgƒ}|j|ƒS(uq 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. uverifyu:actionusubmit(ucheck_credentialsuvalidateutodictuencode_requestuitemsu send_request(uselfumetadataudurequesturesponse((u2/tmp/pip-zej_zi-build/pip/_vendor/distlib/index.pyuregisterqs     uPackageIndex.registercCscxR|jƒ}|sPn|jdƒjƒ}|j|ƒtjd||fƒq|jƒdS(ur 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. uutf-8u%s: %sN(ureadlineudecodeurstripuappenduloggerudebuguclose(uselfunameustreamuoutbufus((u2/tmp/pip-zej_zi-build/pip/_vendor/distlib/index.pyu_reader…s   uPackageIndex._readercCsÒ|jdddg}|jr7|jd|jgƒn|dk r\|jdddgƒntjƒ}tjj|tjj |ƒdƒ}|jd d d |d ||gƒt j d dj|ƒƒ||fS(u¯ 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. :return: The signing command as a list suitable to be passed to :class:`subprocess.Popen`. u --status-fdu2u--no-ttyu --homediru--batchu--passphrase-fdu0u.ascu --detach-signu--armoru --local-useru--outputu invoking: %su N( ugpgugpg_homeuextenduNoneutempfileumkdtempuosupathujoinubasenameuloggerudebug(uselfufilenameusigneru sign_passworducmdutdusf((u2/tmp/pip-zej_zi-build/pip/_vendor/distlib/index.pyuget_sign_command—s    %uPackageIndex.get_sign_commandc Cs itjd6tjd6}|dk r6tj|d|j|jƒnt|Œ}|j|ƒS(uÝ 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). (upassword_handleruappendu ssl_verifieru build_openeruopen(uselfurequhandlersuopener((u2/tmp/pip-zej_zi-build/pip/_vendor/distlib/index.pyu send_request¨s   uPackageIndex.send_requestcCs<g}|j}xy|D]q\}}t|ttfƒsC|g}nxA|D]9}|jd|d|jdƒd|jdƒfƒqJWqWxG|D]?\}} } |jd|d|| fjdƒd| fƒq’W|jd|ddfƒdj|ƒ} d|} i| d6tt| ƒƒd 6} t |j | | ƒS( u& 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--u)Content-Disposition: form-data; name="%s"uutf-8su8Content-Disposition: form-data; name="%s"; filename="%s"s smultipart/form-data; boundary=u Content-typeuContent-length( uboundaryu isinstanceulistutupleuextenduencodeujoinustrulenuRequestuurl(uselfufieldsufilesupartsuboundaryukuvaluesuvukeyufilenameuvalueubodyuctuheaders((u2/tmp/pip-zej_zi-build/pip/_vendor/distlib/index.pyuencode_request¸s4      uPackageIndex.encode_requestcCsbt|tƒri|d6}n|jdkrIt|jddƒ|_n|jj||p^dƒS(Nunameutimeoutg@uand(u isinstanceu string_typesu rpc_proxyuNoneu ServerProxyuurlusearch(uselfutermsuoperator((u2/tmp/pip-zej_zi-build/pip/_vendor/distlib/index.pyusearchãs uPackageIndex.searchN(u__name__u __module__u __qualname__u__doc__uboundaryuNoneu__init__u_get_pypirc_commanduread_configurationusave_configurationucheck_credentialsuregisteru_readeruget_sign_commandu run_commandu sign_fileu upload_fileuupload_documentationuget_verify_commanduverify_signatureu download_fileu send_requestuencode_requestusearch(u __locals__((u2/tmp/pip-zej_zi-build/pip/_vendor/distlib/index.pyu PackageIndexs*    # 4   M  +u PackageIndex(uhashlibulogginguosushutilu subprocessutempfileu threadinguThreadu ImportErrorudummy_threadinguuDistlibExceptionucompatuHTTPBasicAuthHandleruRequestuHTTPPasswordMgruurlparseu build_openeru string_typesuutilucached_propertyuzip_diru ServerProxyu getLoggeru__name__uloggeru DEFAULT_INDEXu DEFAULT_REALMuobjectu PackageIndex(((u2/tmp/pip-zej_zi-build/pip/_vendor/distlib/index.pyus       .