https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/mercurial/__pycache__/templater.cpython-310.pyc
o

�]Lbі�@s�dZddlmZmZddlZddlZddlmZddlm	Z	m
Z
ddlmZm
Z
mZmZmZmZmZmZmZddlmZmZid	d
�dd�d
d�dd�dd�dd�dd�dd�dd�dd�dd�dd �d!d"�d#d$�d%d&�d'd�Zd�d(d)�Zd�d+d,�Zd�d.d/�Zd�d0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z d<d=�Z!d>d?�Z"d@dA�Z#dBdC�Z$dDdE�Z%dFdG�Z&dHdI�Z'dJdK�Z(dLdM�Z)dNdO�Z*dPdQ�Z+dRdS�Z,dTdU�Z-dVdW�Z.dXdY�Z/dZd[�Z0idd\d]��d#d^d]��d!d_d]��d%e'�d`dad]��de*�de(�d
e)�dbe-�dce/�dde0�dded]��ddfd]��dge+�ddhd]��ddid]��Z1e1�2�Z3e1d!e3d<Gdjdk�dkej4�Z5dldm�Z6dndo�Z7Gdpdq�dqe8�Z9Gdrds�dse9�Z:Gdtdu�due8�Z;dvdw�Z<dxdy�Z=dzd{�Z>Gd|d}�d}e8�Z?Gd~d�de8�Z@d�d��ZAd�d�d��ZBd�d�d��ZCdS)�a�Slightly complicated template engine for commands and hgweb

This module provides low-level interface to the template engine. See the
formatter and cmdutil modules if you are looking for high-level functions
such as ``cmdutil.rendertemplate(ctx, tmpl)``.

Internal Data Types
-------------------

Template keywords and functions take a dictionary of current symbols and
resources (a "mapping") and return result. Inputs and outputs must be one
of the following data types:

bytes
    a byte string, which is generally a human-readable text in local encoding.

generator
    a lazily-evaluated byte string, which is a possibly nested generator of
    values of any printable types, and  will be folded by ``stringify()``
    or ``flatten()``.

None
    sometimes represents an empty value, which can be stringified to ''.

True, False, int, float
    can be stringified as such.

wrappedbytes, wrappedvalue
    a wrapper for the above printable types.

date
    represents a (unixtime, offset) tuple.

hybrid
    represents a list/dict of printable values, which can also be converted
    to mappings by % operator.

hybriditem
    represents a scalar printable value, also supports % operator.

revslist
    represents a list of revision numbers.

mappinggenerator, mappinglist
    represents mappings (i.e. a list of dicts), which may have default
    output format.

mappingdict
    represents a single mapping (i.e. a dict), which may have default output
    format.

mappingnone
    represents None of Optional[mappable], which will be mapped to an empty
    string by % operation.

mappedgenerator
    a lazily-evaluated list of byte strings, which is e.g. a result of %
    operation.
�)�absolute_import�print_functionN�)�_)�FileNotFoundError�getattr)	�config�encoding�error�parser�pycompat�templatefilters�
templatefuncs�templateutil�util)�resourceutil�
stringutil�()�N)�groupr�))�funcrrN�.)�NN)rrN�%)�NN)rrN�|)rNN)rrN�*)�NN)rrN�/)rNN)rrN�+)�NN)r r!N�-)r!N)�negate�)r"r!N�=)�NN)�keyvaluer&N�,)�NN)�listr)Nr)rNNNN�integer)rr+NNN�symbol)rr,NNN�string)rr-NNN�template)rr.NNN�endccsV�|}t�|�}||k�r�||}|��r�ny|dvr#|d|fV�nm|dvr@|d}t||||�\}}d||fV|d8}�nP|dkr�|||d�dvr�||d}|d}}||kr�||}|d	krk|d7}qZ||krzd
|||�|fVn|d7}||ks^t�td�|���n|��r�|}||kr�||}|��s�n|d7}||ks�d|||�|fV|d8}n�|d	kr�|||d�d
vs�|dk�r=|||d�dv�r=|dkr�|d7}d
}	nd}	|||d�}
|d}}||k�r4|�d||��r|d7}q�|�|
||��r,t	�
|||��}|	dk�r!t|dt|��d}|	||fV|d7}n|d7}||ks�t�td�|��nS|���sG|dv�r{|}|d7}||k�rj||}|���sa|dk�san	|d7}||k�sR|||�}d||fV|d8}n||k�r�dd|fVdSt�td�|��|d7}||ks
|�r�t�td�|��dd|fVdS)z^Parse a template expression into a stream of tokens, which must end
    with term if specifieds(=,).%|+-*/Ns"'rr.�rr))sr'sr"�\r-�unterminated stringr+)s\'s\"r&)sr\'sr\"s\\\r!r�_r,r/ssyntax errorsunterminated template expansion)
