
    e                     P    d Z ddlmZmZ ddlmZ  G d d      Z G d dee      Zy)	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                     |j                  di       }g d}|| j                  |      z   }	 t        |   dd|i| y# 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.12/site-packages/cookiecutter/environment.pyr   zExtensionLoaderMixin.__init__   sv     **Y+
 ($*?*?*HH
	PG=
=f= 	P"%?u#EFCO	Ps   ? 	AAAc                 r    	 |d   d   }|D cg c]  }t        |       c}S c c}w # 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_extensions)strKeyError)r   r	   r
   exts       r   r   z%ExtensionLoaderMixin._read_extensions(   sF    	4 0?J )33CH333  	I	s   ( #66)__name__
__module____qualname____doc__r   r   __classcell__r   s   @r   r   r      s    P24    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                 0    t        |   ddt        i| y)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%   6   s    > >r#   r%   N)r    jinja2r   r   cookiecutter.exceptionsr   r   r%   r   r#   r   <module>r*      s(    0 / 4+4 +4\>,k >r#   