
    -Ph                        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m	Z	 d dl
mZmZ d dlmZ ej        dk     rd dlZnd d	lmZ d(dZd)d*dZd+dZd,dZdddddd-d#Zddd$d.d&Zddd$d.d'ZdS )/    )annotationsNwraps)Pathcall)AnyCallable)	CliRunner)   	   )	resourcesfilename
str | Pathreturnstrc                D    t          |                                           S )N)r   	read_text)r   s    V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/towncrier/test/helpers.pyreadr      s    >>##%%%    FpathcontentsdedentboolNonec                    t          |           }|j                            dd           |rt          j        |          }|                    |           dS )zT
    Create a file with given contents including any missing parent directories
    T)parentsexist_okN)r   parentmkdirtextwrapr   
write_text)r   r   r   ps       r   writer%      sV     	T

AHNN4$N/// -?8,,LLr   c                V    t          j        d          | z                      d          S )z1
    Read *path* from the towncrier package.
    	towncrierzutf-8)r   filesr   )r   s    r   read_pkg_resourcer)   #   s'     OK((4/::7CCCr   fnCallable[..., Any]c                >     t                     d fd            }|S )za
    Run *fn* within an isolated filesystem and add the kwarg *runner* to its
    arguments.
    argsr	   kwr   c                     t                      }|                                5   | d|i|cd d d            S # 1 swxY w Y   d S )Nrunner)r   isolated_filesystem)r-   r.   r0   r*   s      r   testz"with_isolated_runner.<locals>.test0   s    '')) 	2 	22t1F1b11	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s   
;??r-   r	   r.   r	   r   r	   r   )r*   r2   s   ` r   with_isolated_runnerr4   *   s:     2YY2 2 2 2 2 Y2
 Kr    zpyproject.tomlTconfigextra_configpyproject_pathmkdir_newsfragmentsr7   
str | Noner8   r9   r:   c                R   | d|z   } nt          j        |           } t          |                              |            t          d                                           t          d                              d           |r#t          d                                           d S d S )Nz![tool.towncrier]
package = "foo"
foozfoo/__init__.pyz__version__ = "1.2.3"
zfoo/newsfragments)r"   r   r   r#   r!   r6   s       r   setup_simple_projectr>   9   s     ~9LH((##F+++KK	&&'@AAA * !!'')))))* *r   r7   r9   2Callable[[Callable[..., Any]], Callable[..., Any]]c                     d fd}|S )a  Decorator to run a test with an isolated directory containing a simple
    project.

    The files are not managed by git.

    `config` is the content of the config file.
    It will be automatically dedented.

    `pyproject_path` is the path where to store the config file.
    r*   r+   r   c                D     t                     d fd            }|S )Nr-   r	   r.   r   c                     t                      }|                                5  t                      | d|i|cd d d            S # 1 swxY w Y   d S )Nr?   r0   )r   r1   r>   )r-   r.   r0   r7   r*   r9   s      r   r2   z-with_project.<locals>.decorator.<locals>.test]   s    [[F++-- 6 6$!#1   
 r455"556 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6s   AAAr3   r   )r*   r2   r7   r9   s   ` r   	decoratorzwith_project.<locals>.decorator\   sC    	r	6 	6 	6 	6 	6 	6 	6 
	6 r   r*   r+   r   r+    r7   r9   rD   s   `` r   with_projectrH   L   s/            r   c                     d fd}|S )zDecorator to run a test with an isolated directory containing a simple
    project checked into git.
    Use `config` to tweak the content of the config file.
    Use `pyproject_path` to tweak the location of the config file.
    r*   r+   r   c                P     ddt                     d	 fd            }|S )
Nr   r   c                 J    t          g d           t          g d           d S )Ngitadd.)rM   commit-mzSecond Commitr   rF   r   r   _commitz4with_git_project.<locals>.decorator.<locals>._commity   s2    $$$%%%999:::::r   r-   r	   r.   c                    t                      }|                                5  t                     t          ddg           t          g d           t          g d           t          g d           t          g d           t          g d            | |d	|cd d d            S # 1 swxY w Y   d S )
Nr?   rM   init)rM   r7   z	user.nameuser)rM   r7   z
user.emailzuser@example.com)rM   r7   zcommit.gpgSignfalserL   )rM   rP   rQ   zInitial Commit)r0   rP   )r   r1   r>   r   )r-   r.   r0   rR   r7   r*   r9   s      r   r2   z1with_git_project.<locals>.decorator.<locals>.test}   sI   [[F++-- F F$!#1   
 eV_%%%;;;<<<HHHIIIAAABBB((()))>>>???r4wEE"EEF F F F F F F F F F F F F F F F F Fs   BB33B7:B7)r   r   r3   r   )r*   r2   rR   r7   r9   s   ` @r   rD   z#with_git_project.<locals>.decoratorx   sh    	; 	; 	; 	; 
r	F 	F 	F 	F 	F 	F 	F 	F 
	F" r   rE   rF   rG   s   `` r   with_git_projectrW   m   s/          2 r   )r   r   r   r   )F)r   r   r   r   r   r   r   r   )r   r   r   r   rE   )
r7   r;   r8   r   r9   r   r:   r   r   r   )r7   r;   r9   r   r   r@   )
__future__r   sysr"   	functoolsr   pathlibr   
subprocessr   typingr	   r
   click.testingr   version_infoimportlib_resourcesr   	importlibr   r%   r)   r4   r>   rH   rW   rF   r   r   <module>rb      s   " " " " " " 



                                    # # # # # # f+++++######& & & &    D D D D   " * $* * * * * ** *     F *$ $ $ $ $ $ $ $r   