r�bytestr�isspace�_parsetemplater
�
ParseErrorr�isdigit�
startswithr�unescapestr�len�isalnum)�program�start�end�term�pos�c�s�data�d�token�quote�sym�rI�5/usr/lib/python3/dist-packages/mercurial/templater.py�tokenizeus��

�
��



��

�

�ZrK�cCstg}t||||�D]+\}}}|dkr|�||f�q	|dkr$|�|�q	|dkr.||fSt�d|��t�d��)a�
    >>> _parsetemplate(b'foo{bar}"baz', 0, 12)
    ([('string', 'foo'), ('symbol', 'bar'), ('string', '"baz')], 12)
    >>> _parsetemplate(b'foo{bar}"baz', 0, 12, quote=b'"')
    ([('string', 'foo'), ('symbol', 'bar')], 9)
    >>> _parsetemplate(b'foo"{bar}', 0, 9, quote=b'"')
    ([('string', 'foo')], 4)
    >>> _parsetemplate(br'foo\"bar"baz', 0, 12, quote=b'"')
    ([('string', 'foo"'), ('string', 'bar')], 9)
    >>> _parsetemplate(br'foo\\"bar', 0, 10, quote=b'"')
    ([('string', 'foo\\')], 6)
    r-r.r/sunexpected type: %s�!unterminated scanning of template)�
_scantemplate�appendr
�ProgrammingError)�tmplr>�stoprG�parsed�typ�valrArIrIrJr6�s

r6FccsV�d}t|dt|�|d�D]\}}}|r||fV|dkr!dS||f}q
t�d��)aScan (type, start, end) positions of outermost elements in template

    If raw=True, a backslash is not taken as an escape character just like
    r'' string in Python. Note that this is different from r'' literal in
    template in that no template fragment can appear in r'', e.g. r'{foo}'
    is a literal '{foo}', but ('{foo}', raw=True) is a template expression
    'foo'.

    >>> list(scantemplate(b'foo{bar}"baz'))
    [('string', 0, 3), ('template', 3, 8), ('string', 8, 12)]
    >>> list(scantemplate(b'outer{"inner"}outer'))
    [('string', 0, 5), ('template', 5, 14), ('string', 14, 19)]
    >>> list(scantemplate(b'foo\\{escaped}'))
    [('string', 0, 5), ('string', 5, 13)]
    >>> list(scantemplate(b'foo\\{escaped}', raw=True))
    [('string', 0, 4), ('template', 4, 13)]
    Nr)�rawr/rM)rNr;r
rP)rQrV�lastrTrUrArIrIrJ�scantemplate�s�

rXc

