+
    WBiCD                       R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^RIH	t	 ]P                  '       d   ^ RIt^ RIHtHtHt ^ RIHt ^RIHtHtHt RR.tR	 R
 lt]P.                  ! RR7       ! R R4      4       t]P.                  ! RR7       ! R R4      4       t]P4                  ! R4      t]P.                   ! R R]	4      4       tR# )z
This module focues on reading pyproject.toml fields with error collection. It is
mostly internal, except for License and Readme classes, which are re-exported in
the top-level package.
)annotationsN)ErrorCollector)	GeneratorIterableSequence)Requirement)ContactTableDynamicProjectTableLicenseReadmec                   V ^8  d   QhRR/# )   returnz	list[str] )formats   "A/usr/lib/python3.14/site-packages/pyproject_metadata/pyproject.py__annotate__r   "   s           c                     \         # )N)__all__r   r   r   __dir__r   "   s    Nr   T)frozenc                  0    ] tR t^&t$ RtR]R&   R]R&   RtR# )r   z
This represents a classic license, which contains text, and optionally a
file path. Modern licenses are just SPDX identifiers, which are strings.
strtextpathlib.Path | Nonefiler   N__name__
__module____qualname____firstlineno____doc____annotations____static_attributes__r   r   r   r   r   &   s    
 I
r   c                  :    ] tR t^1t$ RtR]R&   R]R&   R]R&   RtR# )	r   z_
This represents a readme, which contains text and a content type, and
optionally a file path.
r   r   r   r   content_typer   Nr   r   r   r   r   r   1   s    
 I
r   Tc                      ] tR t^@tRtR R ltR R ltR R ltR R	 ltR
 R lt	R R lt
R R ltR R ltR R ltR R ltR R ltR R ltRtR# )PyProjectReadera  Class for reading pyproject.toml fields with error collection.

Unrelated errors are collected and raised at once if the `collect_errors`
parameter is set to `True`. Some methods will return None if an error was
raised. Most of them expect a non-None value as input to enforce the caller
to handle missing vs. error correctly. The exact design is based on usage,
as this is an internal class.
c               $    V ^8  d   QhRRRRRR/# )r   valuer   keyr   z
str | Noner   )r   s   "r   r   PyProjectReader.__annotate__K   s!       # * r   c                r    \        V\        4      '       d   V# RpV P                  W2\        V4      R7       R# )z Ensure that a value is a string.3Field {key} has an invalid type, expecting a stringr-   got_typeN)
isinstancer   config_errortype)selfr,   r-   msgs   &&& r   
ensure_strPyProjectReader.ensure_strK   s3    eS!!LC#e=r   c               $    V ^8  d   QhRRRRRR/# )r   valzlist[T] | Noner-   r   r   r   )r   s   "r   r   r.   T   s!      ~ C N r   c                    Vf   R# \        V\        4      '       g!   RpV P                  W2\        V4      R7       R# V F:  p\        V\        4      '       d   K  RpV P                  W2\        V4      R7        R# 	  V# )z)Ensure that a value is a list of strings.Nz<Field {key} has an invalid type, expecting a list of stringsr1   z?Field {key} contains item with invalid type, expecting a string)r3   listr4   r5   r   )r6   r;   r-   r7   items   &&&  r   ensure_listPyProjectReader.ensure_listT   ss    ;#t$$PCcT#Y?DdC((W!!#d!D	  
r   c               $    V ^8  d   QhRRRRRR/# )r   r;   zdict[str, str]r-   r   r   zdict[str, str] | Noner   )r   s   "r   r   r.   d   s"      ~ C <Q r   c                   \        V\        4      '       g!   RpV P                  W2\        V4      R7       R# VP	                  4        FA  w  rE\        V\
        4      '       d   K  RpV P                  W2 RV 2\        V4      R7        R# 	  V# )z/Ensure that a value is a dictionary of strings.z=Field {key} has an invalid type, expecting a table of stringsr1   Nr0   .)r3   dictr4   r5   itemsr   )r6   r;   r-   r7   subkeyr>   s   &&&   r   ensure_dictPyProjectReader.ensure_dictd   s~    #t$$QCcT#Y?IIKLFdC((K!!#U!F8+<tDz!R	 (
 
