Ë
    tPêjo  ã                  ó&  — d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	m
Z
mZ ddlZddlZddlmZ ddlmZ dd	lmZmZmZ dd
lmZ ddlmZmZ ddlmZ ddlmZmZ  ej@                  e!«      Z" G d„ de«      Z# G d„ de«      Z$ G d„ de«      Z%y)z3
Collect dependencies from `pyproject.toml` files.
é    )ÚannotationsN)ÚIterator)ÚPath)ÚNamedTemporaryFileÚTemporaryDirectory)ÚRequirement)ÚSpecifierSet)ÚDependencyFixErrorÚDependencySourceÚDependencySourceError)ÚResolvedFixVersion)Ú
DependencyÚResolvedDependency)Ú
AuditState)Ú
VirtualEnvÚVirtualEnvErrorc                  óL   — e Zd ZdZdg  e«       f	 	 	 	 	 	 	 	 	 dd„Zdd„Zdd„Zy)	ÚPyProjectSourcezN
    Wraps `pyproject.toml` dependency resolution as a dependency source.
    Nc                ó    — || _         || _        y)a.  
        Create a new `PyProjectSource`.

        `filename` provides a path to a `pyproject.toml` file

        `index_url` is the base URL of the package index.

        `extra_index_urls` are the extra URLs of package indexes.

        `state` is an `AuditState` to use for state callbacks.
        N)ÚfilenameÚstate)Úselfr   Ú	index_urlÚextra_index_urlsr   s        úk/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/pip_audit/_dependency_source/pyproject.pyÚ__init__zPyProjectSource.__init__$   s   € ð$ !ˆŒØˆ�
