
    -Ph                       d Z ddlmZ ddlZddlmZ ddlmZ ddlZddl	m
Z
 ddlmZmZ d	Z ej        d
          ej         ej        ddddd           ej        dddde           ej        ddd           ej        ddeed           ej        ded           ej        dd           d2d+                                                                                                Zd3d-Zd4d5d0Zed1k    r e             dS dS )6z
Create a new fragment.
    )annotationsN)Path)cast   )FragmentsPath)config_option_helpload_config_from_optionszAdd your info herecreate)namez--dir	directoryPATHz;Create fragment in directory. Default to current directory.)defaultmetavarhelpz--configconfig	FILE_PATHz--edit/--no-editz4Open an editor for writing the newsfragment content.)r   r   z-cz	--contentz%Sets the content of the new fragment.)typer   r   z	--sectionz'The section to create the fragment for.)r   r   filename )r   ctxclick.Context
str | Nonestreditbool | NonecontentsectionreturnNonec           	     0    t          | ||||||           dS )aK  
    Create a new news fragment.

    If FILENAME is not provided, you'll be prompted to create it.

    Towncrier has a few standard types of news fragments, signified by the file
    extension.

    
    These are:
    * .feature - a new feature
    * .bugfix - a bug fix
    * .doc - a documentation improvement,
    * .removal - a deprecation or removal of public API,
    * .misc - an issue has been closed, but it is not of interest to users.

    If the FILENAME base is just '+' (to create a fragment not tied to an
    issue), it will be appended with a random hex string.
    N)__main)r   r   r   r   r   r   r   s          P/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/towncrier/create.py_mainr#      s%    | 3	68T7GDDDDD    config_pathc                   t          ||          \  }}d}	|j        rBt          j                            |j                  d         }
|
                                dv r|
}	|du}|st          |j                  dk    r"t          t          |j                            }nS|j                                        D ]\  }}|s|} n|,t          |j                                                  d         }||j        vr]d}| j        j        D ]}|j        dk    r|} nd                    d |j        D                       }t%          j        d	| |
          t)          t*          |          }|sm|st          |j                  }t          |          dk    rt%          j        d           d}t/          |          D ]>\  }}t%          j        d|dz    d|pd            |s||k    rt+          |dz             }?t%          j        dt%          j        d t5          t          |                    D                       |          }|t7          |          dz
           }d}|j        r|d|j         dz  }t%          j        |          }t%          j        dt%          j        t          |j                                      }| d| }||t<          k    rd}t          j                            |          \  }}|j        r|                     |j         d          rit          j                            ||j         t          j!        d          "                                 |t          |j                  d                    }|                    d          }t          |          dk     s|d         |j        vrO|d         |j        vr@t%          j        d#                    |d                    |j                                      |d         |j        v r|	r||	z  }tI          ||          } ||j        |                   }t          j        %                    |          st          j&        |           t          j                            ||          }d}|                    d          d         |j        vr#t          j                            |          \  }} nd} t          j        %                    |          rK|dz  }t          j                            || d| |            }t          j        %                    |          K|rI|t<          k    rd}tO          ||	          }|s)t%          j        d            | (                    d           tS          |j*        o|o|+                    d!                     }!tY          |          -                    |d!|!z  z   d"#           t%          j        d$|            dS )%z
    The main entry point.
    r   r   )z.rstz.mdNr   r   z, c              3  "   K   | ]
}d | d V  dS )'N ).0ss     r"   	<genexpr>z__main.<locals>.<genexpr>   s*      %H%H1h!hhh%H%H%H%H%H%Hr$   zexpected one of )paramzPick a section: z: z	(primary)Sectionc                2    g | ]}t          |d z             S )r   )r   )r*   is     r"   
<listcomp>z__main.<locals>.<listcomp>   s"    &P&P&Pas1q5zz&P&P&Pr$   )r   r   zIssue numberz (`z
` if none)zFragment type)r   .T      z~Expected filename '{}' to be of format '{{name}}.{{type}}', where '{{name}}' is an arbitrary slug and '{{type}}' is one of: {})section_directory	extensionz4Aborted creating news fragment due to empty message.
zutf-8)encodingzCreated news fragment at ).r	   create_add_extensionospathsplitextr   lowerlensectionsnextiteritemslistkeyscommandparamsr   joinclickBadParameterr   r   echo	enumeratepromptChoicerangeintorphan_prefixtypesDEFAULT_CONTENTsplit
startswithurandomhexformatr   existsmakedirs_get_news_content_from_userexitboolcreate_eof_newlineendswithr   
write_text)"r   r   r%   r   r   r   r   base_directoryr   filename_extextsection_providedsection_namesection_dirsection_parampexpected_sectionsrC   default_section_indexr1   r+   section_indexrP   issuefragment_typefile_dirfile_basenamefilename_partsget_fragments_pathfragments_directorysegment_fileretry	extra_extadd_newlines"                                     r"   r!   r!   Y   sk    6iMMNFL" gv//299;;/))Ld* :v1$$40011GG &&((  " *GE v335566q9fo%%# 	 	Av"" ! # !II%H%H%H%H%HHH 2022
 
 
 	
 3  G  	;FO,,H8}}q  
,---(,%%h// ; ;DAqJ<1Q3<<!*:{<<===0 ;Q'\\03AE

- %&P&P5X;O;O&P&P&PQQ1! ! !
 #3}#5#5#9: 	=<F0<<<<FV$$d6<0011
 
 
 --m--<G66D gmmH55Hm 
 8 8F<P9S9S9S T T 
7<<' ?A):):)<)< ? V%9!:!:!;!;<? ?
 
 ^^C((N
>Qr&,..2fl22 $))FL*A*ABB
 
 	

 bV\))l)L &~v>>,,vw?WXXX7>>-.. )
'(((7<< 3X>>LE~~c2fl22 g..x88))	
'..
&
& 

w||H!A!Au!Ai!A!A
 
 '..
&
& 
  o%%G-gNNN 	JMNNNHHQKKK!LgLg6F6Ft6L6L2L K 	!!'D;,>">!QQQ	J9<99:::::r$   messager:   c                    d}| r|  d| }t          j        ||pd          }|| S |                    d          }d |D             }d                    |                                          S )Nzk
# Please write your news content. Lines starting with '#' will be ignored, and
# an empty message aborts.
r;   z.txtr9   c                    g | ]=}|                                                     d           )|                                >S )#)lstriprX   rstrip)r*   lines     r"   r2   z/_get_news_content_from_user.<locals>.<listcomp>   s<    VVVt8P8PQT8U8UVT[[]]VVVr$   )rL   r   rW   rK   strip)rz   r:   initial_contentr   	all_linesliness         r"   r^   r^      s    O  :$9999jI4GHHHGd##IVVyVVVE99U!!###r$   __main__)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   r   )r   )rz   r   r:   r   r   r   )__doc__
__future__r   r>   pathlibr   typingr   rL   _builderr   	_settingsr   r	   rV   rI   pass_contextoptionr   argumentr#   r!   r^   __name__r)   r$   r"   <module>r      s(    # " " " " " 				              # # # # # # C C C C C C C C ' H	F   	   	?  
 		0   		2  
 
B'''E E E ('       DE>H; H; H; H;V$ $ $ $ $ z	EGGGGG r$   