a 5a2@sdZddlmZddlmZddlmZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlmZddlmZd d ZGd d d eZdS) z|upload_docs Implements a Distutils 'upload_docs' subcommand (upload documentation to sites other than PyPi such as devpi). )standard_b64encode)log)DistutilsOptionErrorN)iter_entry_points)uploadcCs |ddS)Nzutf-8surrogateescape)encode)sr O/opt/alt/python39/lib/python3.9/site-packages/setuptools/command/upload_docs.py_encodesr c@seZdZdZdZdddejfddgZejZdd Zd efgZ d d Z d dZ ddZ ddZ eddZeddZddZdS) upload_docszhttps://pypi.python.org/pypi/z;Upload documentation to sites other than PyPi such as devpiz repository=rzurl of repository [default: %s])z show-responseNz&display full response text from server)z upload-dir=Nzdirectory to uploadcCs"|jdurtddD]}dSdS)Nzdistutils.commands build_sphinxT) upload_dirr)selfZepr r r has_sphinx-s zupload_docs.has_sphinxrcCst|d|_d|_dS)N)rinitialize_optionsr target_dir)rr r r r4s zupload_docs.initialize_optionscCst||jdurV|r8|d}t|jd|_qh|d}tj |j d|_n| d|j|_d|j vr|td|d|jdS) NrZhtmlbuildZdocsrzpypi.python.orgzz multipart/form-data; boundary=%s) r functoolspartialrCmapitems itertoolschain from_iterabler) clsdataboundaryr>Z end_boundaryZ end_itemsZbuilderZ part_groupspartsZ body_items content_typer r r _build_multipart{s  zupload_docs._build_multipartc CsVt|d}|}Wdn1s(0Y|jj}d|tj||fd}t|j d|j }t | d}d|}| |\}} d|j} || tjtj|j\} } } }}}|s|s|rJ| dkrtj| }n"| d krtj| }n td | d }zZ||d | | }|d ||dtt||d||| |Wn<t!j"y}z |t|tj#WYd}~dSd}~00|$}|j%dkrd|j%|j&f} || tjnb|j%dkr|'d}|durd|}d|} || tjnd|j%|j&f} || tj#|j(rRt)d|ddS)NrbZ doc_upload)z:actionr,content:rDzBasic zSubmitting documentation to %shttphttpszunsupported schema ZPOSTz Content-typezContent-lengthZ AuthorizationzServer response (%s): %si-ZLocationzhttps://pythonhosted.org/%s/zUpload successful. Visit %szUpload failed (%s): %szK---------------------------------------------------------------------------)*openreadr1r2r3rrbasenamer usernamepasswordrdecoderRrrrINFOurllibparseurlparserVZclientZHTTPConnectionZHTTPSConnectionAssertionErrorZconnectZ putrequestZ putheaderstrr"Z endheaderssendsocketerrorZERRORZ getresponseZstatusreasonZ getheaderZ show_responseprint)rr'frTmetarNZ credentialsZauthbodyZctmsgZschemanetlocurlparamsqueryZ fragmentsZconnrQerlocationr r r r4s` &           zupload_docs.upload_fileN)__name__ __module__ __qualname__ZDEFAULT_REPOSITORY descriptionrZ user_optionsZboolean_optionsrZ sub_commandsrrr/r6 staticmethodrC classmethodrRr4r r r r rs(   r)__doc__base64rZ distutilsrZdistutils.errorsrrrgr r0r5rJrFZ http.clientrV urllib.parseraZ pkg_resourcesrrr rr r r r s