
    kh{                         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      Zy)	    N)TYPE_CHECKING)loads)TOMLDocument)StrPath)Unionc                   <    e Zd ZdZdeddfdZdefdZdeddfdZy)	TOMLFilezI
    Represents a TOML file.

    :param path: path to the TOML file
    pathreturnNc                 <    || _         t        j                  | _        y )N)_pathoslinesep_linesep)selfr
   s     M/opt/mcp/mcp-sentiment/venv/lib/python3.12/site-packages/tomlkit/toml_file.py__init__zTOMLFile.__init__   s    


    c                 H   t        | j                  dd      5 }|j                         }|j                  d      }|dkD  rD|j                  d      }||k(  rd| _        |j                  dd      }n|dk(  rd| _        nd| _        t        |      cddd       S # 1 sw Y   yxY w)	zGRead the file content as a :class:`tomlkit.toml_document.TOMLDocument`.utf-8 encodingnewline
r   
mixedN)openr   readcountr   replacer   )r   fcontentnum_newlinenum_win_eols        r   r   zTOMLFile.read   s    $**w; 	"qffhG "---KQ%mmF3+-$*DM%oofd;G A%$(DM$+DM>	" 	" 	"s   A5BB!datac                 2   |j                         }| j                  dk(  r|j                  dd      }n&| j                  dk(  rt        j                  dd|      }t        | j                  ddd      5 }|j                  |       ddd       y# 1 sw Y   yxY w)	z#Write the TOMLDocument to the file.r   r   z	(?<!\r)\nwr   r   r   N)	as_stringr   r!   resubr   r   write)r   r&   r#   r"   s       r   r,   zTOMLFile.write0   s    .." ==D oofd3G]]f$ff\67;G$**cGR@ 	AGGG	 	 	s   2BB)	__name__
__module____qualname____doc___StrPathr   r   r   r,    r   r   r	   r	      s9    #X #$ #"l "&, 4 r   r	   )r   r*   typingr   tomlkit.apir   tomlkit.toml_documentr   	_typeshedr   r1   r   strPathLiker	   r2   r   r   <module>r9      s<    	 	    . -S"++%&H) )r   