
    -Ph
                    n    d Z ddlmZ ddlZddlmZ ddlmZ ej        dk     rddZ	nddZ	ddZ
ddZdS )ze
Responsible for writing the built news fragments to a news file without
affecting existing content.
    )annotationsN)Path)Any)   
   pathr   contentstrkwargsr   returnNonec                |     | j         di |5 }|                    |           d d d            d S # 1 swxY w Y   d S )Nw)r   )openwrite)r   r	   r   strms       Q/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/towncrier/_writer.py_newline_write_textr      s    TY%%f%% 	 JJw	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   155c                "     | j         |fi | d S )N)
write_text)r   r	   r   s      r   r   r      s"    **6*****    	directoryfilenamestart_stringtop_linesingle_fileboolc                    t          |           |z  }t          |||          \  }}|r||v rt          d          t          |||r||z   n|                                dz   z   dd           dS )z
    Write *content* to *directory*/*filename* behind *start_string*.

    Double-check *top_line* (i.e. the release header) is not already in the
    file.

    if *single_file* is True, add it to an existing file, otherwise create a
    fresh one.
    z<It seems you've already produced newsfiles for this version?
utf-8 )encodingnewlineN)r   _figure_out_existing_content
ValueErrorr   rstrip)	r   r   r   r   r	   r   	news_fileheader	prev_bodys	            r   append_to_newsfiler*      s    " Y(*I4< FI  YH	))WXXX 	O'I%%8H8H48OP 
 
 
 
 
 
r   r'   tuple[str, str]c                j   |r|                                  sdS t          |                               d          }|                    |d          }t	          |          dk    r:|d                                          d| d|d                                         fS d	|                                fS )
a  
    Try to read *news_file* and split it into header (everything before
    *start_string*) and the old body (everything after *start_string*).

    If there's no *start_string*, return empty header.

    Empty file and per-release files have neither.
    )r!   r!   r    )r"         r   z

r   r!   )existsr   	read_textsplitlenr&   lstrip)r'   r   r   r	   ts        r   r$   r$   D   s      i..00  v9oo'''99GlA&&A
1vv{{A$++--55\555qt{{}}DDw~~r   )r   r   r	   r
   r   r   r   r   )r   r
   r   r
   r   r
   r   r
   r	   r
   r   r   r   r   )r'   r   r   r
   r   r   r   r+   )__doc__
__future__r   syspathlibr   typingr   version_infor   r*   r$    r   r   <module>r<      s    
 # " " " " " 



             g         + + + +$ $ $ $N           r   