ai4ddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z m Z mZmZmZmZddlmZmZmZmZddlmZe jrddlmZe jdZe jd kreZnGd d eZGd d e Z!GddedZ"hdZ#hdZ$dhZ%dYdZ&dZdZ'd[d Z(id!d!d"d#d$d%d&d&d'd(d)d*d+d+d,d-d.d/d0d1d2d2d3d3d4d5d6d7d8d8d9d:d;d<d=d>d?d@ddAdBdCdDdEdFdGdHdIdJdKZ)dLe)*DZ+GdMdNej,j-Z.GdOdPej/j0Z1d\dRZ2e3Z4gdSZ5edSZ6e7gdTZ8GdUdVeeZ9GdWdXZ:dS)]) annotationsN)AnyCallableGenericLiteral TypedDictcast)licenses requirements specifiersutils)version)NormalizedLicenseExpressionT) c8eZdZUdZded<ded<d dZd 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. strmessagelist[Exception] exceptionsreturnNonec"||_||_dSN)rr)selfrrs b/home/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/packaging/metadata.py__init__zExceptionGroup.__init__,s"DL(DOOOc@|jjd|jd|jdS)N(, )) __class____name__rr)rs r__repr__zExceptionGroup.__repr__0s*n-VV VV$/VVV Vr!N)rrrrrr)rr)r' __module__ __qualname____doc____annotations__r r(r!rrr"se   #### ) ) ) ) W W W W W Wr!rc2eZdZUdZded< dfd ZxZS) InvalidMetadataz'A metadata field contains invalid data.rfieldrrrcX||_t|dSr)r0superr )rr0rr&s rr zInvalidMetadata.__init__:s(  !!!!!r!)r0rrrrr)r'r)r*r+r,r __classcell__r&s@rr/r/4sQ11JJJ;""""""""""r!r/cTeZdZUdZded<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 <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_extradynamiclicense_expression license_files import_namesimport_namespacesN)r'r)r*r+r,r-r!rr6r6Cs    IIILLLLLLNNNKKKLLL#"""OOO        "!!!      r!r6F)total>r8r?rAr;rr>rHr<r@rCrMrIr7rTrQ>rSrFrErGr:rDrVrUrKrJrLrRrWrNrBrPdatarrr9c@d|dDS)zCSplit a string of comma-separated keywords into a list of keywords.c6g|]}|Sr-strip).0ks r z#_parse_keywords..s / / /!AGGII / / /r!,)split)rYs r_parse_keywordsrcs / /tzz# / / //r!rOci}|D]=}d|dD\}}}||vrtd|||<>|S)z?Parse a list of label/URL string pairings separated by a comma.c3>K|]}|VdSrr\)r^ss r z&_parse_project_urls..s*@@q@@@@@@r!raz duplicate labels in project urls) partitionKeyError)rYurlspairlabel_urls r_parse_project_urlsrosh D0A@DNN3,?,?@@@ q# D===>> >U Kr!msgemail.message.Messagesource bytes | strcRt|tr-|}t|tsJ|S|d}t|tsJ |ddS#t $r}t d|d}~wwxYw)zGet the body of the message.Tdecodeutf8strictzpayload in an invalid encodingN) isinstancer get_payloadbytesrvUnicodeDecodeError ValueError)rprrpayloadbpayloadexcs r _get_payloadrs&# H//##'3'''''??$?//(E***** H??6844 4! H H H=>>C G Hs1B B&B!!B&r?z author-emailr@ classifierrDr<zdescription-content-typerQz download-urlrCrSz home-pager> import-namerVzimport-namespacerWr=rAzlicense-expressionrTz license-filerUrHzmaintainer-emailrImetadata-versionr7r8rGrLr:rFrKrRrErJrNrMr;rBr)r8rGzobsoletes-distplatform project-urlrFz provides-distzprovides-extrarEz requires-distzrequires-externalzrequires-pythonr;zsupported-platformrci|]\}}|| Sr-r-)r^emailraws r r'sTTT seTTTr!c&eZdZdZdZdZdZd d Zd S) RFC822Policyz This is :class:`email.policy.EmailPolicy`, but with a simple ``header_store_parse`` implementation that handles multi-line values, and some nice defaults. TFrr8rvaluertuple[str, str]cft|dz}|ddd|zz}||fS)N  )lenreplace)rr8rsizes rheader_store_parsezRFC822Policy.header_store_parse5s74yy1} dD3:$566e}r!N)r8rrrrr)r'r)r*r+rw mangle_from_max_line_lengthrr-r!rrr+sC DLOr!rc0eZdZdZd fd Z ddd ZxZS) RFC822Messagez This is :class:`email.message.EmailMessage` with two small changes: it defaults to our `RFC822Policy`, and it correctly writes unicode when being called with `bytes()`. rrcdttdS)Npolicy)r2r r)rr&s rr zRFC822Message.__init__Cs(  /////r!FNunixfromboolremail.policy.Policy | Noner{cV|||dS)zi Return the bytes representation of the message. This handles unicode encoding. rzutf-8) as_stringencode)rrrs ras_byteszRFC822Message.as_bytesFs(~~hv~66==gFFFr!)rr)FN)rrrrrr{)r'r)r*r+r rr3r4s@rrr<sp 000000LPGGGGGGGGGr!r(tuple[RawMetadata, dict[str, list[str]]]c i}i}t|trCtjtjj|}nBtjtjj |}t| D]#}| }| |pg}g}d}|D] } t| tjjtfsJt| tjjrg} tj| D]J\} } | ddd} n#t$$rd} d}YnwxYw| | | fK|ttj| ||  |s|||<Jt*|}||||<m|t.vr t1|dkr |d ||<|d kr|d gkrg||<|t2vr|||<|d kr-t1|dkrt5|d ||<|d kr+ t7|||<#t8$r |||<YwxYw|||<% t;||}|rxd|vrOt=d|d}| dg!||gnd|vr|d|nf||d<n`#tD$rS| dg|#t|tHYnwxYwt=d||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. rTrwrxlatin1FNr rrVr=rPr<rrur6)%ryrrparserParserrcompat32parsestr BytesParser parsebytes frozensetkeyslowerget_allheaderHeader decode_headerrvr|append make_header_EMAIL_TO_RAW_MAPPINGget_STRING_FIELDSr _LIST_FIELDSrcrorirr pop setdefaultextendr}rzr{)rYrunparsedparsedname_with_caser8headersrvalid_encodinghchunksbinary _encodingencodingraw_namer~description_headers r parse_emailrQsW 8:C%'H$Y$$EL,A$BBKKDQQ))1F)GGRRSWXX $FKKMM22y#y###%% ..&&,"# # Aa%,"5s!;<< < < <!U\011 :<).)C)CA)F)F 6 6%FI* fh777 $* .///#+)./ MM68"45555  S!9!9&!A!ABBCCCC Q  "HTN (,,T22  #HTN  ~ % %#e**//!!HCMM ' 'EbTMMCMM % %!CMM  # #E a+E!H55CMM ' ' ' 3E : :H  ' ' '!& ' #HTNN -vt,,  -##%)%1G1G%H%H"##M266=='1(**'..w7777%,M"!    M2..55   ju&=&=  > >      ,  s # #X --s7%E>>F F 4KKK&M11AO O)1.01.11.22.12.2z2.32.42.5)r7r8rceZdZUdZded<ded<ded<ddd,d Zd-dZd.dZ d/d0dZd1dZ d2dZ d3dZ d2dZ d2dZ d4d!Zd5d#Zd6d%Zd7d'Zd8d)Zd4d*Zd4d+ZeZdS)9 _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). rr8r_MetadataVersionaddedrrrrc||_dSrr)rrs rr z_Validator.__init__s  r!_ownerMetadatac8||_t||_dSr)r8_RAW_TO_EMAIL_MAPPINGr)rrr8s r __set_name__z_Validator.__set_name__%s -d3 r!instancetype[Metadata]rcJ|j}|j|j}|jtvs|5 t |d|j}||}n#t $rYnwxYw|||j< |j|j=n#t$rYnwxYwtd|S)N _process_r) __dict___rawrr8_REQUIRED_ATTRSgetattrAttributeErrorrir )rrrcacher converters r__get__z_Validator.__get__)s! !!$),, 9 ' '5+< )07>U$)>U>U0V0V " %(("     !di  di((    D Cs#A A)(A)7 B BBNrpcauseException | Noner/c t|j|dt|ji}||_|S)Nr0)r/r format_maprepr __cause__)rrprrs r_invalid_metadataz_Validator._invalid_metadataDsC M3>>7D4G4G*HII    r!rcd|tvr||dtd|S)Nz is not a valid metadata versionr)_VALID_METADATA_VERSIONSrr rrs r_process_metadata_versionz$_Validator._process_metadata_versionMs< 0 0 0((E)U)U)UVV V&...r!c|s|d tj|d|S#tj$r }||d||d}~wwxYw)N{field} is a required fieldTvalidate is invalid for {field}r)rrcanonicalize_name InvalidNamerrrs r _process_namez_Validator._process_nameSs H(()FGG G   #ED 9 9 9 9 L     ((555S)  s1A AA version_module.Versionc|s|d tj|S#tj$r }||d||d}~wwxYw)Nrrr)rversion_moduleparseInvalidVersionrs r_process_versionz_Validator._process_version`s H(()FGG G !'.. .,   ((555S)  s-AAAc8d|vr|d|S)z%Check the field contains no newlines.rz{field} must be a single line)rrs r_process_summaryz_Validator._process_summaryjs% 5==(()HII I r!cXhd}tj}||d<||dj}}||vs||vr(|dt|d||dd}|dkr%|dt|dd h}|d d}|d kr,||vr(|d t|d||S) N> text/plain text/x-rst text/markdownz content-typez{field} must be one of , not charsetzUTF-8z0{field} can only specify the UTF-8 charset, not GFM CommonMarkvariantr z(valid Markdown variants for {field} are ) rr EmailMessageget_content_typerparamsrlistr) rr content_typesr content_type parametersr markdown_variantsrs r!_process_description_content_typez,_Validator._process_description_content_typepspEEE -,,.."'  $ $ & & , , . . N # *!  } , , EKKMM0Q0Q((PD,?,?PPuPP ..G44 g  ((TT']]TT #L1..E22 ? * *w>O/O/O((#TBS=T=T####  r!r9cttj|D]?}|dvr||d|tvr||d@t ttj|S)N>r8rrz" is not allowed as a dynamic fieldz is not a valid dynamic field)maprrrrr)rr dynamic_fields r_process_dynamicz_Validator._process_dynamics E22  M GGG,,$JJJ&;;;,,$EEE<C 5))***r!list[utils.NormalizedName]cg} |D]+}|tj|d, |S#tj$r }||d||d}~wwxYw)NTrrr)rrrrr)rrnormalized_namesr8rs r_process_provides_extraz"_Validator._process_provides_extras $ V V ''(?t(T(T(TUUUU V$ #     ((444C)  s.5A$AA$specifiers.SpecifierSetc tj|S#tj$r }||d||d}~wwxYwNrr)r SpecifierSetInvalidSpecifierrrs r_process_requires_pythonz#_Validator._process_requires_pythonsh *511 1*   ((555S)  sAAAlist[requirements.Requirement]cg} |D])}|tj|* |S#tj$r }||d||d}~wwxYwr#)rr RequirementInvalidRequirementr)rrreqsreqrs r_process_requires_distz!_Validator._process_requires_dists  ; ; L4S99:::: ;K .   ((3333)  s,3A"AA"rc tj|S#t$r }||d||d}~wwxYwr#)r canonicalize_license_expressionr}rrs r_process_license_expressionz&_Validator._process_license_expressionse ;EBB B   ((555S)  s A;Acg}|D]}d|vr||dd|vr||dtj|s&tj|r||dtj||kr||d|||S)Nz..zD is invalid for {field}, parent directory indicators are not allowed*z/ is invalid for {field}, paths must be resolvedz/ is invalid for {field}, paths must be relativez5 is invalid for {field}, paths must use '/' delimiter)rpathlib PurePosixPath is_absolutePureWindowsPathas_posixr)rrpathspaths r_process_license_filesz!_Validator._process_license_filessE  Dt||,,BBBd{{,,PPP%d++7799 *400<<>> ,,PPP&t,,55774??,,VVV LL     r!c|D]}|d\}}}|}|dD]`}|s||d|dt j|r||d|da|r0|dkr||d|S)N;.z is invalid for {field}; z is not a valid identifierz is a keywordprivatez; is invalid for {field}; the only valid option is 'private')rhrstriprb isidentifierrkeyword iskeywordlstrip)rr import_namer8 semicolonr> identifiers r_process_import_namesz _Validator._process_import_namessB   K'2'<'NOO " ( ( (!!"6777#'       ( (11OCO  23 3O& + ++'%%58\#5F5L22'%%%"1#7Uc7U7U"V"VC&--c222$H%%=$B$B2%% %|33$9#$>E"1 %#(!T!T#9!T!TAQ!T!T##C '--c222$C%%%%&+++%%c********+ E$%7DDD sZ!A A7A22A7!E$B76E72C,)E+C,,AE E F%E??FrscJt|\}}|rPg}|D]9}|tvr|d}nd|}|t||:|rt d| |||S#t$r}t d|jdd}~wwxYw)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 datarKrrzinvalid or unparsed metadataN)rrrr/rrVr) rNrYrrrr unparsed_keyr exc_groups r from_emailzMetadata.from_emailAs$D)) X  =*,J ( J J #888!-BBBGGE\EEG!!/,"H"HIIII =$Z<<< <<h<77 7    . 0D  s&A== B"BB"z_Validator[_MetadataVersion]r7z_Validator[str]r8z"_Validator[version_module.Version]rrrz_Validator[list[str] | None]rSr:rrBz_Validator[str | None]r;r<rrQr=r>rCr?r@rrHrIrArz._Validator[NormalizedLicenseExpression | None]rTrUrDz1_Validator[list[requirements.Requirement] | None]rJz*_Validator[specifiers.SpecifierSet | None]rMrNz!_Validator[dict[str, str] | None]rPz-_Validator[list[utils.NormalizedName] | None]rRrKrLrrVrWrErFrGrcLt}|||S)= Return an RFC822 message with the metadata. )r_write_metadata)rrs r as_rfc822zMetadata.as_rfc822s& // W%%%r!rrc>|jjD]\}}t|tr|dkrt ||}t |}||dkr%|D]\}}|d|||<j|dkrd|||<|dkr |gkrd||<t|tr|D]}t|||<t|||<|j | |j dSdS) r\r<Nrr$r=rarr) r&ritemsryrrrjoinrrr< set_payload) rrr8 validatorr email_namerlrnitems rr]zMetadata._write_metadatasj $~6<<>> 9 9OD))Z00 9T]5J5Jd++248 $!]22*/++--DDJE35:2C2Cc2C2CGJ//D#z11.1hhuoo ++#}44".0 ++#E4009$)<rCr?r@rHrIrArTrUrDrJrMrNrPrRrKrLrVrWrErFrGr^r]r-r!rrrs=A66666[6p?C[66@Z\\AAAA<'JLLD((((3=*,,G>>>>:,6J---GD.8jllI::::08B 8O8O8OOOOO:&0jllG2222R*4*,,K666637Az7N7N7NNNNNL-7Z\\H99990(2 I44441+5:E+B+B+BLBBBB4%/Z\\F1111.+5:<rws"""""" 877777777777'''''' 6555555FN3w#NNWWWWWWWW$"""""j"""I!I!I!I!I!)5I!I!I!I!\$ & 0000 $$$$NHHHH>! h!N!-!= !  : ! N !y!!>!+! !y!.!O!,! *!!"*#!$ &!$&$,(/A!!!DUT6K6Q6Q6S6STTT     5<+   "GGGGGEM.GGG*r.r.r.r.jVXX TSSQR)CCCDDj7j7j7j7j7j7j7j7ZU2U2U2U2U2U2U2U2U2U2r!