
    e                         d Z ddl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
 ddlmZmZ ddlmZ dd	lmZmZ dd
lmZmZ ddlmZ ddlmZ  ej4                  e      Z	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ G d d      Zy)z
Main entry point for the `cookiecutter` command.

The code in this module is also a good example of how to use Cookiecutter as a
library rather than a script.
    N)copy)Path)get_user_config)InvalidModeException)generate_contextgenerate_files)run_pre_prompt_hook)choose_nested_templateprompt_for_config)dumpload)determine_repo_dir)rmtreec                    |r|dus|d}t        |      t        ||      }t        | |d   |d   |||	|
      \  }}||}}|rt        |      n|}||k7  rdnd}t	        |      }t
        j                  j                  t
        j                  j                  |            }|ry|5  t        |t              rt        |d	   |      }nNt
        j                  j                  t
        j                  j                  |      d
         \  }}t        ||      }ddd       t
        j                  j                  |d      }t        j!                  d|       |rt#        ||d   d      }t        j!                  d       |d   j%                         D ci c]  \  }}||d   j'                         vr|| }}}i }||d<   |}t        j!                  d|       nt#        ||d   |      }|}|d   j%                         D ci c]  \  }}|j)                  d      r|| c}}|d<   |5  ddht+        |d   j'                               z  r/t-        |||      }t/        ||||||||||	|
|||      cddd       S |d   r|d   j1                  t3        ||             ddd       t        j!                  d|       | |d   d<   t
        j                  j                  |      |d   d<   | |d   d<   ||d   d<   t5        |d	   ||       |5  t7        |||||||      }ddd       |rt9        |       |rt9        |       S # 1 sw Y   .xY wc c}}w c c}}w # 1 sw Y   xY w# 1 sw Y   JxY w)a  
    Run Cookiecutter just as if using it from the command line.

    :param template: A directory containing a project template directory,
        or a URL to a git repository.
    :param checkout: The branch, tag or commit ID to checkout after clone.
    :param no_input: Do not prompt for user input.
        Use default values for template parameters taken from `cookiecutter.json`, user
        config and `extra_dict`. Force a refresh of cached resources.
    :param extra_context: A dictionary of context that overrides default
        and user configuration.
    :param replay: Do not prompt for input, instead read from saved json. If
        ``True`` read from the ``replay_dir``.
        if it exists
    :param overwrite_if_exists: Overwrite the contents of the output directory
        if it exists.
    :param output_dir: Where to output the generated project dir into.
    :param config_file: User configuration file path.
    :param default_config: Use default values rather than a config file.
    :param password: The password to use when extracting the repository.
    :param directory: Relative path to a cookiecutter template in a repository.
    :param skip_if_file_exists: Skip the files in the corresponding directories
        if they already exist.
    :param accept_hooks: Accept pre and post hooks if set to `True`.
    :param keep_project_on_failure: If `True` keep generated project directory even when
        generation fails
    FNzKYou can not use both replay and no_input or extra_context at the same time.)config_filedefault_configabbreviationscookiecutters_dir)templater   clone_to_dircheckoutno_inputpassword	directoryT
replay_dirr   zcookiecutter.jsonzcontext_file is %sdefault_context)context_filer   extra_contextzreplayfile context: %scookiecutterzprompting context: %s__cookiecutterr   	templates)r   r   r   r   replayoverwrite_if_exists
output_dirr   r   r   r   skip_if_file_existsaccept_hookskeep_project_on_failurezcontext is %s	_template_output_dir	_repo_dir	_checkout)repo_dircontextr$   r&   r%   r'   r(   )r   r   r   r	   _patch_import_path_for_repoospathbasenameabspath
isinstanceboolr   splitsplitextjoinloggerdebugr   itemskeys
startswithsetr
   r   updater   r   r   r   ) r   r   r   r   r#   r$   r%   r   r   r   r   r&   r'   r(   err_msgconfig_dictbase_repo_dircleanup_base_repo_dirr-   cleanupimport_patchtemplate_namecontext_from_replayfiler1   r   r.   kvitems_for_promptingcontext_for_promptingnested_templateresults                                    1lib/python3.12/site-packages/cookiecutter/main.pyr   r      s   V HE)}/H  	 #7++!%K ,>!/2 !45,(M( &'<gH5A"=1xH-/dUG.x8LGG$$RWW__X%>?M 	D&$'*.{</H-*X'&(ggmmBGG4D4DV4LQ4O&P#m*.t]*C'	D 77<<*=>L
LL%|4"%'(9:

 	-/FG  /557
1/?DDFF qD
 

 !#0Cn-),.CD"%'(9:'

 !( !0668 AS@Q1 GO 
 $s7>+B+G+G+I'JJ4WhQO(!!+$7%'-!#$7)(? & !0N#**!"7B)0 LL'* ,4GNK( .0WW__Z-HGNM* /7ZGNK( ,4GNK(\	"M7; 
 	
 3 3!%$;
	
 x}MG	D 	D"
$  R	
 	
s>   %A/M "M?MM'AM8#M	M% M
M"%M.c                        e Zd ZddZd Zd Zy)r/   c                 F    t        |t              r| n|| _        d | _        y N)r4   r   r+   _path)selfr-   s     rN   __init__z$_patch_import_path_for_repo.__init__   s    *4Xt*DH:(
    c                     t        t        j                        | _        t        j                  j	                  | j
                         y rQ   )r   sysr1   rR   appendr+   )rS   s    rN   	__enter__z%_patch_import_path_for_repo.__enter__   s%    #((^
'rU   c                 .    | j                   t        _        y rQ   )rR   rW   r1   )rS   typevalue	tracebacks       rN   __exit__z$_patch_import_path_for_repo.__exit__   s    ::rU   N)r-   zos.PathLike[str])__name__
__module____qualname__rT   rY   r^    rU   rN   r/   r/      s    (rU   r/   )NFNNF.NFNNFTF)__doc__loggingr0   rW   r   pathlibr   cookiecutter.configr   cookiecutter.exceptionsr   cookiecutter.generater   r   cookiecutter.hooksr	   cookiecutter.promptr
   r   cookiecutter.replayr   r   cookiecutter.repositoryr   cookiecutter.utilsr   	getLoggerr_   r9   r   r/   rb   rU   rN   <module>rp      s     	 
   / 8 B 2 I * 6 %			8	$
 !k\
 
rU   