o
    Vh                     @  s   d dl mZ d dlZ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
 d dlmZ d d	lmZ d d
lmZ erNd dlmZ d dlmZ d dlmZ G dd deZdS )    )annotationsN)TYPE_CHECKING)ClassVar)argument)option)Version)InvalidVersionError)Config)Command)Argument)Option)IOc                   @  sb   e Zd ZU dZeddddgZded< edd	d
dddgZded< dZ	e
dddZdddZdS )PythonRemoveCommandzpython removepythonzThe python version to remove.T)multiplezClassVar[list[Argument]]	argumentsimplementationiz-Python implementation to use. (cpython, pypy)Fcpython)flagdefaultzClassVar[list[Option]]optionszcRemove the specified Python version if managed by Poetry. (<warning>experimental feature</warning>)requeststrior   returnintc              
   C  sB  zt | }W n ttfy   |d|  d Y dS w |jr&|jr&|js6|d|  d |d dS d|  d| d}t	 j
| d	|  }| r| r[|d
|  |d| d zt| W n# ty } z|d | r|d|  W Y d }~nd }~ww |d dS |d| d dS )Nz+<error>Invalid Python version requested <b>z</></error>   z</></error>
zYou need to provide an exact Python version in the format <c1>X.Y.Z</> to be removed.

You can use <c1>poetry python list -m</> to list installed Poetry managed Python versions.z<c1>z</> (<b>z</>)@zInstallation path: zRemoving installation z ... z<fg=red>Failed</>
zFailed to remove directory: z<fg=green>Done</>
zNo installation was found at .r   )r   parse
ValueErrorr   write_error_linemajorminorpatchr	   createpython_installation_direxists
is_verbose
write_linewriteshutilrmtreeOSError)r   r   r   versionrequest_titlepathe r3   y/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/poetry/console/commands/python/remove.pyremove_python_installation,   sD   



z.PythonRemoveCommand.remove_python_installationc                 C  s:   |  d }d}| dD ]}|| ||| j7 }q|S )Nr   r   r   )r   lowerr   r5   r   )selfr   resultr   r3   r3   r4   handleX   s
   zPythonRemoveCommand.handleN)r   r   r   r   r   r   r   r   )r   r   )__name__
__module____qualname__namer   r   __annotations__r   r   descriptionstaticmethodr5   r9   r3   r3   r3   r4   r      s"   
 +r   )
__future__r   r,   typingr   r   cleo.helpersr   r   'poetry.core.constraints.version.versionr   poetry.core.version.exceptionsr   poetry.config.configr	   poetry.console.commands.commandr
   cleo.io.inputs.argumentr   cleo.io.inputs.optionr   
cleo.io.ior   r   r3   r3   r3   r4   <module>   s    