r   c               $    V ^8  d   QhRRRRRR/# )r   r;   zSequence[ContactTable]r-   r   r   zlist[tuple[str, str | None]]r   )r   s   "r   r   r.   q   s)     *U *U)*U03*U	%*Ur   c                   \        V\        4      '       g!   RpV P                  W2\        V4      R7       . # V F  p\        V\        4      '       g-   RpV P                  W2\        V4      P
                  R7       . u # VP                  4        FG  p\        V\        4      '       d   K  RpV P                  W2\        V4      P
                  R7       . u u # 	  \        V4      RR0,
          pV'       g   K  RpV P                  VVR	P                  \        R
 V 4       4      4      R7       . u # 	  V Uu. uF%  qwP                  RR4      VP                  R4      3NK'  	  up# u upi )zNEnsure that a value is a list of tables with optional "name" and "email" keys.zeField {key} has an invalid type, expecting a list of tables containing the "name" and/or "email" keysr1   zField {key} has an invalid type, expecting a list of tables containing the "name" and/or "email" keys (got list with {type_name}))r-   	type_namezField {key} has an invalid type, expecting a list of tables containing the "name" and/or "email" keys (got list with dict with {type_name})nameemailzField {key} has an invalid type, expecting a list of tables containing the "name" and/or "email" keys (got list with dict with extra keys {extra_keys})z, c              3  .   "   T F  pR V R 2x  K  	  R# 5i)"Nr   ).0ks   & r   	<genexpr>0PyProjectReader.ensure_people.<locals>.<genexpr>   s     /M*Q!A3a*s   )r-   
extra_keysUnknown)r3   r=   r4   r5   rD   r   valuesr   setjoinsortedget)r6   r;   r-   r7   eachr,   rT   entrys   &&&     r   ensure_peoplePyProjectReader.ensure_peopleq   s^    #t$$C  cT#Y?IDdD))3 
 !!#$t*:M:M!N	!%--A 
 %%cd5k>R>R%SI ' Tfg%66JzI 
 !!#yy/M*/M)MN " 
 	= > QTTPSu69-uyy/ABPSTTTs   6+E$c               $    V ^8  d   QhRRRRRR/# )r   projectr
   project_dirpathlib.Pathr   zLicense | str | Noner   )r   s   "r   r   r.      s$     0# 0##0#2>0#	0#r   c                   VP                  R4      pVf   R# \        V\        4      '       d   V# \        V\        4      '       d   V P	                  VR4      pVf   R# M!RpV P                  VR\        V4      R7       R# V F%  pVR9  g   K  RpV P                  VR	V 2R
7        R# 	  RpVP                  R4      pVP                  R4      p	V'       d	   V	'       g   V'       g!   V	'       g   RpV P                  VRVR7       R# V'       dV   VP                  V4      pVP                  4       '       g   RV: R2pV P                  VRR
7       R# VP                  RR7      p	V	f   Q h\        W4      # )zGet the license field from the project table. Handles PEP 639 style license too.

None is returned if the license field is not present or if an error occurred.
licenseNzproject.licensezGField {key} has an invalid type, expecting a string or table of stringsr1   r   r   Unexpected field {key}zproject.license.r-   zFInvalid {key} contents, expecting a string or one key "file" or "text"r-   gotzLicense file not found ()zproject.license.fileutf-8encoding)r   r   )rZ   r3   r   rD   rG   r4   r5   joinpathis_file	read_textr   )
r6   r`   ra   r;   _licenser7   fieldr   filenamer   s
   &&&       r   get_licensePyProjectReader.get_license   sn    kk)$;c3Jc4  ''->?H   \Cc'849ME,,.!!#-=eW+E!F	  %)<<'||F#xX  c'8hG''1D<<>>0A>!!#+A!B>>7>3Dt""r   c               $    V ^8  d   QhRRRRRR/# )r   r`   r
   ra   rb   r   zlist[pathlib.Path] | Noner   )r   s   "r   r   r.      s)     L L#L2>L	"Lr   c                    VP                  R4      pVf   R# V P                  VR4      f   R# \        V P                  W#4      4      # )zGet the license-files list of files from the project table.

Returns None if an error occurred (including invalid globs, etc) or if
not present.
zlicense-filesNproject.license-files)rZ   r?   r=   _get_files_from_globs)r6   r`   ra   license_filess   &&& r   get_license_files!PyProjectReader.get_license_files   sH      O4 M+BCKD..{JKKr   c               $    V ^8  d   QhRRRRRR/# )r   r`   r
   ra   rb   r   zReadme | Noner   )r   s   "r   r   r.      s)     M0 M0#M02>M0	M0r   c                `   RV9  d   R# RpRpRpRpVR,          p\        V\        4      '       dS   RpTpVP                  R4      '       d   RpEMuVP                  R4      '       d   RpEMZRpV P                  VRVR	7       R# \        V\        4      '       Ed   V F%  p	V	R9  g   K  RpV P                  VRV	 2R7        R# 	  VP                  R
