o
    Vh<                     @  sP  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 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 d dlmZ d dlmZ d dlmZ erd dlmZ d dlm Z  d dlm!Z! edddeddedddgZ"G d d! d!eZ#dS )"    )annotationsNPath)TYPE_CHECKING)Any)ClassVar)cast)argument)option)canonicalize_name)PackageFilterPolicy)boolean_normalizer)boolean_validator)build_config_setting_normalizer)build_config_setting_validator)int_normalizer)UNSET)ConfigSourceMigration)PropertyNotFoundError)Command)Argument)Option)ConfigSourcezexperimental.system-git-clientsystem-git-client)old_keynew_keyz virtualenvs.prefer-active-pythonvirtualenvs.use-poetry-pythonT)TF)r   r   value_migrationc                   @  s   e Zd ZU dZdZeddddeddddd	gZd
ed< edddedddedddedddgZ	ded< dZ
ddhZded< ed5ddZd6d!d"Zd7d*d+Z	,d8d9d1d2Zd:d3d4ZdS );ConfigCommandconfigzManages configuration settings.keyzSetting key.T)optionalvaluezSetting value.)r!   multiplezClassVar[list[Argument]]	argumentslistNzList configuration settings.unsetzUnset configuration setting.localz/Set/Get from the project's local configuration.migratez(Migrate outdated configuration settings.zClassVar[list[Option]]optionsa*  This command allows you to edit the poetry config settings and repositories.

To add a repository:

    <comment>poetry config repositories.foo https://bar.com/simple/</comment>

To remove a repository (repo is a short alias for repositories):

    <comment>poetry config --unset repo.foo</comment>
http-basic
pypi-tokenzClassVar[set[str]]LIST_PROHIBITED_SETTINGSreturndict[str, tuple[Any, Any]]c                 C  s   i dt dd fdttfdttfdttfdttfdttfd	t d
d fdttfdt t fdttfddd tfdttfdttfddd tfdtjtjfdtjtjfdttfdttfi}|S )Nz	cache-dirc                 S     t t| S Nstrr   val r5   r/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/poetry/console/commands/config.py<lambda>N       z4ConfigCommand.unique_config_values.<locals>.<lambda>zvirtualenvs.createzvirtualenvs.in-projectzvirtualenvs.options.always-copyz(virtualenvs.options.system-site-packageszvirtualenvs.options.no-pipzvirtualenvs.pathc                 S  r/   r0   r1   r3   r5   r5   r6   r7   W   r8   r   zvirtualenvs.promptr   zrequests.max-retriesc                 S  s   t | dkS Nr   intr3   r5   r5   r6   r7   [   r8   zinstaller.re-resolvezinstaller.parallelzinstaller.max-workersc                 S  s   t | dkS r9   r:   r3   r5   r5   r6   r7   ^   r8   zinstaller.no-binaryzinstaller.only-binaryzsolver.lazy-wheelzkeyring.enabled)r2   r   r   r   r   	validator	normalize)selfunique_config_valuesr5   r5   r6   r?   K   s^   	
z"ConfigCommand.unique_config_valuesr;   c              	   C  s  ddl m} ddlm} ddlm} ddlm} ddlm	} ddl
m} | dr-|   | }||d	 }z|| jjjjd
 }	|	 rM||	  W n t|fya   || d
 }	Y nw | drn|||	 | s|jjjddd |jjdd | dr| | |  dS | d}
|
sdS | dr| drtd| ds| ds|
dd | j v rt!d|
 dt"#d| d }r|$ds|%d }r| || dS | &d dS t'|$d}d| }|%| }r| &t()| dS | &d| d dS t"#d | d }r`|$ds:i }|%d!d ur9|%d!}n|%d"|$d }|d u rUt!d#|$d d$|}| &t*| dS |
| j+vrnt!d#|
 d|%|
}t,|t*s~t()|}| &| dS | d}|
| j+v r| dr|j-.|
 dS | /|j-|
| j+|
 |S t"#d | d}|r|$dst!d%| dr|%d"|$d }|d u rt!d#|$d d$|j-.d"|$d  dS t0|dkr
