
    -Ph!                       d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	Z	ddl	m
Z
mZmZ ddlmZ dd	lmZmZmZ dd
lmZmZ ddlmZmZmZ ddlmZ ej        dk     rddlZnddlmZ dBdZ dCdZ! e	j"        d           e	j#        ddddd            e	j#        d!d"dd#e$           e	j#        d%d&dd'd($           e	j#        d)d*dd+,           e	j#        d-d.dd/,           e	j#        d0d1dd2,           e	j#        d3d4ddd5e!6           e	j#        d7d8ddd9e!6          dDd<                                                                                                            Z$dDd=Z%dEd@Z&e'dAk    r e$             dS dS )Fz1
Build a combined news file from news fragments.
    )annotationsN)date)Path)ContextOption
UsageError)_git   )find_fragmentsrender_fragmentssplit_fragments)get_project_nameget_version)ConfigErrorconfig_option_helpload_config_from_options)append_to_newsfile)   
   )	resourcesreturnstrc                 L    t          j                                                    S )N)r   today	isoformat     O/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/towncrier/build.py	_get_dater   "   s    :<<!!###r   ctxr   paramr   valueboolc                    |j         dk    r| j                            d          n| j                            d          }|r*|r(t          j        d           |                                  |S )Nanswer_keep
answer_yesz9You can not choose both --yes and --keep at the same time)nameparamsgetclickechoabort)r    r!   r"   value_checks       r   _validate_answerr.   &   sq     :&& 	
|$$$Z^^M** 
  u 
NOOO		Lr   build)r'   z--draftdraftFTzYRender the news fragments to standard output. Don't write to files, don't check versions.)default
flag_valuehelpz--configconfig_file	FILE_PATH)r1   metavarr3   z--dir	directoryPATHz:Build fragment in directory. Default to current directory.z--nameproject_namezPass a custom project name.)r1   r3   z	--versionproject_versionz.Render the news fragments using given version.z--dateproject_datez/Render the news fragments using the given date.z--yesr&   z5Do not ask for confirmation to remove news fragments.)r1   r2   r3   callbackz--keepr%   z6Do not ask for confirmations. But keep news fragments.
str | NoneNonec           
         	 t          | |||||||          S # t          $ r:}t          |t          j                   t          j        d           Y d}~dS d}~ww xY w)z8
    Build a combined news file from news fragment.
    )filer
   N)__mainr   printsysstderrexit)	r0   r7   r4   r9   r:   r;   r&   r%   es	            r   _mainrG   2   s    P	
 	
 		
    acj!!!!s    
A/AAc                   t          ||          \  }}	| }
||	j        }|`|	j        st          d          t	          t
          j                            ||	j                  |	j                  	                                }t          j        d|
           t          |	j        t                    rt          j        |	j        d                                       |	j        d                                       d          }t
          j                            |	j        d                   d         }nRt)          |	j                                      d          }t
          j                            |	j                  d         }|                                d	k    }t          j        d
|
           t-          ||	|	j        du          \  }}d |D             }t          j        d|
           t1          ||	j        |	j                  }|e|	j        }|s\|	j        }|rQt9          t
          j                            t
          j                            ||	j                            |          }nd}| t=                      	                                }|	j        dk    }tA          ||	j!        ||	j        |	j"        dd         |	j#        |||d|	j"        d         |	j        |
  
        }|	j        rm|	j        $                    |||          }|r|g}n||	j"        d         tK          |          z  g}|&                    |           d                    |          }nd}|}| r,t          j        d|
           t          j        |           dS t          j        d|
           |	j'        }|	j(        du r|$                    |||          }tS          |||	j*        |||	j(                   t          j        d|
           tW          j,        ||           t[          |||          r*t          j        d|
           tW          j.        |           t          j        d|
           dS )z
    The main entry point.
    NzV'--version' is required since the config file does not contain 'version' or 'package'.zLoading template...)errr   r
   zutf-8)encodingz.mdzFinding news fragments...)strictc                    g | ]\  }}|S r   r   ).0filename	_categorys      r   
<listcomp>z__main.<locals>.<listcomp>   s    OOO'<)(OOOr   zRendering news fragments...)all_bullets )r'   versionr   )top_underlinerQ   render_title)r'   rS   r;   
zUDraft only -- nothing has been written.
What is seen below is what would be written.
zWriting to newsfile...F)single_filezStaging newsfile...zRemoving news fragments...zDone!)/r   rS   packager   r   ospathjoinpackage_dirstripr*   r+   
isinstancetemplatetupler   filesjoinpath	read_textsplitextr   lowerr   ignorer   typesrQ   r'   r   abspathr   title_formatr   issue_format
underlineswrapformatlenappendrN   rW   r   start_stringr	   stage_newsfileshould_remove_fragment_filesremove_files)r0   r7   r4   r9   r:   r;   r&   r%   base_directoryconfigto_errr_   template_extensionis_markdownfragment_contentsfragment_filesfragment_filenames	fragmentsrX   rU   renderedtop_linepartscontent	news_files                            r   rA   rA      s    6iMMNFF .~ 	6   &GLL);<<fn
 

%'' 	 
J$&1111&/5)) 	BOFOA.//Xfoa())YY(( 	
  W--foa.@AA!D((22G2DDW--fo>>qA$**,,5K	J*7777(6 T)) ) )%~ POOOO	J,&99996<V5G  I { 		"nG "/GOOBGLLAS$T$TUU     " {{((**
 &",L!""/<PP'*&!  H  &--\ . 
 
  	EJEEv03c(mmCDEX))E"" 
=	
 	
 	
 	

 	
7	J'V4444IU"" $$\ % 
 
	 &    
J$&1111	222#  .
 	
/V<<<<,---	JwF######r   r{   	list[str]c                   | st          j        d           dS 	 |r0t          j        d           	 | D ]}t          j        |           dS |rt          j        d           nt          j        d           | D ]}t          j        |           n# | D ]}t          j        |           w xY w|st          j        dd          rdS dS )	Nz&No news fragments to remove. Skipping!FzKeeping the following files:zRemoving the following files:z%I want to remove the following files:z#Is it okay if I remove those files?T)r1   )r*   r+   confirm)r{   r&   r%   rN   s       r   rr   rr     s!   
  
;<<<u! 	J5666 + 	! 	!HJx    	! 	!  	@J67777J>??? + 	! 	!HJx    	!* 	! 	!HJx    	!  U]#HRVWWW t5s   B +B B,__main__)r   r   )r    r   r!   r   r"   r#   r   r#   )r0   r#   r7   r=   r4   r=   r9   r=   r:   r=   r;   r=   r&   r#   r%   r#   r   r>   )r{   r   r&   r#   r%   r#   r   r#   )(__doc__
__future__r   rY   rC   datetimer   pathlibr   r*   r   r   r   	towncrierr	   _builderr   r   r   _projectr   r   	_settingsr   r   r   _writerr   version_infoimportlib_resourcesr   	importlibr   r.   commandoptionrG   rA   rr   __name__r   r   r   <module>r      sX    # " " " " " 				 



              - - - - - - - - - -       G G G G G G G G G G 3 3 3 3 3 3 3 3 P P P P P P P P P P ' ' ' ' ' ' g+++++######$ $ $ $	 	 	 	 G	6	 	 	 	   	E   	&	   	9	   	:	   	@   	A           	 	 v:Q$ Q$ Q$ Q$h   8 z	EGGGGG r   