
    g\                        S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	J
r
  SSK	Jr  SSK	Jr  SSK	Jr  SSK	Jr  SSK	Jr  SS	KJr   " S
 S5      r " S S\5      r " S S\5      r " S S5      rS rS rS rS rS rg)zProvides the Template class, a facade for parsing, generating and executing
template strings, as well as template runtime operations.    N)cache)codegen)compat)
exceptions)runtime)util)Lexerc                   :   \ rS rSrSr\r                           SS jr\R                  S 5       r
S rS r\S 5       r\S	 5       r\R                  S
 5       r\S 5       r\S 5       r\S 5       rS rS rS rS rS rS rS r\S 5       rSrg)Template   a"  Represents a compiled template.

:class:`.Template` includes a reference to the original
template source (via the :attr:`.source` attribute)
as well as the source code of the
generated Python module (i.e. the :attr:`.code` attribute),
as well as a reference to an actual Python module.

:class:`.Template` is constructed using either a literal string
representing the template text, or a filename representing a filesystem
path to a source file.

:param text: textual template source.  This argument is mutually
 exclusive versus the ``filename`` parameter.

:param filename: filename of the source template.  This argument is
 mutually exclusive versus the ``text`` parameter.

:param buffer_filters: string list of filters to be applied
 to the output of ``%def``\ s which are buffered, cached, or otherwise
 filtered, after all filters
 defined with the ``%def`` itself have been applied. Allows the
 creation of default expression filters that let the output
 of return-valued ``%def``\ s "opt out" of that filtering via
 passing special attributes or objects.

:param cache_args: Dictionary of cache configuration arguments that
 will be passed to the :class:`.CacheImpl`.   See :ref:`caching_toplevel`.

:param cache_dir:

 .. deprecated:: 0.6
    Use the ``'dir'`` argument in the ``cache_args`` dictionary.
    See :ref:`caching_toplevel`.

:param cache_enabled: Boolean flag which enables caching of this
 template.  See :ref:`caching_toplevel`.

:param cache_impl: String name of a :class:`.CacheImpl` caching
 implementation to use.   Defaults to ``'beaker'``.

:param cache_type:

 .. deprecated:: 0.6
    Use the ``'type'`` argument in the ``cache_args`` dictionary.
    See :ref:`caching_toplevel`.

:param cache_url:

 .. deprecated:: 0.6
    Use the ``'url'`` argument in the ``cache_args`` dictionary.
    See :ref:`caching_toplevel`.

:param default_filters: List of string filter names that will
 be applied to all expressions.  See :ref:`filtering_default_filters`.

:param enable_loop: When ``True``, enable the ``loop`` context variable.
 This can be set to ``False`` to support templates that may
 be making usage of the name "``loop``".   Individual templates can
 re-enable the "loop" context by placing the directive
 ``enable_loop="True"`` inside the ``<%page>`` tag -- see
 :ref:`migrating_loop`.

:param encoding_errors: Error parameter passed to ``encode()`` when
 string encoding is performed. See :ref:`usage_unicode`.

:param error_handler: Python callable which is called whenever
 compile or runtime exceptions occur. The callable is passed
 the current context as well as the exception. If the
 callable returns ``True``, the exception is considered to
 be handled, else it is re-raised after the function
 completes. Is used to provide custom error-rendering
 functions.

 .. seealso::

    :paramref:`.Template.include_error_handler` - include-specific
    error handler function

:param format_exceptions: if ``True``, exceptions which occur during
 the render phase of this template will be caught and
 formatted into an HTML error page, which then becomes the
 rendered result of the :meth:`.render` call. Otherwise,
 runtime exceptions are propagated outwards.

:param imports: String list of Python statements, typically individual
 "import" lines, which will be placed into the module level
 preamble of all generated Python modules. See the example
 in :ref:`filtering_default_filters`.

:param future_imports: String list of names to import from `__future__`.
 These will be concatenated into a comma-separated string and inserted
 into the beginning of the template, e.g. ``futures_imports=['FOO',
 'BAR']`` results in ``from __future__ import FOO, BAR``.

:param include_error_handler: An error handler that runs when this template
 is included within another one via the ``<%include>`` tag, and raises an
 error.  Compare to the :paramref:`.Template.error_handler` option.

 .. versionadded:: 1.0.6

 .. seealso::

    :paramref:`.Template.error_handler` - top-level error handler function

