o
    Uh?                     @   sr   d dl Z d dlZd dlmZ d dlmZ d dlmZ er#d dlm	Z
 nd dlmZ eee jf Z
G dd dZdS )	    N)TYPE_CHECKING)loads)TOMLDocument)StrPath)Unionc                   @   sB   e Zd ZdZdeddfddZdefddZd	eddfd
dZdS )TOMLFilezI
    Represents a TOML file.

    :param path: path to the TOML file
    pathreturnNc                 C   s   || _ tj| _d S )N)_pathoslinesep_linesep)selfr    r   e/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/tomlkit/toml_file.py__init__   s   zTOMLFile.__init__c                 C   s   t | jddd1}| }|d}|dkr.|d}||kr#d| _n|dkr+d| _nd| _t|W  d   S 1 s<w   Y  dS )	zGRead the file content as a :class:`tomlkit.toml_document.TOMLDocument`.utf-8 encodingnewline
r   
mixedN)openr
   readcountr   r   )r   fcontentnum_newlinenum_win_eolr   r   r   r      s   

$zTOMLFile.readdatac                 C   sz   |  }| jdkr|dd}n| jdkrtdd|}t| jdddd}|| W d   dS 1 s6w   Y  dS )	z#Write the TOMLDocument to the file.r   r   z	(?<!\r)\nwr   r   r   N)	as_stringr   replaceresubr   r
   write)r   r!   r   r   r   r   r   r'   /   s   

"zTOMLFile.write)	__name__
__module____qualname____doc___StrPathr   r   r   r'   r   r   r   r   r      s
    r   )r   r%   typingr   tomlkit.apir   tomlkit.toml_documentr   	_typeshedr   r,   r   strPathLiker   r   r   r   r   <module>   s    