
    g0                     z    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5      r
 " S S\
5      rg)	    N)
exceptions)util)Templatec                   4    \ rS rSrSrS rS	S jrS rS rSr	g)
TemplateCollection   a  Represent a collection of :class:`.Template` objects,
identifiable via URI.

A :class:`.TemplateCollection` is linked to the usage of
all template tags that address other templates, such
as ``<%include>``, ``<%namespace>``, and ``<%inherit>``.
The ``file`` attribute of each of those tags refers
to a string URI that is passed to that :class:`.Template`
object's :class:`.TemplateCollection` for resolution.

:class:`.TemplateCollection` is an abstract class,
with the usual default implementation being :class:`.TemplateLookup`.

c                 \     U R                  U5        g! [        R                   a     gf = f)zReturn ``True`` if this :class:`.TemplateLookup` is
capable of returning a :class:`.Template` object for the
given ``uri``.

:param uri: String URI of the template to be resolved.

TF)get_templater   TemplateLookupException)selfuris     S/Users/Alptekin/Desktop/izin_takip/venv/lib/python3.13/site-packages/mako/lookup.pyhas_templateTemplateCollection.has_template#   s0    	c"11 		s    ++Nc                     [        5       e)a  Return a :class:`.Template` object corresponding to the given
``uri``.

The default implementation raises
:class:`.NotImplementedError`. Implementations should
raise :class:`.TemplateLookupException` if the given ``uri``
cannot be resolved.

:param uri: String URI of the template to be resolved.
:param relativeto: if present, the given ``uri`` is assumed to
 be relative to this URI.

)NotImplementedError)r   r   
relativetos      r   r
   TemplateCollection.get_template1   s     "##    c                     U$ zVConvert the given ``filename`` to a URI relative to
this :class:`.TemplateCollection`. r   r   filenames      r   filename_to_uri"TemplateCollection.filename_to_uriA   s	     
r   c                     U$ )a  Adjust the given ``uri`` based on the calling ``filename``.

When this method is called from the runtime, the
``filename`` parameter is taken directly to the ``filename``
attribute of the calling template. Therefore a custom
:class:`.TemplateCollection` subclass can place any string
identifier desired in the ``filename`` parameter of the
:class:`.Template` objects it constructs and have them come back
here.

r   r   s      r   
adjust_uriTemplateCollection.adjust_uriG   s	     
r   r   )N)
__name__
__module____qualname____firstlineno____doc__r   r
   r   r   __static_attributes__r   r   r   r   r      s    $ r   r   c                       \ rS rSrSr                          SS jrS rS rS rS r	S	 r
S
 rS rS rSrg)TemplateLookupV   a 	  Represent a collection of templates that locates template source files
from the local filesystem.

The primary argument is the ``directories`` argument, the list of
directories to search:

.. sourcecode:: python

    lookup = TemplateLookup(["/path/to/templates"])
    some_template = lookup.get_template("/index.html")

The :class:`.TemplateLookup` can also be given :class:`.Template` objects
programatically using :meth:`.put_string` or :meth:`.put_template`:

.. sourcecode:: python

    lookup = TemplateLookup()
    lookup.put_string("base.html", '''
        <html><body>${self.next()}</body></html>
    ''')
    lookup.put_string("hello.html", '''
        <%include file='base.html'/>

        Hello, world !
    ''')


:param directories: A list of directory names which will be
 searched for a particular template URI. The URI is appended
 to each directory and the filesystem checked.

:param collection_size: Approximate size of the collection used
 to store templates. If left at its default of ``-1``, the size
 is unbounded, and a plain Python dictionary is used to
 relate URI strings to :class:`.Template` instances.
 Otherwise, a least-recently-used cache object is used which
 will maintain the size of the collection approximately to
 the number given.

:param filesystem_checks: When at its default value of ``True``,
 each call to :meth:`.TemplateLookup.get_template()` will
 compare the filesystem last modified time to the time in
 which an existing :class:`.Template` object was created.
 This allows the :class:`.TemplateLookup` to regenerate a
 new :class:`.Template` whenever the original source has
 been updated. Set this to ``False`` for a very minor
 performance increase.

:param modulename_callable: A callable which, when present,
 is passed the path of the source file as well as the
 requested URI, and then returns the full path of the
 generated Python module file. This is used to inject
 alternate schemes for Python module location. If left at
 its default of ``None``, the built in system of generation
 based on ``module_directory`` plus ``uri`` is used.

All other keyword parameters available for
:class:`.Template` are mirrored here. When new
:class:`.Template` objects are created, the keywords
established with this :class:`.TemplateLookup` are passed on
to each new :class:`.Template`.

Nc                    [         R                  " US5       Vs/ s H  n[        R                  " U5      PM     snU l        X l        Xl        X0l        X@l        U	c  0 n	U(       a  U	R                  SU5        U(       a  U	R                  SU5        U(       a  U	R                  SU5        0 SU_SU_SU_SU_S	U
_S
U_SU_SU_SU_SU	_SU_SU_SU_SU_SU_SU_SU_UUS.EU l
        US:X  a  0 U l        0 U l        O6[         R                  " U5      U l        [         R                  " U5      U l        [        R                  " 5       U l        g s  snf )Nr   dirurltypeformat_exceptionserror_handlerinclude_error_handleroutput_encoding
cache_implencoding_errorsinput_encodingmodule_directorymodule_writer
cache_argscache_enableddefault_filtersbuffer_filtersstrict_undefinedimportsfuture_importsenable_loop)preprocessor	lexer_cls)r   to_list	posixpathnormpathdirectoriesr4   modulename_callablefilesystem_checkscollection_size
setdefaulttemplate_args_collection
_uri_cacheLRUCache	threadingLock_mutex)r   rD   r4   rF   rG   r-   r.   r0   r2   r6   r1   r7   
cache_type	cache_dir	cache_urlrE   r5   r8   r9   r:   r;   r<   r=   r3   r>   r?   r/   ds                               r   __init__TemplateLookup.__init__   s   < ,0<<R+H
+HaIq!+H
 !1#6 !2.J!!%3!!%3!!&*5
!2
]
 $%:
 	

 *
 
 n
  0
 ]
 *
 ]
 
 n
  0
 w
  n!
