bir ddlmZddlZddlZddlZddlZddlZddlZddl Z ddl m Z m Z m Z m Z mZmZddlmZmZmZmZddlmZddlmZmZe jrddlmZe jd Zgd ZdYd ZGdde Z!GddedZ"hdZ#hdZ$dhZ%dZdZ&d[dZ'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]dRZ2e3Z4gdSZ5e dSZ6e7gdTZ8GdUdVe eZ9GdWdXZ:dS)^) annotationsN)AnyCallableGenericLiteral TypedDictcast)licenses requirements specifiersutils)version)ExceptionGroup_ErrorCollector)NormalizedLicenseExpressionT)rInvalidMetadataMetadata RFC822Message RFC822Policy RawMetadata parse_emailreturn list[str]ctSN)__all__j/home/jenkins/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/packaging/metadata.py__dir__r"(s Nr c2eZdZUdZded< dfd ZxZS) rz'A metadata field contains invalid data.strfieldmessagerNonecX||_t|dSr)r%super__init__)selfr%r& __class__s r!r*zInvalidMetadata.__init__2s(  !!!!!r )r%r$r&r$rr')__name__ __module__ __qualname____doc____annotations__r* __classcell__r,s@r!rr,sQ11JJJ;""""""""""r rcTeZdZUdZded<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)&raA 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. All fields are considered optional. r$metadata_versionnamerr 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/r0r1rr r!rr;s    IIILLLLLLNNNKKKLLL#"""OOO        "!!!      r rF)total>r6r<r>r8rr;rEr9r=r@rJrFr5rQrN>rPrCrBrDr7rArSrRrHrGrIrOrTrKr?rMdatar$c@d|dDS)zCSplit a string of comma-separated keywords into a list of keywords.c6g|]}|Srstrip).0ks r! z#_parse_keywords..s / / /!AGGII / / /r ,)split)rVs r!_parse_keywordsr`s / /tzz# / / //r rLci}|D]=}d|dD\}}}||vrtd|||<>|S)z?Parse a list of label/URL string pairings separated by a comma.c3>K|]}|VdSrrY)r[ss r! z&_parse_project_urls..s*@@q@@@@@@r r^z duplicate labels in project urls) partitionKeyError)rVurlspairlabel_urls r!_parse_project_urlsrlsh 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_payloadbytesrsUnicodeDecodeError ValueError)rmropayloadbpayloadexcs r! _get_payloadr~s&# H//##'3'''''??$?//(E***** H??6844 4! H H H=>>C G Hs1B B&B!!B&r<z author-emailr= classifierrAr9zdescription-content-typerNz download-urlr@rPz home-pager; import-namerSzimport-namespacerTr:r>zlicense-expressionrQz license-filerRrEzmaintainer-emailrFmetadata-versionr5r6rDrIr7rCrHrOrBrGrKrJr8r?r)r6rDzobsoletes-distplatform project-urlrCz provides-distzprovides-extrarBz requires-distzrequires-externalzrequires-pythonr8zsupported-platformrci|]\}}|| Srr)r[emailraws r! rsTTT seTTTr c&eZdZdZdZdZdZd d Zd S) rz This is :class:`email.policy.EmailPolicy`, but with a simple ``header_store_parse`` implementation that handles multi-line values, and some nice defaults. TFrr6r$valuertuple[str, str]cft|dz}|ddd|zz}||fS)N  )lenreplace)r+r6rsizes r!header_store_parsezRFC822Policy.header_store_parse-s74yy1} dD3:$566e}r N)r6r$rr$rr)r-r.r/r0rt mangle_from_max_line_lengthrrr r!rr#sC DLOr rc0eZdZdZd fd Z ddd ZxZS)rz 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()`. rr'cdttdS)Npolicy)r)r*r)r+r,s r!r*zRFC822Message.__init__;s(  /////r FNunixfromboolremail.policy.Policy | NonerxcV|||dS)zi Return the bytes representation of the message. This handles unicode encoding. rzutf-8) as_stringencode)r+rrs r!as_byteszRFC822Message.as_bytes>s(~~hv~66==gFFFr )rr')FN)rrrrrrx)r-r.r/r0r*rr2r3s@r!rr4sp 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. rTrtrulatin1FNr rrSr:rMr9r$rrr)%rvr$rparserParserrcompat32parsestr BytesParser parsebytes frozensetkeyslowerget_allheaderHeader decode_headerrsryappend make_header_EMAIL_TO_RAW_MAPPINGget_STRING_FIELDSr _LIST_FIELDSr`rlrfr~r pop setdefaultextendrzrwrx)rVrunparsedparsedname_with_caser6headersrvalid_encodinghchunksbinary _encodingencodingraw_namer{description_headers r!rrIsW 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)r5r6rceZdZUdZded<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). r$r6r_MetadataVersionaddedrrrr'c||_dSrr)r+rs r!r*z_Validator.__init__s  r _ownerrc8||_t||_dSr)r6_RAW_TO_EMAIL_MAPPINGr)r+rr6s 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___rawrr6_REQUIRED_ATTRSgetattrAttributeErrorrfr )r+rrcacher converters r!__get__z_Validator.__get__!s! !!$),, 9 ' '5+< )07>U$)>U>U0V0V " %(("     !di  di((    D Cs#A A)(A)7 B BBNrmcauseException | Nonerc t|j|dt|ji}||_|S)Nr%)rr format_maprepr __cause__)r+rmrr}s r!_invalid_metadataz_Validator._invalid_metadata<sC M3>>7D4G4G*HII    r rcd|tvr||dtd|S)Nz is not a valid metadata versionr)_VALID_METADATA_VERSIONSrr r+rs r!_process_metadata_versionz$_Validator._process_metadata_versionEs< 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 InvalidNamer+rr}s r! _process_namez_Validator._process_nameKs 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_versionXs 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_summarybs% 5==(()HII I r c>hd}tj}||d<||dj}}||vs||vr(|dt|d||dd}|dkr|d|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 CommonMarkvariantrz(valid Markdown variants for {field} are ) rr& EmailMessageget_content_typerparamsrlistr) r+r content_typesr& content_type parametersrmarkdown_variantsrs r!!_process_description_content_typez,_Validator._process_description_content_typehsjEEE -,,.."'  $ $ & & , , . . N # *!  } , , EKKMM0Q0Q((PD,?,?PPuPP ..G44 g  ((PWPP #L1..E22 ? * *w>O/O/O((#TBS=T=T####  r rcttj|D]?}|dvr||d|tvr||d@t ttj|S)N>r6rrz" is not allowed as a dynamic fieldz is not a valid dynamic field)mapr$rrrr )r+r 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)r+rnormalized_namesr6r}s 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)r+rreqsreqr}s 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_expressionrzrrs 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)r+rpathspaths 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')rerstripr_ isidentifierrkeyword iskeywordlstrip)r+r import_namer6 semicolonr7 identifiers r!_process_import_namesz _Validator._process_import_namessB   K'2'<'NOO  P P P P P P P P P P P P P P P (11OCO  23 3O& ) ))'%%58\#5F5L22'%%%"1#7Uc7U7U"V"VC%OOC000$H%%=$B$B2%% %|33$9#$>E"1 %#(!T!T#9!T!TAQ!T!T##C &OOC000$C%%%%&)))OOC(((((((()   1 2 2 2 sU"A??BB1E+4CE+2C<9E+;C<rz._Validator[NormalizedLicenseExpression | None]rQrRrAz1_Validator[list[requirements.Requirement] | None]rGz*_Validator[specifiers.SpecifierSet | None]rJrKz!_Validator[dict[str, str] | None]rMz-_Validator[list[utils.NormalizedName] | None]rOrHrIrrSrTrBrCrDrcLt}|||S)= Return an RFC822 message with the metadata. )r_write_metadata)r+r&s r! as_rfc822zMetadata.as_rfc822s& // W%%%r r&r'c>|jjD]\}}t|tr|dkrt ||}t |}||dkr%|D]\}}|d|||<j|dkrd|||<|dkr |gkrd||<t|tr|D]}t|||<t|||<|j | |j dSdS) rZr9Nrz, r:r^rr) r,ritemsrvrrrjoinr r$r9 set_payload) r+r&r6 validatorr email_namerirkitems r!r[zMetadata._write_metadatasj $~6<<>> 9 9OD))Z00 9T]5J5Jd++248 $!]22*/++--DDJE35:2C2Cc2C2CGJ//D#z11.1hhuoo ++#}44".0 ++#E4009$)<rQrRrArGrJrKrMrOrHrIrSrTrBrCrDr\r[rr r!rrs=A33333[3j?C[06@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:<rrs"""""" 877777777777''''''33333333 6555555FN3   """""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)CCCDDj7j7j7j7j7j7j7j7ZO2O2O2O2O2O2O2O2O2O2r