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 erJd d
lmZ d dlmZ d dlmZ G dd deZdS )    )annotations)contextmanager)TYPE_CHECKING)Any)document)table)ConfigSource)PropertyNotFoundError)drop_empty_config_category)Iterator)TOMLDocument)TOMLFilec                   @  s^   e Zd ZdddZeddd	Zedd
dZdddZdddZdddZ	e
dddZdS ) FileConfigSourcefiler   returnNonec                 C  s
   || _ d S N_file)selfr    r   t/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/poetry/config/file_config_source.py__init__   s   
zFileConfigSource.__init__strc                 C  s   t | jjS r   )r   r   pathr   r   r   r   name   s   zFileConfigSource.namec                 C  s   | j S r   r   r   r   r   r   r      s   zFileConfigSource.filekeyr   c                 C  sz   | d}| j r| j ni }t|D ]%\}}||vr(tdd| d|t|d kr6||   S || }qd S )N.zKey z not in config   )splitr   existsread	enumerater	   joinlen)r   r   keysconfigir   r   r   get_property#   s   

zFileConfigSource.get_propertyvaluec                 C  s   |   D}|}|d}t|D ]'\}}||vr%|t|d k r%t ||< |t|d kr3|||<  n|| }qW d    d S W d    d S 1 sKw   Y  d S )Nr   r   )securer    r#   r%   r   )r   r   r*   tomlr'   r&   r(   r   r   r   add_property1   s   




"zFileConfigSource.add_propertyc                 C  s   |   L}|}|d}|}t|D ]"\}}||vr# W d    d S |t|d kr0||=  n|| }qt|d d |d}|  || W d    d S 1 sSw   Y  d S )Nr   r   )r&   r'   )r+   r    r#   r%   r
   clearupdate)r   r   r,   r'   r&   current_configr(   r   r   r   remove_property@   s    

	
"z FileConfigSource.remove_propertyIterator[TOMLDocument]c                 c  s    | j  r| j  }| j  }nt }t }| j   }|V  zd}|r-| j jj|d | j | W d S  tyC   | j |  w )Ni  )mode)r   r!   r"   r   r   touchwrite	Exception)r   initial_configr'   new_filer4   r   r   r   r+   U   s"   

zFileConfigSource.secureN)r   r   r   r   )r   r   )r   r   )r   r   r   r   )r   r   r*   r   r   r   )r   r   r   r   )r   r3   )__name__
__module____qualname__r   propertyr   r   r)   r-   r2   r   r+   r   r   r   r   r      s    



r   N)
__future__r   
contextlibr   typingr   r   tomlkitr   r   poetry.config.config_sourcer   r	   r
   collections.abcr   tomlkit.toml_documentr   poetry.toml.filer   r   r   r   r   r   <module>   s    