
    E^e                     ^    d Z ddlmZmZ ddlmZ  G d d          Z G d dee          ZdS )	z*Jinja2 environment and extensions loading.    )EnvironmentStrictUndefined)UnknownExtensionc                   (     e Zd ZdZ fdZd Z xZS )ExtensionLoaderMixinzMixin providing sane loading of extensions specified in a given context.

    The context is being extracted from the keyword arguments before calling
    the next parent class in line of the child.
    c                     |                     di           }g d}||                     |          z   }	  t                      j        dd|i| dS # t          $ r}t          d|           |d}~ww xY w)aI  Initialize the Jinja2 Environment object while loading extensions.

        Does the following:

        1. Establishes default_extensions (currently just a Time feature)
        2. Reads extensions set in the cookiecutter.json _extensions key.
        3. Attempts to load the extensions. Provides useful error if fails.
        context)z(cookiecutter.extensions.JsonifyExtensionz-cookiecutter.extensions.RandomStringExtensionz(cookiecutter.extensions.SlugifyExtensionz%cookiecutter.extensions.TimeExtensionz%cookiecutter.extensions.UUIDExtension
extensionszUnable to load extension: N )pop_read_extensionssuper__init__ImportErrorr   )selfkwargsr	   default_extensionsr
   err	__class__s         8lib/python3.11/site-packages/cookiecutter/environment.pyr   zExtensionLoaderMixin.__init__   s     **Y++
 
 
 ($*?*?*H*HH
	PEGG==
=f===== 	P 	P 	P"#E#E#EFFCO	Ps   A 
A4A//A4c                 \    	 |d         d         }d |D             S # t           $ r g cY S w xY w)zReturn list of extensions as str to be passed on to the Jinja2 env.

        If context does not contain the relevant info, return an empty
        list instead.
        cookiecutter_extensionsc                 ,    g | ]}t          |          S r   )str).0exts     r   
<listcomp>z9ExtensionLoaderMixin._read_extensions.<locals>.<listcomp>2   s    333CHH333    )KeyError)r   r	   r
   s      r   r   z%ExtensionLoaderMixin._read_extensions'   sR    	4 0?J 43
3333  	 	 	III	s    ++)__name__
__module____qualname____doc__r   r   __classcell__r   s   @r   r   r      sV         P P P P P24 4 4 4 4 4 4r   r   c                   "     e Zd ZdZ fdZ xZS )StrictEnvironmentzCreate strict Jinja2 environment.

    Jinja2 environment will raise error on undefined variable in template-
    rendering context.
    c                 H     t                      j        ddt          i| dS )zSet the standard Cookiecutter StrictEnvironment.

        Also loading extensions defined in cookiecutter.json's _extensions key.
        	undefinedNr   )r   r   r   )r   r   r   s     r   r   zStrictEnvironment.__init__<   s-    
 	==?=f=====r   )r!   r"   r#   r$   r   r%   r&   s   @r   r(   r(   5   sB         > > > > > > > > >r   r(   N)r$   jinja2r   r   cookiecutter.exceptionsr   r   r(   r   r   r   <module>r-      s    0 0 / / / / / / / / 4 4 4 4 4 4+4 +4 +4 +4 +4 +4 +4 +4\> > > > >,k > > > > >r   