#s��d|}tjtjg|}|�t�t�}z���kr�t���fdd�t�|�D�dd�d�}|dkr@d|������fV��n�||d	�}	d}
|s[|�t��|��d
��}
|
dd	krvd|��|d	��|	�fV|d	�q|�kr�d|��|���fV|	|kr�dd
|d	fVWd
S|�	t
�|d	�d��\}���d��s�t�
td����d||fV�d	7���ks|r�t�
td�|��Wntj
y�}zt|���d
}~wwdd
�fVd
S)zEParse template string into chunks of strings and template expressions�{c3s�|]
}��|���VqdS�N)�find)�.0rB�rArRrQrIrJ�	<genexpr>s�z _scantemplate.<locals>.<genexpr>cSs|dk|fS)NrrI)�nrIrIrJ�<lambda>sz_scantemplate.<locals>.<lambda>)�keyrr-rr1r)r/N�}�
invalid tokenr.r2)rr:r�identity�elements�minr4r;�rstrip�parserKr9r
r7r�_addparseerrorhint)
rQr>rRrGrV�sepchars�unescape�pr_rB�bs�parseres�instrIr]rJrNsV�
� ��
��rNcCs\|jdurdS|j}|d|��d�}|�dd�}|dd|d|dtd�|_dS)N�
s\n� rs^ shere)�location�count�replacer�hint)rorQ�loc�offsetrIrIrJri=s
*ricCs�t|t�s|S|d}|dkr|ftdd�|dd�D��St|�dks'J�tdd�|dD��}|s6d	St|�dkrH|ddd
krH|dS|f|S)a;Expand list of templates to node tuple

    >>> def f(tree):
    ...     print(pycompat.sysstr(prettyformat(_unnesttemplatelist(tree))))
    >>> f((b'template', []))
    (string '')
    >>> f((b'template', [(b'string', b'foo')]))
    (string 'foo')
    >>> f((b'template', [(b'string', b'foo'), (b'symbol', b'rev')]))
    (template
      (string 'foo')
      (symbol 'rev'))
    >>> f((b'template', [(b'symbol', b'rev')]))  # template(rev) -> str
    (template
      (symbol 'rev'))
    >>> f((b'template', [(b'template', [(b'string', b'foo')])]))
    (string 'foo')
    rr.cs��|]}t|�VqdSrZ��_unnesttemplatelist�r\�xrIrIrJr^d��z&_unnesttemplatelist.<locals>.<genexpr>rNr)csrxrZryr{rIrIrJr^gr})r-rLr-)�
isinstance�tupler;)�tree�op�xsrIrIrJrzMs
 
rzcCs4t|dt|��\}}|t|�ksJd��td|f�S)zParse template string into treers$unquoted template should be consumedr.)r6r;rz)rQrSrArIrIrJrhpsrhc
Cs2zt|�WStjy}zt||��d}~ww)a=Parse a template expression into tree

    >>> parseexpr(b'"foo"')
    ('string', 'foo')
    >>> parseexpr(b'foo(bar)')
    ('func', ('symbol', 'foo'), ('symbol', 'bar'))
    >>> from . import error
    >>> from . import pycompat
    >>> try:
    ...   parseexpr(b'foo(')
    ... except error.ParseError as e:
    ...   pycompat.sysstr(e.message)
    ...   e.location
    'not a prefix: end'
    4
    >>> try:
    ...   parseexpr(b'"foo" "bar"')
    ... except error.ParseError as e:
    ...   pycompat.sysstr(e.message)
    ...   e.location
    'invalid token'
    7
    N)�
_parseexprr
r7ri)�exprrorIrIrJ�	parseexprws

��r�cCsHt�t�}|�t|dt|���\}}|t|�kr t�td�|��t|�S)Nrrc)	rrerhrKr;r
r7rrz)r�rlr�rArIrIrJr��s

