o
    Vh                     @  sx   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r2d dlmZ G d	d
 d
eZdS )    )annotations)TYPE_CHECKING)PyProjectTOML)table)Table)TOMLDocument)TOMLFile)Pathc                      sR   e Zd ZdZd fddZedd	d
ZedddZdddZdddZ	  Z
S )r   z
    Enhanced version of poetry-core's PyProjectTOML
    which is capable of writing pyproject.toml

    The poetry-core class uses tomli to read the file,
    here we use tomlkit to preserve comments and formatting when writing.
    pathr	   returnNonec                   s"   t  | t|d| _d | _d S )N)r
   )super__init__r   
_toml_file_toml_document)selfr
   	__class__ i/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/poetry/pyproject/toml.pyr      s   
zPyProjectTOML.__init__r   c                 C  s   | j S N)r   r   r   r   r   file   s   zPyProjectTOML.filer   c                 C  s4   | j d u r| j st | _ | j S | j | _ | j S r   )r   r   existsr   readr   r   r   r   data#   s   

zPyProjectTOML.datac                 C  sb   | j }| jd ur(d|vrt |d< |d }t|tsJ | jj|d< | jj|d< | jj|d d S )Nzbuild-systemrequireszbuild-backend)r   )	r   _build_systemr   
isinstancer   r   build_backendr   write)r   r   build_systemr   r   r   save-   s   

zPyProjectTOML.savec                 C  s   d | _ d | _d S r   )r   r   r   r   r   r   reload<   s   
zPyProjectTOML.reload)r
   r	   r   r   )r   r   )r   r   )r   r   )__name__
__module____qualname____doc__r   propertyr   r   r"   r#   __classcell__r   r   r   r   r      s    
	r   N)
__future__r   typingr   poetry.core.pyproject.tomlr   BasePyProjectTOMLtomlkit.apir   tomlkit.itemsr   tomlkit.toml_documentr   poetry.tomlr   pathlibr	   r   r   r   r   <module>   s    