:param input_encoding: Encoding of the template's source code.  Can
 be used in lieu of the coding comment. See
 :ref:`usage_unicode` as well as :ref:`unicode_toplevel` for
 details on source encoding.

:param lookup: a :class:`.TemplateLookup` instance that will be used
 for all file lookups via the ``<%namespace>``,
 ``<%include>``, and ``<%inherit>`` tags. See
 :ref:`usage_templatelookup`.

:param module_directory: Filesystem location where generated
 Python module files will be placed.

:param module_filename: Overrides the filename of the generated
 Python module file. For advanced usage only.

:param module_writer: A callable which overrides how the Python
 module is written entirely.  The callable is passed the
 encoded source content of the module and the destination
 path to be written to.   The default behavior of module writing
 uses a tempfile in conjunction with a file move in order
 to make the operation atomic.   So a user-defined module
 writing function that mimics the default behavior would be:

 .. sourcecode:: python

     import tempfile
     import os
     import shutil

     def module_writer(source, outputpath):
         (dest, name) = \\
             tempfile.mkstemp(
                 dir=os.path.dirname(outputpath)
             )

         os.write(dest, source)
         os.close(dest)
         shutil.move(name, outputpath)

     from mako.template import Template
     mytemplate = Template(
                     filename="index.html",
                     module_directory="/path/to/modules",
                     module_writer=module_writer
                 )

 The function is provided for unusual configurations where
 certain platform-specific permissions or other special
 steps are needed.

:param output_encoding: The encoding to use when :meth:`.render`
 is called.
 See :ref:`usage_unicode` as well as :ref:`unicode_toplevel`.

:param preprocessor: Python callable which will be passed
 the full template source before it is parsed. The return
 result of the callable will be used as the template source
 code.

:param lexer_cls: A :class:`.Lexer` class used to parse
 the template.   The :class:`.Lexer` class is used by
 default.

 .. versionadded:: 0.7.4

:param strict_undefined: Replaces the automatic usage of
 ``UNDEFINED`` for any undeclared variables not located in
 the :class:`.Context` with an immediate raise of
 ``NameError``. The advantage is immediate reporting of
 missing variables which include the name.

 .. versionadded:: 0.3.6

:param uri: string URI or other identifier for this template.
 If not provided, the ``uri`` is generated from the filesystem
 path, or from the in-memory identity of a non-file-based
 template. The primary usage of the ``uri`` is to provide a key
 within :class:`.TemplateLookup`, as well as to generate the
 file path of the generated Python module file, if
 ``module_directory`` is specified.