r�cCst�|d�S)N)r+r-r,)r�prettyformat�r�rIrIrJr��sr�cCs(|s	t�td���|d}||||�S)z1Compile parsed template tree to (func, data) pairsmissing argumentr�r
r7r)�exp�context�
curmethods�trIrIrJ�
compileexp�sr�cCs*|ddkr
|dSt�td�|d��)Nrr,rsexpected a symbol, got '%s'r�)r�rIrIrJ�	getsymbol�sr�cCs0|sgS|ddkrt|d�|dgS|gS)Nrr*rr)��getlist)r|rIrIrJr��s
r�cCs@|ddvrt||t�S|ddkr|�|d�St�td���)z_Compile given template tree or load named template from map file;
    returns (func, data) pairr)r.r-r,rsexpected template specifier)r��methods�_loadr
r7r�r�r�rIrIrJ�gettemplate�s
r�cCst�td�|��)Ns$recursive reference '%s' in template)r
�
InputErrorr)r��mappingrarIrIrJ�_runrecursivesymbol�sr�cs$�fdd�|dd�D�}tj|fS)Ncsg|]}t|�t��qSrI)r�r�)r\�e�r�rIrJ�
<listcomp>��z!buildtemplate.<locals>.<listcomp>r)r�runtemplate)r�r��ctmplrIr�rJ�
buildtemplate�s
r�cCs�t|d�}||jvr|j|}t|d|t�}tj||ffS||jvr8|j|}t|d|t||j�}||fSt	�
td�|��)Nr)r�unknown function '%s')r��_filtersr�r�r�	runfilter�_funcs�_buildfuncargs�_argspecr
r7r)r�r�r_�filt�arg�f�argsrIrIrJ�buildfilter�s



r�cCs,t|d|t�}t|d|�}tj||ffS�Nrr))r�r�r�r�runmap)r�r��darg�targrIrIrJ�buildmap�sr�cCs*t|d|t�}t|d�}tj||ffSr�)r�r�r�r�	runmember)r�r�r��membrIrIrJ�buildmember�sr�cCst|d|t�}tj|fS�Nr)r��exprmethodsr�	runnegate)r�r�r�rIrIrJ�buildnegate�s
r�cCs0t|d|t�}t|d|t�}tj|||ffSr�)r�r�r�
runarithmetic)r�r��func�left�rightrIrIrJ�buildarithmetic�sr�cCs�t|d�}||jvr|j|}t|d|t||j�}||fS||jvrLt|d|t|dd�}t|�dkr>t�t	d�|��|j|}t
j|d|ffSt�t	d�|��)Nrr))�argspecsfilter %s expects one argumentrr�)r�r�r�r�r�r�r;r
r7rrr�)r�r�r_r�r�rIrIrJ�	buildfunc�s



r�c
s���fdd�}��fdd�}|s|t|��St�|�\}}}	}
}tjt|�||ddd�}t��}|r<||�|��||<|
rG||�|
��||
<|�||��|S)aCompile parsed tree of function arguments into list or dict of
    (func, data) pairs

    >>> context = engine(lambda t: (templateutil.runsymbol, t))
    >>> def fargs(expr, argspec):
    ...     x = _parseexpr(expr)
    ...     n = getsymbol(x[1])
    ...     return _buildfuncargs(x[2], context, exprmethods, n, argspec)
    >>> list(fargs(b'a(l=1, k=2)', b'k l m').keys())
    ['l', 'k']
    >>> args = fargs(b'a(opts=1, k=2)', b'**opts')
    >>> list(args.keys()), list(args[b'opts'].keys())
    (['opts'], ['opts', 'k'])
    cs t���fdd�t�|�D��S)Nc3s$�|]
