o
    Vh                     @  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 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rVd dlmZ d dlmZ G dd deZdS )    )annotations)TYPE_CHECKING)Any)ClassVar)argument)option)NullIO)table)AoT)Source)Command)Priority)Argument)Optionc                
   @  s   e Zd ZU dZdZeddeddddgZd	ed
< edddd	dd e
D  de
jj  de
jj  dddgZded< dddZdS )SourceAddCommandz
source addz%Add source configuration for project.namezSource repository name.urlzNSource repository URL. Required, except for PyPI, for which it is not allowed.T)optionalzClassVar[list[Argument]]	argumentsprioritypz)Set the priority of this source. One of: z, c                 c  s    | ]}|j  V  qd S )N)r   lower).0r    r   v/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/poetry/console/commands/source/add.py	<genexpr>-   s    zSourceAddCommand.<genexpr>z. Defaults to z, but will switch to z in a later release.F)flagzClassVar[list[Option]]optionsreturnintc              
   C  s  ddl m} | d}| }| d}| dd }|dkr*d}|r)| d d	S n	|s3| d
 d	S |d u rI| jdtj	j
  d tj}nt|  }tg }t|||d}d}	| j D ]}
|
j
 |krn|}
d}	||
  qa|	r| d| d ||  n	| d| d z|| jj|t }|| W n ty } z| d| d| d W Y d }~d	S d }~ww | jjj}d|vrt |d< d|d vrt |d d< || jjjd< | jj  dS )Nr   )Factoryr   r   r   pypiPyPIz:<error>The URL of PyPI is fixed and cannot be set.</error>   z=<error>A custom source cannot be added without a URL.</error>z0<warning>The default priority will change to <b>z</> in a future release.</>)r   r   r   TFzAdding source with name <c1>z</c1>.zSource with name <c1>z</c1> already exists. Updating.z*<error>Failed to validate addition of <c1>z</c1>: z</error>toolpoetrysource)poetry.factoryr    r   r   r   
line_erroriowrite_error_liner   SUPPLEMENTALr   PRIMARYupperr
   r   r%   get_sourcesappendto_toml_tablelinecreate_poolconfigr   
repository
ValueError	pyprojectdatar	   poetry_configsave)selfr    r   
lower_namer   priority_strr   sources
new_sourceis_new_sourcer&   poolecontentr   r   r   handle4   sl   



zSourceAddCommand.handleN)r   r   )__name__
__module____qualname__r   descriptionr   r   __annotations__r   joinr   r,   r   r+   r   rC   r   r   r   r   r      s6   
 

r   N)
__future__r   typingr   r   r   cleo.helpersr   r   cleo.io.null_ior   tomlkitr	   tomlkit.itemsr
   poetry.config.sourcer   poetry.console.commands.commandr   #poetry.repositories.repository_poolr   cleo.io.inputs.argumentr   cleo.io.inputs.optionr   r   r   r   r   r   <module>   s     