o
    Vhl                     @  s   d dl mZ d dlmZ d dlmZ d dlmZ d dlmZ er8d dl	m
Z
 d dlmZ d dlmZ d d	lmZ G d
d dZdS )    )annotations)defaultdict)TYPE_CHECKING)Any)get_extra_package_names)NormalizedName)Package)	Operation)TransitivePackageInfoc                   @  sB   e Zd Z				d"d#ddZd$ddZddddddd%d d!ZdS )&TransactionNcurrent_packageslist[Package]result_packages4list[Package] | dict[Package, TransitivePackageInfo]installed_packageslist[Package] | Noneroot_packagePackage | None
marker_envdict[str, Any] | Nonegroupsset[str] | NonereturnNonec                 C  s>   || _ || _|d u rg }dd |D | _|| _|| _|| _d S )Nc                 S  s   i | ]}|j |qS  name).0pkgr   r   m/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/poetry/puzzle/transaction.py
<dictcomp>"   s    z(Transaction.__init__.<locals>.<dictcomp>)_current_packages_result_packages_installed_packages_root_package_marker_env_groups)selfr   r   r   r   r   r   r   r   r   __init__   s   	
zTransaction.__init__$dict[Package, TransitivePackageInfo]c                 C  s   t | jtsJ | jS N)
isinstancer"   dict)r'   r   r   r   get_solved_packages'   s   zTransaction.get_solved_packagesTF)with_uninstallssynchronizeskip_directoryextrassystem_site_packagesr.   boolr/   r0   r1   set[NormalizedName] | Noner2   list[Operation]c                C  s  ddl m} ddl m} ddl m} |st }g }	t }
| jr-| j }|d ur,||d< n|d urH| jd us8J t| j	dd | jj
 D |}
t| j	trYdd | j	 D }ntt}t }| j	D ]}d	}| jr| jd usqJ t| j	tsyJ | j	| }|j| j@ r|| j|r||j n|jrd
}nqc|d uo|jo|j|
v}|s||j | j|j }r|rqc|j|jks|js|jdkr||s|	||||| d qc|	||d qc|r|jdks|||| d}|r|d |	| qc|rt }dd | j	D }| jD ](}|j||B vr;| j|j }r;||j |j|vr;|	|| q|rdh| }| j D ]:}|j|v rTqJ| jrb|j| jjkrbqJ|j|v rjqJ|j|vr||j |j|vr|	|| qJt |	dd dS )Nr   )Install)	Uninstall)Updateextrac                 S  s    i | ]\}}|d d |D qS )c                 S  s   g | ]}|j qS r   r   )r   dr   r   r   
<listcomp>F       z?Transaction.calculate_operations.<locals>.<dictcomp>.<listcomp>r   )r   kvr   r   r   r    F   s     z4Transaction.calculate_operations.<locals>.<dictcomp>c                 S  s   i | ]\}}||j qS r   )depth)r   r   infor   r   r   r    K   s    FTlegacy)priorityzAlready installed	directoryzNot requiredc                 S  s   h | ]}|j qS r   r   )r   packager   r   r   	<setcomp>   r<   z3Transaction.calculate_operations.<locals>.<setcomp>pipc                 S  s   | j  | jj| jjfS r*   )rB   rD   r   version)or   r   r   <lambda>   s   z2Transaction.calculate_operations.<locals>.<lambda>)key)!poetry.installation.operationsr6   r7   r8   setr%   copyr$   r   r"   r1   itemsr+   r,   r   intr&   r   
get_markervalidateaddr   optionalr#   getrG   source_typeis_same_package_asappendskipr!   valuessorted)r'   r.   r/   r0   r1   r2   r6   r7   r8   
operationsextra_packagesmarker_env_with_extras
prioritiesrelevant_result_packagesresult_packageis_unsolicited_extrar@   installed_packageop
uninstallsr   current_packagepreserved_package_namesr   r   r   calculate_operations+   s   	







z Transaction.calculate_operations)NNNN)r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r)   )r.   r3   r/   r3   r0   r3   r1   r4   r2   r4   r   r5   )__name__
__module____qualname__r(   r-   rg   r   r   r   r   r      s    
r   N)
__future__r   collectionsr   typingr   r   poetry.utils.extrasr   packaging.utilsr   poetry.core.packages.packager   (poetry.installation.operations.operationr	   'poetry.packages.transitive_package_infor
   r   r   r   r   r   <module>   s    