\}}|t|���fVqdSrZ�r�)r\�kr|�r�r�rIrJr^s
��
�z6_buildfuncargs.<locals>.compiledict.<locals>.<genexpr>)r�sortdictr�	iteritems�r�r�rIrJ�compiledicts�z#_buildfuncargs.<locals>.compiledictcs��fdd�|D�S)Ncsg|]}t|����qSrIr�r{r�rIrJr�r�z7_buildfuncargs.<locals>.compilelist.<locals>.<listcomp>rIr�r�rIrJ�compilelist�z#_buildfuncargs.<locals>.compilelistr'r,)�keyvaluenode�keynode)r�r�splitargspec�
buildargsdictrr��pop�update)
r�r�r��funcnamer�r�r��_poskeys�varkey�_keys�optkey�treeargs�compargsrIr�rJr�s&�r�cCst�td���)Ns*can't use a key-value pair in this contextr�)r��contentrIrIrJ�buildkeyvaluepair3sr�cCstjtd�td�d��)Ns can't use a list in this contextscheck place of comma and parens�rur�r�rIrIrJ�	buildlist7s�r�cC�tj|dfSr�)r�
runinteger�r�rBrIrIrJr`@�r`cCr�r�)r�	runstringr�rIrIrJr`Ar�cCr�r�)r�	runsymbolr�rIrIrJr`Br�rcCst|d|t�Sr�)r�r�r�rIrIrJr`D�rr'r*cC�t||dd��S)NcSs||SrZrI��a�brIrIrJr`K��<lambda>.<locals>.<lambda>�r�r�rIrIrJr`Kr�cCr�)NcSs||SrZrIr�rIrIrJr`Lr�r�r�r�rIrIrJr`Lr�r#cCr�)NcSs||SrZrIr�rIrIrJr`Nr�r�r�r�rIrIrJr`Nr�cCr�)NcSs||SrZrIr�rIrIrJr`Or�r�r�r�rIrIrJr`Or�c@s,eZdZdZed�Zee�Zedd��Z	dS)�_aliasrulesz2Parsing and expansion rule set of template aliasesstemplate aliascCsn|ddkr|dddkr|ddt|d�fS|ddkr3|dddkr5|dd|dgfSdSdS)zNReturn (name, args) if tree is func(...) or ...|filter; otherwise
        Nonerrrr,r)rNr�r�rIrIrJ�_trygetfunc]s
�z_aliasrules._trygetfuncN)
�__name__�
__module__�__qualname__�__doc__r�_section�staticmethodr��_parser�rIrIrIrJr�Wsr�cCst�|�}t�||�S)z'Return new tree of aliases are expanded)r�r��expand)r��aliases�aliasmaprIrIrJ�
expandaliasesgs
r�cCs8t|�dks|ddvs|d|dkr|S|dd�S)z9unwrap quotes if any; otherwise returns unmodified stringr)r�'"���r)r;)rCrIrIrJ�
unquotestringps(r�c@sNeZdZdZejZejdd��Zejdd��Z	ejdd��Z
ejdd	��Zd
S)�resourcemapperz%Mapper of internal template resourcescC�dS)�BReturn a set of available resource keys based on the given mappingNrI��selfr�rIrIrJ�
availablekeys|�zresourcemapper.availablekeyscCr�)�'Return a set of supported resource keysNrI�r�rIrIrJ�	knownkeys�r�zresourcemapper.knownkeyscCr�)z:Return a resource for the key if available; otherwise NoneNrI�r�r�rarIrIrJ�lookup�r�zresourcemapper.lookupcCr�)zcReturn a dict of additional mapping items which should be paired
        with the given new mappingNrI�r�r��origmapping�
newmappingrIrIrJ�populatemap�r�zresourcemapper.populatemapN)r�r�r�r��abc�ABCMeta�
__metaclass__�abstractmethodr�r�rrrIrIrIrJr�ws


r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�nullresourcemappercC�t�SrZ��setr�rIrIrJr���z nullresourcemapper.availablekeyscCr
rZrr�rIrIrJr��r
znullresourcemapper.knownkeyscCsdSrZrIr�rIrIrJr��znullresourcemapper.lookupcCsiSrZrIrrIrIrJr�rznullresourcemapper.populatemapN)r�r�r�r�r�rrrIrIrIrJr	�s
r	c@szeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�enginea�template expansion engine.

    template expansion works like this. a map file contains key=value
    pairs. if value is quoted, it is treated as string. otherwise, it
    is treated as name of template file.

    templater is asked to expand a key in map. it looks up key, and
    looks for strings like this: {foo}. it expands {foo} by looking up
    foo in map, and substituting it. expansion is recursive: it stops
    when there is no more {foo} to replace.

    expansion also allows formatting and filtering.

    format uses key to expand each item in list. syntax is
    {key%format}.

    filter uses function to transform value. syntax is
    {key|filter1|filter2|...}.NcCsV||_|dur	i}||_tj|_|duri}|durt�}||_||_i|_i|_	dSrZ)
�_loaderr�r�funcsr�r	�	_defaults�
_resources�_cache�
_tmplcache)r��loader�filters�defaults�	resourcesrIrIrJ�__init__�s
zengine.__init__csV�j����j�|�����fdd�t�|�D�}|�|�|��j��||��|S)zfCreate combined mapping from the original mapping and partial
        mapping to override the originalcs.i|]\}}|�vs����|��r||�qSrI)�
isdisjoint�_defaultrequires)r\r��v��knownres�newresr�rIrJ�
<dictcomp>�s��z%engine.overlaymap.<locals>.<dictcomp>)rr�r�rr�r�r)r�rrr�rIrrJ�
overlaymap�s
�
�zengine.overlaymapcCs,|j�|�}|dust|�sdSt|dd�S)z?Resource keys required by the specified default symbol functionNrI�	_requires)r�get�callabler)r�rarrIrIrJr�szengine._defaultrequirescCs4d}||j��vr|�|�}|dur|j�|�}|S)z:Resolve symbol to value or function; None if nothing foundN)rr�r$r�r�r�rarrIrIrJ�symbol�s
z
engine.symbolcC�|j�|�S)r�)rr�r�rIrIrJ�availableresourcekeys��zengine.availableresourcekeyscCs
|j��S)r�)rr�r�rIrIrJ�knownresourcekeys�s
zengine.knownresourcekeyscCs,|j�||�}|durt�td�|��|S)zNReturn internal data (e.g. cache) used for keyword/function
        evaluationNs#template resource not available: %s)rrr�ResourceUnavailablerr&rIrIrJ�resource�s
�zengine.resourcecCsT||jvr%|�|�}t|f|j|<zt||t�|j|<Wn|j|=�|j|S)z!load, parse, and cache a template)rrr�r�r�)r�r�r|rIrIrJr��s


zengine._loadcCs.||jvrt|�}t||t�|j|<|j|S)z"Parse and cache a literal template)rrhr�r��r�rQr|rIrIrJr�s

z
engine._parsecCs(z|�|�WdStjyYdSw)z:Load, parse, and cache the specified template if availableTF)r�r�TemplateNotFound�r�r�rIrIrJ�preload
s
�zengine.preloadcC�|�|�\}}|�|||�S)z�Perform expansion. t is name of map element to expand.
        mapping contains added elements for use during expansion. Is a
        generator.)r��_expand)r�r�r�r�rDrIrIrJ�processszengine.processcCr2)z�Perform expansion over a literal template

        No user aliases will be expanded since this is supposed to be called
        with an internal template string.
        )r�r3)r�rQr�r�rDrIrIrJr�sz
engine.expandcCs8|j�|i|�}|r|�|�|}t�||||||��SrZ)rrr�r�flatten)r�r�rDr��extramappingrIrIrJr3"s

zengine._expand)NNN)r�r�r�r�rr"rr'r)r+r-r�r�r1r4r�r3rIrIrIrJr�s
	

	rcCsjt�}|s	td�St�|�}g}|D]}|�d�}|ddvr q|ddkr-|�|d�qd�t|��S)	Ns7no templates found, try `hg debuginstall` for more inforr�)sorigsrejrsmap-cmdliners, )�templatedirr�os�listdir�splitrO�join�sorted)�path�dirlist�	stylelist�filer:rIrIrJr?-s

�r?cCs8tj�|�rt�|d�Stjtd�|td�t�d��)N�rbsstyle '%s' not foundsavailable styles: %sr�)	r8r=�existsr�	posixfiler
�Abortrr?)�mapfilerIrIrJ�
_open_mapfile<s
�rFc
s�tjr|�tj�}d�|�}tj�|��t������fdd��|�	�}�j
||ddi�d�i}i}g}��dd�}|r�|dd	vr�tj�tj��|��}tj�
|�s�t�}	|	d
ur�tj�tj�|	|��}
tj�|
�ro|
}ntj�tj�|
d��}tj�|�r�|}t|�}t||�\}}}��d�D]@\}}|s�t�td���d|���|dd	vr�|d|d
kr�t�td���d|���t|�||<q�|dkr�tj��|�||<q�|���d��|||fS)z.Load template elements from the given map filercs�d}�rtj�tj��|��}tj�|�rt�|d�}|sTtj|vr8|}zt	�
d|�}Wn'ty7d}Ynwt�}|rTtj�tj�||��}tj�|�rTt�|d�}|rf|�
�}�j||||�d�dSdS)NrAsmercurial.templates)�sections�remap�include)r8r=�normpathr;�isfilerrCr�ossepr�
open_resourcerr7�readrh)�relrHrG�subresource�abs�dirrD��base�confrIrIrJrIQs<
��
��z_readmapfile.<locals>.includerL�	templates)rHrIs__base__rr�Nsmaps
missing valuer�sunmatched quotess
templatealias)r�	iswindowsr:rLr;r8r=�dirnamerrNrhr$rJrBr7rKrF�_readmapfile�itemsr
r7r�sourcer��extend)
�fprE�
name_pathsrD�cache�tmapr�rUr=rR�p2�p3rarIrSrJrYEsR
���
rYc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)rz2Load template fragments optionally from a map filecCs,|duri}|��|_i|_t�|�|_dSrZ)�copyr_�_mapr�r��	_aliasmap)r�r_r�rIrIrJr�s

zloader.__init__cCs||jvp	||jvSrZ)r_rd�r�rarIrIrJ�__contains__�r�zloader.__contains__c
Cs�||jvrWzt|j|�\}}|��|j|<Wn?ty/}zt�td�|jd��d}~wt	yV}ztd�|j|t
�|jd�f}t	|jdt�
|���d}~ww|�|j|�S)�?Get parsed tree for the given template name. Use a local cache.s"%s" not in template maprNstemplate file %s: %sr)r_�
open_templaterdrN�KeyErrorrr/rr��IOErrorr�forcebytestrr	�strfromlocalr�)r�r�rEr]ro�reasonrIrIrJ�load�s$
�����zloader.loadcCs t|�}|jrt�|j|�}|SrZ)rhrer�r�r.rIrIrJr��sz
loader._parsecCs�|sdS|d}|dkr4|d}||dvrdS|d�|�||jvs)||jvr2|�|�|�|�dS|dvr:dS|dkrS|d�t|d��|�|d|�dS|dkrl|d�t|d��|�|d|�dS|dd�D]}|�||�qrdS)Nrr,r>r-r+rr)r)�addr_rd�_findsymbolsusedror�)r�r��symsr�rCr|rIrIrJrq�s0�zloader._findsymbolsusedcCs"t�t�f}|�|�|�|�|S�z�Look up (keywords, filters/functions) referenced from the name
        template 't'

        This may load additional templates from the map file.
        )rrqro)r�r�rrrIrIrJ�symbolsused�szloader.symbolsusedN)
r�r�r�r�rrgror�rqrtrIrIrIrJr�src@s�eZdZ							ddd�Ze							ddd��Zd	d
�Zedd��Zed
d��Z	edd��Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�	templaterNrI��c	CsJtj��}|r|�|�t||�|_t|jj|||�|_|||_	|_
dS)agCreate template engine optionally with preloaded template fragments

        - ``filters``: a dict of functions to transform a value into another.
        - ``defaults``: a dict of symbol values/functions; may be overridden
          by a ``mapping`` dict.
        - ``resources``: a resourcemapper object to look up internal data
          (e.g. cache), inaccessible from user template.
        - ``cache``: a dict of preloaded template fragments.
        - ``aliases``: a list of alias (name, replacement) pairs.

        self.cache may be updated later to register additional template
        fragments.
        N)r
rrcr�rrrro�_proc�	_minchunk�	_maxchunk)	r�rrrr_r��minchunk�maxchunk�
allfiltersrIrIrJr�s

ztemplater.__init__c	CsX|||||g||�}	|st|�}t||�\}}
}|	jj�|�|
|	j_t�|�|	j_|	S)z,Create templater from the specified map file)	rFrYrr_r�rdr�r�re)�clsrEr]rrrr_r{r|r�r`r�rIrIrJ�frommapfiles
ztemplater.frommapfilecCs
||jvSrZ)rrfrIrIrJrgs
ztemplater.__contains__cC�|jjSrZ)rr_r�rIrIrJr_�ztemplater.cachecCr�rZ)rxr�r�rIrIrJr�$r�ztemplater._filterscCr�rZ)rxrr�rIrIrJr(r�ztemplater.defaultscCr()rh)rror0rIrIrJro,r*ztemplater.loadcCs
|�d�S)z�Look up (keywords, filters/functions) referenced from the default
        unnamed template

        This may load additional templates from the map file.
        rL)rtr�rIrIrJ�symbolsuseddefault0s