|d }|j-1d"|$d d&| dS t!d't"#d(| d}|rdd)l2m3} ||}| drN|$dd*kr<|4|$d dS |$dd+krL|5|$d dS |$dd*krt0|dkro|d }| 6d,}t,|t*snJ nt0|dkrt!d-t0| |d }|d }|7|$d|| dS |$dd+krt0|dkrt!d.t0| |d }|8|$d| dS t"#d/| d}|r|$d}|$d}| dr|j9.d0| d|  dS t0|dkr|d }|d1krt:|d rt;|d }|j91d0| d| | dS t!d2t"#d3| d}|r{dt'|$d }| dr8|j-.| dS z|j-<|}W n t=yL   i }Y nw |D ]"}t>|rjt?|}|@ D ]	\}}|||< q^qOt!d4| d5|j-1|| dS t!d6| d d7)8Nr   r   )PyProjectError)ConfigFileConfigSource
CONFIG_DIRTOMLFiler(   config.tomlpoetry.tomlr'   T)parentsexist_oki  )moder%   r    r"   r&   z0You can not combine a setting value with --unset.zExpected a value for z	 setting.z,installer\.build-config-settings(\.([^.]+))?   zinstaller.build-config-settingsz2No packages configured with build config settings.   z installer.build-config-settings.z,No build config settings configured for <c1>z</>.z^repos?(?:itories)?(?:\.(.+))?repositoriesrepositories.zThere is no z repository definedz,You cannot remove the [repositories] sectionz.urlzNYou must pass the url. Example: poetry config repositories.foo https://bar.comz^(http-basic|pypi-token)\.(.+))PasswordManagerr*   r+   z	Password:z8Expected one or two arguments (username, password), got z(Expected only one argument (token), got z)certificates\.([^.]+)\.(cert|client-cert)zcertificates.certzYou must pass exactly 1 valuez)installer\.build-config-settings\.([^.]+)zInvalid build config setting 'zL'. It must be a valid JSON with each property a string or a list of strings.zSetting z does not exist)Apathlibr    poetry.core.pyproject.exceptionsr@   poetry.config.configrA    poetry.config.file_config_sourcerC   poetry.locationsrE   poetry.toml.filerG   r
   _migratecreatepoetryfilepathparentexistsmergereadRuntimeErrorcwdset_config_sourcemkdirtouch_list_configurationallrawr	   splitr,   
ValueErrorrematchgroupgetliner   jsondumpsr2   r?   
isinstanceconfig_sourceremove_property_handle_single_valuelenadd_propertypoetry.utils.password_managerrR   delete_http_passworddelete_pypi_tokensecretset_http_passwordset_pypi_tokenauth_config_sourcer   r   get_propertyr   r   r   items)r>   r   r@   rA   rC   rE   rG   r   config_filelocal_config_filesetting_keymr"   package_namer    repovaluesurlrR   password_managerusernamepasswordtoken
repository	new_valuesettingsconfig_settingssetting_nameitemr5   r5   r6   handlem   s\  





















zConfigCommand.handlesourcer   r2   	callbackstuple[Any, Any]r   	list[Any]c                 C  sT   |\}}t |dkrtd|d }||s td| d| |||| dS )NrN   zYou can only pass one value.r   "z" is an invalid value for )rx   rc   ry   )r>   r   r    r   r   r<   
normalizerr"   r5   r5   r6   rw   X  s   z"ConfigCommand._handle_single_value dict[str, Any]rj   kNonec           	      C  s  |}t | D ]\}}|| | jv rq||}t|tr5|| d7 }td|}| j|||d |}qt|trJd	dd |D }d| d}|
d	r^d
||  dt| d}n(t|trx||krxd
||  dt| d| }nd
||  dt| d}| | qd S )NrM   r   )r   z, c                 s  s(    | ]}t |trt|n|V  qd S r0   )rt   r%   rr   rs   ).0r4   r5   r5   r6   	<genexpr>~  s    
z4ConfigCommand._list_configuration.<locals>.<genexpr>[]rQ   z<c1>z</c1> = <c2>z</c2>z	</c2>  # )sortedr   r,   rp   rt   dictr   rh   r%   join
startswithrr   rs   r2   rq   )	r>   r   rj   r   orig_kr    r"   raw_valmessager5   r5   r6   rh   l  s0   





z!ConfigCommand._list_configurationc                   s   ddl m} ddlm} ddlm} ||d }dr/|jjj	j
d }| s/td|| jd	  fd
dtD }|sMjd d S j rXddrj|D ]}|  qZjd d S d S )Nr   rB   rD   rF   rH   r'   rI   zNo local config file foundz$Checking for required migrations ...c                   s    g | ]}|j  jd r|qS ))io)dry_runr   )r   	migrationru   r>   r5   r6   
<listcomp>  s    z*ConfigCommand._migrate.<locals>.<listcomp>zAlready up to date.zProceed with migration?: Fz#Config migration successfully done.)rW   rC   rX   rE   rY   rG   r
   r\   r]   r^   r_   r`   rc   r   
write_lineCONFIG_MIGRATIONSis_interactiveconfirmapply)r>   rC   rE   rG   r   required_migrationsr   r5   r   r6   rZ     s.   
zConfigCommand._migrate)r-   r.   )r-   r;   )
r   r   r    r2   r   r   r   r   r-   r;   )r   )r   r   rj   r   r   r2   r-   r   )r-   r   )__name__
__module____qualname__namedescriptionr	   r$   __annotations__r
   r)   helpr,   propertyr?   r   rw   rh   rZ   r5   r5   r5   r6   r   .   s*   
 




! 
l"r   )$
__future__r   rr   rm   rT   r   typingr   r   r   r   cleo.helpersr	   r
   installer.utilsr   rV   r   r   r   r   r   r   poetry.config.config_sourcer   r   r   poetry.console.commands.commandr   cleo.io.inputs.argumentr   cleo.io.inputs.optionr   r   r   r   r5   r5   r5   r6   <module>   sF    