Nc           	         U(       a$  [         R                  " SSU5      U l        X0l        OU(       a  [         R                  " SSU5      U l        [        R
                  R                  U5      u  nn[        R
                  R                  U5      R                  [        R
                  R                  S5      nUU l        O-S[        [        U 5      5      -   U l        U R                  U l        U R                  nUR                  S5      (       a  USS  n[        R
                  R                  U5      nUR                  S5      (       a#  [        R                  " SU R                  -  5      eUU l        Xpl        Xl        UU l        UU l        UU l        Uc	  S/U l        OUU l        UU l        UU l        UU l        UU l        Ub  UU l        Ub,  [7        XU5      u  nn UU l        Xl        [=        U S XUX5        OUb|  Ub  UnOcU	b^  [        R
                  R?                  [        R
                  RA                  [        R
                  R                  U	5      US	-   5      5      nOS nU RC                  UU5      n O[        RD                  " S
5      eU U l#        X l$        U RF                  RJ                  U l&        X@l'        XPl(        UU l)        X`l*        Xl+        U RY                  UUU
UUU5        g )N\W_/zmemory:   z..zNTemplate uri "%s" is invalid - it cannot be relative outside of the root path.strz.pyz"Template requires text or filename)-resub	module_iduriospath
splitdrivenormpathreplacesephexid
startswithr   TemplateLookupExceptioninput_encodingoutput_encodingencoding_errorsenable_loopstrict_undefinedmodule_writerdefault_filtersbuffer_filtersimportsfuture_importspreprocessor	lexer_cls_compile_text_code_source
ModuleInfoabspathjoin_compile_from_fileRuntimeExceptionmodulefilenamerender_body	callable_format_exceptionserror_handlerinclude_error_handlerlookupmodule_directory_setup_cache_args)!selftextr6   r   r9   r:   r<   r"   r#   r=   
cache_args
cache_implcache_enabled
cache_type	cache_dir	cache_urlmodule_filenamer!   r&   r'   r(   r%   r)   r*   r$   r+   r,   r;   driver   u_normcoder5   s!                                    U/Users/Alptekin/Desktop/izin_takip/venv/lib/python3.13/site-packages/mako/template.py__init__Template.__init__   s   < VVE34DNHVVE39DN'',,X6KE477##D)11"''++sCDDH&RX6DN~~DHS!!ABZF!!&)T""44$&*hh/  -..& 0*"$)7D #2D ,,( &DN *4x@NT6DJLvtTT4E! *&!-wwGGLL(()9:FUN ,,T8<F--4   00!2*%:" 0	
    c                     U R                   (       a  [        R                  $ [        R                  R                  S/5      $ )Nloop)r$   r   RESERVED_NAMES
differencer?   s    rK   reserved_namesTemplate.reserved_namesQ  s0    )))))44fX>>rN   c                     Xl         X l        U=(       d    0 U l        U(       a  X@R                  S'   U(       a  XPR                  S'   U(       a  X`R                  S'   g g )Ntypedirurl)rB   rC   rA   )r?   rB   rC   rA   rD   rE   rF   s          rK   r>   Template._setup_cache_argsX  sM     %*$*&0OOF#%.OOE"%.OOE" rN   c           	      x   UGbt  [         R                  " [        R                  R	                  U5      5        [        R
                  " U5      [
        R                     n[        R                  R                  U5      (       a+  [        R
                  " U5      [
        R                     U:  a-  [         R                  " U5      n[        XX!U R                  5        [        R                  " U R                  U5      nUR                  [        R                   :w  aN  [         R                  " U5      n[        XX!U R                  5        [        R                  " U R                  U5      n[#        XQXS S S 5        U$ [         R                  " U5      n[%        XU5      u  peS U l        X`l        [#        US XUS S 5        U$ N)r   verify_directoryr   r   dirnamestatST_MTIMEexists	read_file_compile_module_filer&   r   load_moduler   _magic_numberr   MAGIC_NUMBERr0   r-   r/   r.   )r?   r   r6   	filemtimedatar5   rJ   s          rK   r3   Template._compile_from_filel  sH   !!"''//$"78)$--8IGGNN4((774=/);~~h/$0B0B ''=F##w';';;~~h/$0B0B  ++DNNDAvTT4F  >>(+D(X>LDDLJvtTT4FrN   c                 @    [        U R                  5      R                  $ )z<Return the template source code for this :class:`.Template`.)_get_module_info_from_callabler8   sourcerS   s    rK   rl   Template.source  s     .dnn=DDDrN   c                 @    [        U R                  5      R                  $ )z:Return the module source code for this :class:`.Template`.)rk   r8   rJ   rS   s    rK   rJ   Template.code  s     .dnn=BBBrN   c                 .    [         R                  " U 5      $ r\   )r   CacherS   s    rK   r   Template.cache  s    {{4  rN   c                      U R                   S   $ )NrX   rA   rS   s    rK   rE   Template.cache_dir      u%%rN   c                      U R                   S   $ )NrY   rt   rS   s    rK   rF   Template.cache_url  rv   rN   c                      U R                   S   $ )NrW   rt   rS   s    rK   rD   Template.cache_type  s    v&&rN   c                 D    [         R                  " X R                  X5      $ )a  Render the output of this template as a string.

If the template specifies an output encoding, the string
will be encoded accordingly, else the output is raw (raw
output uses `StringIO` and can't handle multibyte
characters). A :class:`.Context` object is created corresponding
to the given data. Arguments that are explicitly declared
by this template's internal rendering method are also
pulled from the given ``*args``, ``**data`` members.

r   _renderr8   r?   argsrh   s      rK   renderTemplate.render  s     t^^T@@rN   c                 B    [         R                  " X R                  XSS9$ )z7Render the output of this template as a unicode object.T)
as_unicoder|   r~   s      rK   render_unicodeTemplate.render_unicode  s      ..$
 	
rN   c                     [        USS5      c  UR                  U 5        [        R                  " X R                  U/UQ70 UD6  g)zfRender this :class:`.Template` with the given context.

The data is written to the context's buffer.

_with_templateN)getattr_set_with_templater   _render_contextr8   )r?   contextr   kwargss       rK   render_contextTemplate.render_context  s@     7,d3;&&t,nngOOOrN   c                 4    [        U R                  SU-  5      $ N	render_%s)hasattrr5   r?   names     rK   has_defTemplate.has_def      t{{K$$677rN   c                 H    [        U [        U R                  SU-  5      5      $ )z9Return a def of this template as a :class:`.DefTemplate`.r   )DefTemplater   r5   r   s     rK   get_defTemplate.get_def  s!     4kD6H!IJJrN   c                 r    [        U R                  5       Vs/ s H  oSS S:X  d  M  USS PM     sn$ s  snf )zAreturn a list of defs in the template.

.. versionadded:: 1.0.4

N   render_)rX   r5   )r?   is     rK   	list_defsTemplate.list_defs  s:      #4;;/F/!Ra5I3E!"/FFFs   4	4c                 4    [        U R                  SU-  5      $ r   )r   r5   r   s     rK   _get_def_callableTemplate._get_def_callable  r   rN   c                 .    U R                   R                  $ r\   )r5   _modified_timerS   s    rK   last_modifiedTemplate.last_modified  s    {{)))rN   )r.   r/   r(   rA   rC   rB   r8   r'   r$   r#   r:   r6   r9   r*   r)   r;   r!   r,   r<   r5   r=   r   r&   r"   r+   r%   r   )NNNFNNNstrictNNbeakerTNNNNNNN FNNTNNN)__name__
__module____qualname____firstlineno____doc__r	   r,   rL   r   memoized_propertyrT   r>   r3   propertyrl   rJ   r   rE   rF   rD   r   r   r   r   r   r   r   r   __static_attributes__r   rN   rK   r   r      sK   {z I  "9s
j 
? ?/(< E E
 C C
 
! ! & & & & ' 'A
P8K
G8 * *rN   r   c                   D    \ rS rSrSr                 SS jrSrg)ModuleTemplatei  a	  A Template which is constructed given an existing Python module.

e.g.::

     t = Template("this is a template")
     f = file("mymodule.py", "w")
     f.write(t.code)
     f.close()

     import mymodule

     t = ModuleTemplate(mymodule)
     print(t.render())

Nc           	         [         R                  " SSUR                  5      U l        UR                  U l        UR
                  U l        Xpl        Xl        UR                  U l
        Xl        X@l        [        UUU UUUUR                  5        U R                  R                  U l        Xl        Xl        UU l        Xl        U R)                  UUUUUU5        g )Nr   r   )r   r   _template_urir   r   _source_encodingr!   r"   r#   _enable_loopr$   r5   r6   r0   r7   r8   r9   r:   r;   r<   r>   )r?   r5   rG   templatetemplate_filenamemodule_sourcetemplate_sourcer"   r#   r9   r:   r<   rA   rB   rC   rD   rE   rF   r;   s                      rK   rL   ModuleTemplate.__init__  s    * sF,@,@A''$55..!..)  	
 00!2*%:"	
rN   )r8   r$   r#   r:   r6   r9   r;   r!   r<   r5   r   r"   r   )NNNNNNr   FNNNr   TNNNN)r   r   r   r   r   rL   r   r   rN   rK   r   r     sA    &  "'4
rN   r   c                   $    \ rS rSrSrS rS rSrg)r   i&  zJA :class:`.Template` which represents a callable def in a parent
template.c                 ,   Xl         X l        UR                  U l        UR                  U l        UR                  U l        UR
                  U l        UR                  U l        UR                  U l        UR                  U l        UR                  U l	        g r\   )
parentr8   r"   r5   r#   r9   r:   r;   r$   r<   )r?   r   r8   s      rK   rL   DefTemplate.__init__+  sv    "%55mm%55!'!9!9#11%+%A%A"!--mmrN   c                 8    U R                   R                  U5      $ r\   )r   r   r   s     rK   r   DefTemplate.get_def7  s    {{""4((rN   )
r8   r$   r#   r:   r9   r;   r<   r5   r"   r   N)r   r   r   r   r   rL   r   r   r   rN   rK   r   r   &  s    
$)rN   r   c                   t    \ rS rSrSr\R                  " 5       rS r\	S	S j5       r
\S 5       r\S 5       rSrg)
r0   i;  zStores information about a module currently loaded into
memory, provides reverse lookups of template source, module
source code based on a module's identifier.

c                     Xl         X l        X@l        XPl        X`l        Xpl        U =U R                  UR                  '   Ul        U(       a  X R                  U'   g g r\   )	r5   rG   r   r   r   template_uri_modulesr   _mmarker)r?   r5   rG   r   r   r   r   r   s           rK   rL   ModuleInfo.__init__E  sU     .!2*.(=AAfoo&):-1MM/* rN   c                    [         R                  " SU[         R                  5      R                  S5      n[        R
                  " U5      nUS   R                  5        VVs0 s H  u  pE[        U5      [        U5      _M     snnUS'   U(       aC  / =ocS'   US   nSn[        S[        U5      5       H  n	X;   a  Xy   nUR                  U5        M     U$ s  snnf )Nz'__M_BEGIN_METADATA(.+?)__M_END_METADATAr   line_mapfull_line_map)r   searchSgroupjsonloadsitemsintrangemaxappend)
clsr   r   
source_mapkv
f_line_mapr   curr_templ_linemod_lines
             rK   get_module_source_metadata%ModuleInfo.get_module_source_metadataY  s    YY6rtt

%( 	 ZZ
+
'1*'='C'C'E"
'EtqCFCFN'E"

: 799JO4!*-HO!!S]3'&.&8O!!/2 4 "
s   "!Cc                 t    U R                   b  U R                   $ [        R                  " U R                  5      $ r\   )r   r   read_python_filerG   rS   s    rK   rJ   ModuleInfo.codem  s1    )%%%(()=)=>>rN   c                    U R                   cb  [        R                  " U R                  5      nU R                  R
                  (       a%  UR                  U R                  R
                  5      $ U$ U R                  R
                  (       aN  [        U R                   [        5      (       d/  U R                   R                  U R                  R
                  5      $ U R                   $ r\   )	r   r   rb   r   r5   r   decode
isinstancer   )r?   rh   s     rK   rl   ModuleInfo.sourcet  s    '>>$"8"89D{{++{{4;;#?#?@@[[))*  #3
 3
 ''..t{{/K/KLL'''rN   )r5   rG   r   r   r   r   N)F)r   r   r   r   r   weakrefWeakValueDictionaryr   rL   classmethodr   r   rJ   rl   r   r   rN   rK   r0   r0   ;  sX     **,H2(  & ? ? ( (rN   r0   c                 f   U R                  UUU R                  U R                  S9nUR                  5       n[        R
                  " UU R                  UU R                  U R                  U R                  U R                  UR                  UU R                  U R                  U R                  S9nXd4$ )N)r!   r+   )	r'   r(   r)   r*   source_encodinggenerate_magic_commentr%   r$   rT   )r,   r!   r+   parser   compiler   r'   r(   r)   r*   encodingr%   r$   rT   )r   r@   r6   r   lexernoderl   s          rK   _compiler     s    ..**	  E ;;=D__ 00..  ..5!22((..F =rN   c                     U R                   n[        XUSS9u  pEUn[        R                  " U5      n[	        XFS5      n[        XR                  UR                  5        XG4$ )NFr   exec)r   r   types
ModuleTyper   r   __dict__)	r   r@   r6   
identifierrl   r   cidr5   rJ   s	            rK   r-   r-     s`    ##JMF Cc"F6'D 	0rN   c                    [        XUSS9u  pV[        U[        5      (       a$  UR                  UR                  =(       d    S5      nU(       a	  U" XS5        g [
        R                  " [        R                  R                  U5      S9u  px[        R                  " Xu5        [        R                  " U5        [        R                  " X5        g )NTr   ascii)rX   )r   r   r   encoder   tempfilemkstempr   r   r^   writecloseshutilmove)	r   r@   r6   
outputpathr&   rl   r   destr   s	            rK   rc   rc     s    MF &#u~~89f)
  ''BGGOOJ,GH

D%rN   c                 2    [        U R                  S   5      $ )Nr   )_get_module_info__globals__)r8   s    rK   rk   rk     s    I11*=>>rN   c                 (    [         R                  U    $ r\   )r0   r   )r6   s    rK   r  r    s    x((rN   )r   r   r   r   r  r_   r   r   r   makor   r   r   r   r   r   
mako.lexerr	   r   r   r   r0   r   r-   rc   rk   r  r   rN   rK   <module>r     s   =  	 	            ~* ~*BF
X F
R)( )*G( G(T2&*?)rN   