ztemplater.symbolsuseddefaultcCr(rs)rrtr0rIrIrJrt8sztemplater.symbolsusedcCs|�d|�S)z?Render the default unnamed template and return result as stringrL)�renderr�rIrIrJ�
renderdefault@r*ztemplater.renderdefaultcCsd�|�||��S)z?Render the specified named template and return result as stringrL)r;�generate)r�r�r�rIrIrJr�Dsztemplater.rendercCs,|j�||�}|jrtj||j|jd�}|S)zVReturn a generator that renders the specified named template and
        yields chunks)rf�max)rxr4ryr�increasingchunksrz)r�r�r��streamrIrIrJr�Hs
�ztemplater.generate)NNNNrIrvrw)NNNNNrvrw)r�r�r�r�classmethodrrg�propertyr_r�rror�rtr�r�r�rIrIrIrJru�s>
��


rucCs,tj�tj�tjd��}tj�|�r|SdS)z6return the directory used for template files, or None.rVN)r8r=rJr;r�datapath�isdir)r=rIrIrJr7Ssr7cCs�tj�|�stj�|�r|t|dd�fS|durt�}|dur.tj�||�}|t|dd�fStjr<|�	tj
�}d�|�}|�	d�}d�ddg|dd��}|t�||d�fS)	a
returns a file-like object for the given template, and its full path

    If the name is a relative path and we're in a frozen binary, the template
    will be read from the mercurial.templates package instead. The returned path
    will then be the relative path.
    �rb)�modeNrrs	mercurialrVr�)
r8r=rK�isabs�openr7r;rrWr:rLrrM)�name�templatepathr�r^�
name_parts�package_namerIrIrJriYs

�ric	Cs&zt||�WSttfyYdSw)N)NN)ri�EnvironmentError�ImportError)r�r�rIrIrJ�try_open_template|s
�r�rZ)rL)F)rLF)Dr��
__future__rrrr8�i18nrrrr�rr	r
rr
rrr�utilsrrrerKr6rXrNrirzrhr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rcr��basealiasrulesr�r�r��objectr�r	rr?rFrYrrur7rir�rIrIrIrJ�<module>s�<,�������	�
���
�����

d

-#

/��������	�
���
����		WKl
#

https://t.me/RX1948 - 2025