
    E^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 dd
lmZ ddlmZmZ ddlmZ ddlmZ  ej        e          Z	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ G d d          ZdS )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)rmtreeF.Tc                    |r|dus|d}t          |          t          ||          }t          | |d         |d         |||	|
          \  }}||}}|rt          |          n|}||k    rdnd}t	          |          }t
          j                            t
          j                            |                    }|r|5  t          |t                    rt          |d	         |          nUt
          j                            t
          j                            |          d
                   \  }}t          ||          ddd           n# 1 swxY w Y   t
          j                            |d          }t                              d|           |r~t#          ||d         d          }t                              d           fd|d                                         D             }i }||d<   }t                              d|           nt#          ||d         |          }|}d |d                                         D             |d<   |5  ddht'          |d                                                   z  r:t+          |||          }t-          ||||||||||	|
|||          cddd           S |d         r)|d                             t1          ||                     ddd           n# 1 swxY w Y   t                              d|           | |d         d<   t
          j                            |          |d         d<   | |d         d<   ||d         d<   t3          |d	         ||           |5  t5          |||||||          }ddd           n# 1 swxY w Y   |rt7          |           |rt7          |           |S )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: %sc                 T    i | ]$\  }}|d                                           v!||%S )cookiecutter)keys).0kvcontext_from_replayfiles      1lib/python3.11/site-packages/cookiecutter/main.py
<dictcomp>z cookiecutter.<locals>.<dictcomp>s   sF     
 
 
1/?DDFFFF qFFF    r!   zprompting context: %sc                 D    i | ]\  }}|                     d           ||S )_)
startswith)r#   r$   r%   s      r'   r(   z cookiecutter.<locals>.<dictcomp>   s?          AS@Q@Q 	1     r)   _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contextr0   r2   r1   r3   r4   )r   r   r   r	   _patch_import_path_for_repoospathbasenameabspath
isinstanceboolr   splitsplitextjoinloggerdebugr   itemssetr"   r
   r!   updater   r   r   r   )r   r   r   r   r/   r0   r1   r   r   r   r   r2   r3   r4   err_msgconfig_dictbase_repo_dircleanup_base_repo_dirr9   cleanupimport_patchtemplate_namer=   r   r:   items_for_promptingcontext_for_promptingnested_templateresultr&   s                                @r'   r!   r!      s|   V  ,HE))}/H  	 #7+++!%  K ,>!/2 !45, , ,(M( &'<gH5AO"=111xH-//ddUG.x88LG$$RW__X%>%>??M D 	D 	D&$'' D*.{</H-*X*X''&(gmmBG4D4DV4L4LQ4O&P&P#m*.t]*C*C'	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 7<<*=>>L
LL%|444 ("%'(9:
 
 

 	-/FGGG
 
 
 
/5577
 
 

 !#0Cn-),.CDDDD"%'(9:'
 
 

 !(    06688     GO 
  $s7>+B+G+G+I+I'J'JJ 	4WhQQO(!!+$7%'-!#$7)(?         & !0 	N#**!"7BB  )              0 LL'*** ,4GNK( .0W__Z-H-HGNM* /7=GNK( ,4GNK(\	"M7;;; 
 	
 	
 3 3!%$;
 
 
	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
  x }Ms>   BEEEAK<?1K<<L L N((N,/N,c                   "    e Zd ZddZd Zd ZdS )r;   r9   os.PathLike[str]c                 R    t          |t                    r| n|| _        d | _        d S N)r@   r   r7   _path)selfr9   s     r'   __init__z$_patch_import_path_for_repo.__init__   s)    *4Xt*D*DRH(


r)   c                     t          t          j                  | _        t          j                            | j                   d S rX   )r   sysr=   rY   appendr7   )rZ   s    r'   	__enter__z%_patch_import_path_for_repo.__enter__   s-    #(^^
'''''r)   c                 (    | j         t          _        d S rX   )rY   r]   r=   )rZ   typevalue	tracebacks       r'   __exit__z$_patch_import_path_for_repo.__exit__   s    :r)   N)r9   rV   )__name__
__module____qualname__r[   r_   rd    r)   r'   r;   r;      sF           ( ( (    r)   r;   )NFNNFr   NFNNFTF)__doc__loggingr<   r]   r   pathlibr   cookiecutter.configr   cookiecutter.exceptionsr   cookiecutter.generater   r   cookiecutter.hooksr	   cookiecutter.promptr
   r   cookiecutter.replayr   r   cookiecutter.repositoryr   cookiecutter.utilsr   	getLoggerre   rE   r!   r;   rh   r)   r'   <module>ru      s     				 



             / / / / / / 8 8 8 8 8 8 B B B B B B B B 2 2 2 2 2 2 6 6 6 6 6 6 1 1 1 1 1 1 * * * * * * * * 6 6 6 6 6 6 % % % % % %		8	$	$
 !k k k k\
 
 
 
 
 
 
 
 
 
r)   