4      p
V
e   V P                  V
R4      pVf   R# VP                  R4      pVe   V P                  VR4      pVf   R# VP                  R4      pVe   V P                  VR4      pVf   R# V'       d	   V'       g   V'       g!   V'       g   RpV P                  VRVR7       R# V'       g   RpV P                  VRR7       R# M!RpV P                  VR\        V4      R7       R# V'       dR   VP                  V4      pVP                  4       '       g   RpV P                  VRVR	7       R# VP                  RR7      pVf   Q h\        WTV4      # )z}Get the text of the readme from the project table.

Returns None if an error occurred or if the readme field is not present.
readmeNz.mdztext/markdownz.rstz
text/x-rstz9Could not infer content type for readme file {filename!r}zproject.readme)r-   rr   content-typer   r   re   zproject.readme.rf   zproject.readme.content-typezproject.readme.filezproject.readme.textz9Invalid {key} contents, expecting either "file" or "text"rg   zField {key} missingzNField {key} has an invalid type, expecting either a string or table of stringsr1   z$Readme file not found ({filename!r})rj   rk   )r   r   r   )r3   r   endswithr4   rD   rZ   r8   r5   rm   rn   ro   r   )r6   r`   ra   rr   r   r   r'   r~   r7   rq   content_type_rawfilename_rawtext_raws   &&&          r   
get_readmePyProjectReader.get_readme   s6    7"#$(#'"fc""DH  ''.""6**+Q!!#+;h!O%% @@2C%%c/H%I	    &zz.9+#$&C   '!::f-L'??<9NO#zz&)H#x1FG<T8DQ!!#+;!H+!!#+H!I  
 cCc'7$v,O''1D<<>><!!#+@8!T>>7>3Dd,//r   c                    V ^8  d   QhRRRR/# )r   r`   r
   r   zlist[Requirement]r   )r   s   "r   r   r.   .  s       9J r   c                b   RpVP                  R4      pVe   V P                  VR4      pVf   . # . p V F1  pVP                  \        P                  P                  V4      4       K3  	  V#   \        P                  P                   d$   pRpT P                  TRXTR7       . u Rp?# Rp?ii ; i)z,Get the dependencies from the project table.Ndependencieszproject.dependenciesNField {key} contains an invalid PEP 508 requirement string {req!r} ({error!r})r-   reqerror)rZ   r?   append	packagingrequirementsr   InvalidRequirementr4   )r6   r`   requirement_stringsrequirement_strings_rawr   r   er7   s   &&      r   get_dependencies PyProjectReader.get_dependencies.  s    04")++n"="."&"2"2')?# &I*,	*##I$:$:$F$Fs$KL + 	 %%88 	bCc'=3aPI	s   7A, ,B.B)#B.)B.c                    V ^8  d   QhRRRR/# )r   r`   r
   r   zdict[str, list[Requirement]]r   )r   s   "r   r   r.   C  s     4' 4'4' 
&4'r   c           
     N   VP                  R4      pV'       g   / # / p\        V\        4      '       g"   RpV P                  VR\	        V4      R7       / # VP                  4       P                  4        F  w  rV\        V\        4      '       g   Q h\        V\        4      '       g'   RpV P                  VRV 2\	        V4      R7       / u # . W5&   V Fv  p\        V\        4      '       g)   RpV P                  VRV 2\	        V4      R7       / u u #  W5,          P                  \        P                  P                  V4      4       Kx  	  K  	  \        V4      #   \        P                  P                   d+   pRpT P                  TRT 2TTR7       / u R	p?u u # R	p?ii ; i)