" ;#
$ )"'
, b !D DO#}}_=D"mmO<DOnn&]
s    Ec                 j    U R                   (       a  U R                  XR                  U   5      $ U R                  U   $ ! [         a  n[        R
                  " SSU5      nU R                   H  nUR                  [        R                  R                  [        R                  5      n[        R                  " [        R                  " XC5      5      n[        R                  R                  U5      (       d  M  U R                  XQ5      s  s SnA$    [         R"                  " SU-  5      UeSnAff = f)zReturn a :class:`.Template` object corresponding to the given
``uri``.

.. note:: The ``relativeto`` argument is not supported here at
   the moment.

z^\/+ N Can't locate template for uri %r)rF   _checkrJ   KeyErrorresubrD   replaceospathseprB   rC   joinisfile_loadr   TopLevelLookupException)r   r   eudir_srcfiles         r   r
   TemplateLookup.get_template   s    	%%{{3(8(8(=>>'',, 	wC(A(( ||BGGKK?#,,Y^^D-DE77>>'**::g33 ) !886<	s/   .A  A   
D2
B+D-9D-D2D--D2c                     X4nX0R                   ;   a  U R                   U   $ US   S:X  a  U=o@R                   U'   U$ Ub;  [        R                  " [        R                  " U5      U5      =o@R                   U'   U$ SU-   =o@R                   U'   U$ )z9Adjust the given ``uri`` based on the given relative URI.r   /)rK   rB   ra   dirname)r   r   r   keyvs        r   r   TemplateLookup.adjust_uri  s     //!??3''q6S='**A$  #'0~~!!*-s( A$
  (+Sy0A$r   c                      U R                   U   $ ! [         a$    U R                  U5      nX R                   U'   Us $ f = fr   )rK   rZ   _relativeize)r   r   values      r   r   TemplateLookup.filename_to_uri  sF    	??8,, 	%%h/E(-OOH%L	s    +??c                     [         R                  " U5      nU R                   H%  nUS[        U5       U:X  d  M  U[        U5      S s  $    g)zXReturn the portion of a filename that is 'relative'
to the directories in this lookup.

r   N)rB   rC   rD   len)r   r   rg   s      r   rq   TemplateLookup._relativeize  sM     %%h/$$DCI&$.D	,, % r   c                 $   U R                   R                  5           U R                  U   U R                   R                  5         $ ! [         a     Of = f U R
                  b  U R                  X5      nOS n[        SU[        R                  " U5      U US.U R                  D6=U R                  U'   nUU R                   R                  5         $ !   U R                  R                  US 5        e = f! U R                   R                  5         f = f)N)r   r   lookupmodule_filenamer   )rO   acquirerJ   releaserZ   rE   r   rB   rC   rI   pop)r   r   r   ry   templates        r   rc   TemplateLookup._load*  s
   	" '',. KK!-  ++7&*&>&>x&MO&*O3; 4&//9$3	4
 ((4   %   KK!   $$S$/KK!s6   A 
AC3 AC3 AC C00C3 3Dc                    UR                   c  U$  [        R                  " UR                   5      nUR                  R                  U[        R
                     :  a  U$ U R                  R                  US 5        U R                  UR                   U5      $ ! [         a;  nU R                  R                  US 5        [        R                  " SU-  5      UeS nAff = f)NrX   )r   r^   statmodule_modified_timeST_MTIMErJ   r|   rc   OSErrorr   r   )r   r   r}   template_statre   s        r   rY   TemplateLookup._checkI  s    $O
	GGH$5$56M--t}}1MM  d+::h//55 	  d+442S8	s   AB 7B 
C 6CCc                 N    [        U4XS.U R                  D6U R                  U'   g)zrPlace a new :class:`.Template` object into this
:class:`.TemplateLookup`, based on the given string of
``text``.

)rx   r   N)r   rI   rJ   )r   r   texts      r   
put_stringTemplateLookup.put_stringY  s2     !)!
!
*.*<*<!
r   c                      X R                   U'   g)zyPlace a new :class:`.Template` object into this
:class:`.TemplateLookup`, based on the given
:class:`.Template` object.

N)rJ   )r   r   r}   s      r   put_templateTemplateLookup.put_templatec  s     !)r   )	rJ   rO   rK   rG   rD   rF   r4   rE   rI   )NNTr@   FNNstrictNbeakerTNNNNNNr   FNNTNNNN)r    r!   r"   r#   r$   rT   r
   r   r   rq   rc   rY   r   r   r%   r   r   r   r'   r'   V   s    >D   "7K'Z8"	"> 
)r   r'   )r^   rB   r[   r   rM   makor   r   mako.templater   r   r'   r   r   r   <module>r      s;    
  	     "A AHS)' S)r   