ó    c           	   #  ó†  K  — | j                   j                  d«      5 }t        j                  |«      }|j	                  d«      }|€t        d| j                   › d�«      ‚|j	                  d«      }|€-t        j                  d| j                   › d�«       	 ddd«       yt        «       5 }t        |d¬	«      5 }|j                  t        j                  j                  |«      j                  «       «       |j                  «        t!        d
|j"                  g| j$                  ¬«      }	 |j'                  |«       |j,                  D ]  \  }	}
t/        |	|
¬«      –— Œ 	 ddd«       ddd«       ddd«       y# t(        $ r}t        t+        |«      «      |‚d}~ww xY w# 1 sw Y   Œ@xY w# 1 sw Y   ŒDxY w# 1 sw Y   yxY w­w)z�
        Collect all of the dependencies discovered by this `PyProjectSource`.

        Raises a `PyProjectSourceError` on any errors.
        ÚrbÚprojectNúpyproject file ú# does not contain `project` sectionÚdependenciesú% does not contain `dependencies` listF)ÚdirÚdeletez-r)Úinstall_argsr   )ÚnameÚversion)r   ÚopenÚtomliÚloadÚgetÚPyProjectSourceErrorÚloggerÚwarningr   r   ÚwriteÚosÚlinesepÚjoinÚencodeÚflushr   r(   r   Úcreater   ÚstrÚinstalled_packagesr   )r   ÚfÚpyproject_datar    ÚdepsÚve_dirÚreq_fileÚveÚexcr(   r)   s              r   ÚcollectzPyProjectSource.collect9   s²  è ø€ ð �]‰]×Ñ Ó%ð *	I¨Ü"ŸZ™Z¨›]ˆNà$×(Ñ(¨Ó3ˆGØˆÜ*Ø% d§m¡m _Ð4WÐXóð ð —;‘;˜~Ó.ˆDØˆ|ä—‘Ø% d§m¡m _Ð4YÐZôð ÷*	Ið *	Iô, #Ó$ðIØ(.Ü" v°eÔ<ðIà@Hð —‘œrŸz™zŸ™¨tÓ4×;Ñ;Ó=Ô>Ø—‘Ô ô  ¨d°H·M±MÐ-BÈ$Ï*É*ÔU�ðBØ—I‘I˜fÔ%ð
 &(×%:Ñ%:ò I‘M�D˜'Ü,°$ÀÔHÓHñI÷)I÷ I÷+*	Ið *	IøôJ 'ò BÜ.¬s°3«xÓ8¸cÐAûðBú÷!Ið Iú÷ Ið Iú÷+*	Ið *	Iüs~   ‚GžA9F5Â	GÂ 
F5Â*F)Â8A0FÄ)E7Ä:#FÅF)Å&F5Å.	GÅ7	F	Æ F	ÆF	ÆFÆF&Æ"F)Æ)F2	Æ.F5Æ5F>Æ:Gc                óF  — | j                   j                  d«      5 }t        dd¬«      5 }t        j                  |«      }|j                  d«      }|€t        d| j                   › d�«      ‚|j                  d«      }|€5t        j                  d| j                   › d	�«       	 ddd«       ddd«       y|D �cg c]  }t        |«      ‘Œ }}t        t        |«      «      D ]Ò  }	||	   }
|
j                  |j                  j                  k(  r|
j                  j                  |j                  j                   «      rP|
j                  j                  |j                   «      s+t#        d
|j                   › �«      |
_        t%        |
«      ||	<   |
j&                  €Œ·|
j&                  j)                  «       rŒÒJ ‚ t+        j,                  ||«       ddd«       ddd«       t/        j0                  j                  | j                   «       yc c}w # 1 sw Y   ŒAxY w# 1 sw Y   ŒExY w)zH
        Fixes a dependency version for this `PyProjectSource`.
        zrb+F)Úmoder&   r    Nr!   r"   r#   r$   z==)r   r*   r   r+   r,   r-   ÚPyProjectFixErrorr/   r0   r   ÚrangeÚlenr(   ÚdepÚ	specifierÚcontainsr)   r	   r8   ÚmarkerÚevaluateÚtomli_wÚdumpr2   Úreplace)r   Úfix_versionr:   Útmpr;   r    r<   rG   ÚreqsÚiÚreqs              r   ÚfixzPyProjectSource.fixl   sÔ  € ð
 �]‰]×Ñ Ó&ð  	.¨!Ô-?ÀUÐSXÔ-Yð  	.Ð]`Ü"ŸZ™Z¨›]ˆNà$×(Ñ(¨Ó3ˆGØˆÜ'Ø% d§m¡m _Ð4WÐXóð ð —;‘;˜~Ó.ˆDØˆ|ä—‘Ø% d§m¡m _Ð4YÐZôð ÷ 	.÷  	.ð  	.ð" 15Ö5¨”K Õ$Ð5ˆDÐ5Üœ3˜t›9Ó%ò C�ð ˜1‘g�à—H‘H §¡× 4Ñ 4Ò4ØŸ™×.Ñ.¨{¯©×/FÑ/FÔGØŸM™M×2Ñ2°;×3FÑ3FÔGä$0°2°k×6IÑ6IÐ5JÐ1KÓ$L�C”MÜ! #›h�D˜‘GØ—z‘zÑ)¨S¯Z©Z×-@Ñ-@Õ-BÐBÐBðCô �L‰L˜¨Ô-÷A 	.÷  	.ôF 	�
‰
�3—8‘8˜TŸ]™]Õ+ùò% 6÷# 	.ð  	.ú÷  	.ð  	.úsN   œHªA9HÂ#HÂ4HÂ8HÃ
CHÆHÆ2HÇHÈHÈH	ÈHÈH )
r   r   r   z
str | Noner   z	list[str]r   r   ÚreturnÚNone)rU   zIterator[Dependency])rO   r   rU   rV   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   rA   rT   © r   r   r   r      sU   „ ñð !%Ø&(Ù&›Lðàðð ðð $ð	ð
 ðð 
óó*1Iôf(,r   r   c                  ó   — e Zd ZdZy)r.   z4A `pyproject.toml` specific `DependencySourceError`.N©rW   rX   rY   rZ   r[   r   r   r.   r.   —   s   „ Ù>àr   r.   c                  ó   — e Zd ZdZy)rD   z1A `pyproject.toml` specific `DependencyFixError`.Nr]   r[   r   r   rD   rD   �   s   „ Ù;àr   rD   )&rZ   Ú
__future__r   Úloggingr2   Úcollections.abcr   Úpathlibr   Útempfiler   r   r+   rL   Úpackaging.requirementsr   Úpackaging.specifiersr	   Úpip_audit._dependency_sourcer
   r   r   Úpip_audit._fixr   Úpip_audit._servicer   r   Úpip_audit._stater   Úpip_audit._virtual_envr   r   Ú	getLoggerrW   r/   r   r.   rD   r[   r   r   ú<module>rl      s~   ðñõ #ã Û 	Ý $Ý ß ;ã Û Ý .Ý -÷ñ õ
 .ß =Ý 'ß >à	ˆ×	Ñ	˜8Ó	$€ôu,Ð&ô u,ôp	Ð0ô 	ô	Ð*õ 	r   