z5Get the optional dependencies from the project table.zoptional-dependencieszQField {key} has an invalid type, expecting a table of PEP 508 requirement stringszproject.optional-dependenciesr1   zproject.optional-dependencies.zGField {key} has an invalid type, expecting a PEP 508 requirement stringr   r   N)rZ   r3   rD   r4   r5   copyrE   r   r=   r   r   r   r   r   )	r6   r`   r;   requirements_dictr7   extrar   r   r   s	   &&       r   get_optional_dependencies)PyProjectReader.get_optional_dependenciesC  s   
 kk12I:<#t$$eC849   I#&88:#3#3#5EeS))))lD11i!!8@!,/ " 
 	')$#!#s++cC%%<UGD!%c & 
 I%,33!..::3? $ $6H %&& !--@@ T  %%<UGD	 &  IIs   4EF$:FF$F$c                    V ^8  d   QhRRRR/# )r   r`   r
   r   zdict[str, dict[str, str]]r   )r   s   "r   r   r.   y  s     & &| &8Q &r   c           	        VP                  RR4      pVf   / # \        V\        4      '       g"   RpV P                  VR\	        V4      R7       / # VP                  4        EF  w  rE\        V\        4      '       g   Q h\        P                  ! RV4      '       g   RpV P                  VRVR7       / u # \        V\        4      '       g'   R	pV P                  VR
V 2\	        V4      R7       / u # VP                  4        F^  w  rg\        V\        4      '       g   Q h\        V\        4      '       d   K5  RpV P                  VR
V RV 2\	        V4      R7       / u u # 	  EK  	  V# )z+Get the entrypoints from the project table.zentry-pointsNzIField {key} has an invalid type, expecting a table of entrypoint sectionszproject.entry-pointsr1   z^\w+(\.\w+)*$znField {key} has an invalid value, expecting a name containing only alphanumeric, underscore, or dot charactersrg   zAField {key} has an invalid type, expecting a table of entrypointszproject.entry-points.r0   rC   )	rZ   r3   rD   r4   r5   rE   r   rematch)r6   r`   r;   r7   sectionentrypointsrL   
entrypoints   &&      r   get_entrypointsPyProjectReader.get_entrypointsy  sj   kk.$/;I#t$$]Cc'=S	RI$'IIK Ggs++++88,g66R  !!#+Aw!O	k400W  !!/y9!+. " 
 	$/$5$5$7 !$,,,,!*c22OC%%3G9AdVD!%j!1 & 
 I %8' %0: 
r   c                    V ^8  d   QhRRRR/# )r   r`   r
   r   zlist[Dynamic]r   )r   s   "r   r   r.     s      < M r   c                    VP                  R. 4      pV P                  VR4       RV9   d   RpV P                  VRR7       . # V# )z{Get the dynamic fields from the project table.

Returns an empty list if the field is not present or if an error occurred.
dynamiczproject.dynamicrL   z!Unsupported field 'name' in {key}rf   )rZ   r?   r4   )r6   r`   r   r7   s   &&  r   get_dynamicPyProjectReader.get_dynamic  sP    
 ++i,"34W5Cc'89Ir   c               $    V ^8  d   QhRRRRRR/# )r   ra   rb   globszIterable[str]r   z#Generator[pathlib.Path, None, None]r   )r   s   "r   r   r.     s$     1 1'10=1	,1r   c              #  r  "   V F  pVP                  R4      '       d   RpV P                  VRVR7        R# VP                  V4       Uu. uF  qUP                  4       '       g   K  VNK  	  ppV'       g   RpV P                  VRVR7        R# V F  pVP	                  V4      x  K  	  K  	  R# u upi 5i)z,Given a list of globs, get files that match.z\{glob!r} is an invalid {key} glob: the pattern must match files within the project directoryrw   )r-   globzOEvery pattern in {key} must match at least one file: {glob!r} did not match anyN)z../)
startswithr4   r   rn   relative_to)r6   ra   r   r   r7   ffiless   &&&    r   rx   %PyProjectReader._get_files_from_globs  s      D{++t!!#+B!N + 0 0 6F 61))+QQ 6EFg!!#+B!NmmK00  
 Gs   A	B7B2'B2-A
B7r   N)r   r    r!   r"   r#   r8   r?   rG   r]   rs   rz   r   r   r   r   r   rx   r%   r   r   r   r*   r*   @   sP     *UX0#dL M0^*4'l&P 1 1r   r*   )r#   
__future__r   dataclassesr   typingpackaging.requirementsr   errorsr   TYPE_CHECKINGpathlibcollections.abcr   r   r   r   project_tabler   r	   r
   r   r   	dataclassr   r   TypeVarr(   r*   r   r   r   <module>r      s    #  	   "	==2BB  d#  $ d#  $ NN3 1n 1 1r   