U cf]~@sddlmZddlZddlZddlZddlZddlZddlZddlm Z m Z m Z m Z m Z mZddlmZmZmZddlmZedZzeWn$ek rGdd d eZYnXeZGd d d eZGd d d e ddZddddddddddddddhZddd d!d"d#d$d%d&d'd(d)h Zd*hZd+d,d-d.d/Z d,d0d-d1d2Z!d3d4d+d5d6d7Z"ddddddddd8dddddd d!d"d*d#d$d%d&d'd(ddd)dd9Z#d:d;e#$DZ%d4dZ&e'Z(d?d@dAdBdCdDgZ)e dEZ*e+dddgZ,GdFdGdGe eZ-GdHdIdIZ.dS)J) annotationsN)AnyCallableGenericLiteral TypedDictcast) requirements specifiersutils)versionTc@sBeZdZUdZded<ded<dddddd Zdd d d Zd S)ExceptionGroupzA minimal implementation of :external:exc:`ExceptionGroup` from Python 3.11. If :external:exc:`ExceptionGroup` is already defined by Python itself, that version is used instead. strmessagezlist[Exception] exceptionsNone)rrreturncCs||_||_dSN)rr)selfrrrL/opt/hc_python/lib/python3.8/site-packages/pip/_vendor/packaging/metadata.py__init__&szExceptionGroup.__init__)rcCs|jjd|jd|jdS)N(z, )) __class____name__rr)rrrr__repr__*szExceptionGroup.__repr__N)r __module__ __qualname____doc____annotations__rrrrrrrs rcs4eZdZUdZded<ddddfdd ZZS)InvalidMetadataz'A metadata field contains invalid data.rfieldr)r$rrcs||_t|dSr)r$superr)rr$rrrrr7szInvalidMetadata.__init__)rrr r!r"r __classcell__rrr&rr#1s r#c@seZdZUdZded<ded<ded<ded<ded<ded <ded <ded <ded <ded <ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded <d!S)" RawMetadataaA dictionary of raw core metadata. Each field in core metadata maps to a key of this dictionary (when data is provided). The key is lower-case and underscores are used instead of dashes compared to the equivalent core metadata field. Any core metadata field that can be specified multiple times or can hold multiple values in a single field have a key with a plural name. See :class:`Metadata` whose attributes match the keys of this dictionary. Core metadata fields that can be specified multiple times are stored as a list or dict depending on which is appropriate for the field. Any fields which hold multiple values in a single field are stored as a list. rmetadata_versionnamer list[str] platformssummary descriptionkeywords home_pageauthor author_emaillicensesupported_platforms download_url classifiersrequiresprovides obsoletes maintainermaintainer_email requires_dist provides_distobsoletes_distrequires_pythonrequires_externaldict[str, str] project_urlsdescription_content_typeprovides_extradynamicN)rrr r!r"rrrrr(@s:  r(F)totalr1r2r.rCr5r0r3r:r;r)r*r?r-r r6rEr9r>r,r8r=rDr7r<r@r4rBrr+)datarcCsdd|dDS)zCSplit a string of comma-separate keyboards into a list of keywords.cSsg|] }|qSrstrip).0krrr sz#_parse_keywords..,)split)rGrrr_parse_keywordssrOrAc Csfi}|D]X}dd|ddD}|dgtddt||\}}||krXtd|||<q|S) z?Parse a list of label/URL string pairings separated by a comma.cSsg|] }|qSrrH)rJprrrrLsz'_parse_project_urls..rMr rz duplicate labels in project urls)rNextendmaxlenKeyError)rGurlspairpartslabelurlrrr_parse_project_urlss r\zemail.message.Message bytes | str)msgsourcercCsRt|tr|}|S|jdd}z|ddWStk rLtdYnXdS)zGet the body of the message.Tdecodeutf8strictzpayload in an invalid encodingN) isinstancer get_payloadraUnicodeDecodeError ValueError)r^r_payloadbpayloadrrr _get_payloads  rjr/)r1z author-email classifierr.zdescription-content-typez download-urlrEz home-pager/r3r:zmaintainer-emailmetadata-versionr*r9zobsoletes-distplatformz project-urlr8z provides-distzprovides-extrar7z requires-distzrequires-externalzrequires-pythonr-zsupported-platformr cCsi|]\}}||qSrr)rJemailrawrrr srpz(tuple[RawMetadata, dict[str, list[str]]]c Csi}i}t|tr,tjjtjjd|}ntjjtjjd |}t | D]}| }| |pjg}g}d}|D]}t|tjjtfstt|tjjrg} tj|D]H\} } z| ddWntk rd} d}YnXd} | | | fq|ttj| qx||qx|s0|||<qPt|} | dkrN|||<qP| tkrtt|dkrt|d || <qP| tkr||| <qP| d krt|dkrt|d || <qP| d krzt||| <Wntk r|||<YnXqP|||<qPzt||} Wn6tk r<| d g|j!t|t"d Yn\X| rd |krvt#t|$d }| d g%|| gn"d |kr|d | n| |d <t#t&||fS)a Parse a distribution's metadata stored as email headers (e.g. from ``METADATA``). This function returns a two-item tuple of dicts. The first dict is of recognized fields from the core metadata specification. Fields that can be parsed and translated into Python's built-in types are converted appropriately. All other fields are left as-is. Fields that are allowed to appear multiple times are stored as lists. The second dict contains all other fields from the metadata. This includes any unrecognized fields. It also includes any fields which are expected to be parsed into a built-in type but were not formatted appropriately. Finally, any fields that are expected to appear only once but are repeated are included in this dict. )policyTrbrclatin1FNr rr/rBr.r`)'rdrrnparserParserrqcompat32parsestr BytesParser parsebytes frozensetkeyslowerget_allheaderHeaderAssertionError decode_headerrarfappend make_header_EMAIL_TO_RAW_MAPPINGget_STRING_FIELDSrU _LIST_FIELDSrOr\rVrjrg setdefaultrebytesrpoprSr()rGrounparsedparsedr*headersvalueZvalid_encodinghchunksbinencodingraw_namerhZdescription_headerrrr parse_emailsv                 r1.01.11.22.12.22.3)rrrrrrc@seZdZUdZded<ded<ded<dddd d d d Zd dd dddZd dddddZd4ddddddZdddddZ ddddd Z dd!dd"d#Z dddd$d%Z dddd&d'Z d(d(dd)d*Zd(d+dd,d-Zdd.dd/d0Zd(d1dd2d3ZdS)5 _ValidatoravValidate a metadata field. All _process_*() methods correspond to a core metadata field. The method is called with the field's raw value. If the raw value is valid it is returned in its "enriched" form (e.g. ``version.Version`` for the ``Version`` field). If the raw value is invalid, :exc:`InvalidMetadata` is raised (with a cause as appropriate). rr*r_MetadataVersionaddedrrr)rrcCs ||_dSrr)rrrrrrsz_Validator.__init__Metadata)_ownerr*rcCs||_t||_dSr)r*_RAW_TO_EMAIL_MAPPINGr)rrr*rrr __set_name__sz_Validator.__set_name__ztype[Metadata]r)instancerrcCs|j}|j|j}|jtks&|dk rZzt|d|j}Wntk rPYn X||}|||j<z|j|j=Wntk rYnXtt |S)NZ _process_) __dict___rawrr*_REQUIRED_ATTRSgetattrAttributeErrorrVrr)rrrcacher converterrrr__get__s z_Validator.__get__NzException | Noner#)r^causercCs&t|j|dt|ji}||_|S)Nr$)r#r format_maprepr __cause__)rr^rexcrrr_invalid_metadatas z_Validator._invalid_metadata)rrcCs"|tkr||dtt|S)Nz is not a valid metadata version)_VALID_METADATA_VERSIONSrrrrrrrr_process_metadata_version sz$_Validator._process_metadata_versionc Csb|s|dztj|ddWn8tjk rX}z|j|d|dW5d}~XYnX|SdS)N{field} is a required fieldTvalidate is invalid for {field}r)rr canonicalize_name InvalidNamerrrrrr _process_names z_Validator._process_namezversion_module.Versionc CsX|s|dz t|WStjk rR}z|j|d|dW5d}~XYnXdS)Nrrr)rversion_moduleparseInvalidVersionrrrr_process_versions  z_Validator._process_versioncCsd|kr|d|S)z%Check the field contains no newlines. z{field} must be a single line)rrrrr_process_summary(s z_Validator._process_summaryc Csdddh}tj}||d<||dj}}||ksH||krb|dt|d||dd}|dkr|d t|d d h}|d d }|dkr||kr|d t|d||S)Nz text/plainz text/x-rstz text/markdownz content-typez{field} must be one of z, not charsetzUTF-8z0{field} can only specify the UTF-8 charset, not ZGFMZ CommonMarkvariantz(valid Markdown variants for {field} are ) rnr EmailMessageget_content_typer{paramsrlistr) rrZ content_typesr content_type parametersrZmarkdown_variantsrrrr!_process_description_content_type.s,      z,_Validator._process_description_content_typer+cCsTttj|D]6}|dkr*||dq |tkr ||dq tttj|S)N>r r*rlz" is not allowed as a dynamic fieldz is not a valid dynamic field)maprr{rrr)rrZ dynamic_fieldrrr_process_dynamicNsz_Validator._process_dynamiczlist[utils.NormalizedName]c Cshg}z"|D]}|tj|ddq Wn8tjk r^}z|j|d|dW5d}~XYnX|SdS)NTrrr)rr rrr)rrZnormalized_namesr*rrrr_process_provides_extraXsz"_Validator._process_provides_extrazspecifiers.SpecifierSetc CsJz t|WStjk rD}z|j|d|dW5d}~XYnXdSNrr)r SpecifierSetInvalidSpecifierrrrrr_process_requires_pythongs z#_Validator._process_requires_pythonzlist[requirements.Requirement]c Csdg}z|D]}|t|q Wn8tjk rZ}z|j|d|dW5d}~XYnX|SdSr)rr RequirementInvalidRequirementr)rrreqsreqrrrr_process_requires_distos&z!_Validator._process_requires_dist)N)rrr r!r"rrrrrrrrrrrrrrrrrrs&       rc@seZdZUdZded<edddddddd Zeddd dddd d ZeZ d ed<eZ ded<eZ ded<eddZ ded<eZ ded<eddZded<eZded<eZded<eddZded<eZded<eZded <eddZded!<eZded"<eZded#<ed$dZded%<ed$dZded&<eZded'<eddZded(<ed$dZd)ed*<ed$dZd+ed,<ed$dZded-<ed$dZd.ed/<eddZd0ed1<ed$dZ ded2<ed$dZ!ded3<eddZ"ded4<eddZ#ded5<eddZ$ded6<d7S)8raJRepresentation of distribution metadata. Compared to :class:`RawMetadata`, this class provides objects representing metadata fields instead of only using built-in types. Any invalid metadata will cause :exc:`InvalidMetadata` to be raised (with a :py:attr:`~BaseException.__cause__` attribute as appropriate). r(rTrbool)rGrrc CsP|}||_|rLg}z|j}t|}Wn0tk r^}z||d}W5d}~XYnXt|jtB}|dh8}|D]} z|rz|j | j } Wn4t k rt| d| } || YWq|YnXt| } | |krt | } t| d} || Wq|t || Wq|tk r8} z|| W5d} ~ XYq|Xq||rLtd||S)zCreate an instance from :class:`RawMetadata`. If *validate* is true, all metadata will be validated. All exceptions related to validation will be gathered and raised as an :class:`ExceptionGroup`. Nr)unrecognized field: zW{field} introduced in metadata version {field_metadata_version}, not {metadata_version}zinvalid metadata)copyrr)rindexr#rryrrrrVrrr)clsrGrZinsrr)Z metadata_ageZmetadata_version_excZfields_to_checkkeyZfield_metadata_versionrZ field_ager$rrrfrom_rawsL       zMetadata.from_rawr]c Cst|\}}|rZg}|D]2}|tkr0|d}n d|}|t||q|rZtd|z|j||dWStk r}ztd|jdW5d}~XYnXdS)zParse metadata from email headers. If *validate* is true, the metadata will be validated. All exceptions related to validation will be gathered and raised as an :class:`ExceptionGroup`. z has invalid datarrrzinvalid or unparsed metadataN)rrrr#rrr) rrGrrorrZ unparsed_keyrZ exc_grouprrr from_emails&    zMetadata.from_emailz_Validator[_MetadataVersion]r)z_Validator[str]r*z"_Validator[version_module.Version]r rrz_Validator[list[str] | None]rEr,rr4z_Validator[str | None]r-r.rrCr/r0r5r1r2rr:r;r3r6z1_Validator[list[requirements.Requirement] | None]r<z*_Validator[specifiers.SpecifierSet | None]r?r@z!_Validator[dict[str, str] | None]rBz-_Validator[list[utils.NormalizedName] | None]rDr=r>r7r8r9N)%rrr r!r" classmethodrrrr)r*r rEr,r4r-r.rCr/r0r5r1r2r:r;r3r6r<r?r@rBrDr=r>r7r8r9rrrrr}sV 8r)/ __future__remail.feedparserrnZ email.header email.message email.parser email.policytypingrrrrrrrQr r r r rTypeVarrr NameError Exceptionrgr#r(rrZ _DICT_FIELDSrOr\rjritemsrrobject _NOT_FOUNDrrryrrrrrrrs    E(10