403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /usr/lib64/python3.9/site-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/lib64/python3.9/site-packages/mercurial/__pycache__/templater.cpython-39.opt-1.pyc
a

�+�bі�@svdZddlmZmZddlZddlZddlmZddlm	Z	m
Z
ddlmZm
Z
mZmZmZmZmZmZmZddlmZmZd	d
ddd
dddddddddddd�Zdudd�Zdvdd�Zdwdd �Zdxd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Z d-d.�Z!d/d0�Z"d1d2�Z#d3d4�Z$d5d6�Z%d7d8�Z&d9d:�Z'd;d<�Z(d=d>�Z)d?d@�Z*dAdB�Z+dCdD�Z,dEdF�Z-dGdH�Z.dIdJ�Z/dKdL�Z0dMdN�dOdN�dPdN�e'dQdN�e*e(e)e-e/e0dRdN�dSdN�e+dTdN�dUdN�dV�Z1e1�2�Z3e1dWe3dX<GdYdZ�dZej4�Z5d[d\�Z6d]d^�Z7Gd_d`�d`e8�Z9Gdadb�dbe9�Z:Gdcdd�dde8�Z;dedf�Z<dgdh�Z=didj�Z>Gdkdl�dle8�Z?Gdmdn�dne8�Z@dodp�ZAdydqdr�ZBdzdsdt�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)�.rN)�NN)�%rN)rNN)�|rN)�NN)�*rN)rNN)�/rN)�NN)�+rN)rN)�negate�)�-rN)�NN)�keyvaluer$N)�NN)�listr&N)rNNNN)r�integerNNN)r�symbolNNN)r�stringNNN)r�templateNNN)�(rrrrrr r#�=�,rr(r)r*r+�endccsX|}t�|�}||k�r2||}|��r,�n�|dvrD|d|fV�n�|dvr~|d}t||||�\}}d||fV|d8}�n�|dk�r|||d�dv�r||d}|d}}||k�r||}|d	kr�|d7}q�||kr�d
|||�|fV�q(|d7}q�t�td�|���n|���rr|}||k�rR||}|���sF�qR|d7}�q&d|||�|fV|d8}�n�|d	k�r�|||d�d
v�s�|dk�r�|||d�dv�r�|dk�r�|d7}d
}	nd}	|||d�}
|d}}||k�rt|�d||��r|d7}�q�|�|
||��rht	�
|||��}|	dk�rPt|dt|��d}|	||fV|d7}�q(|d7}�q�t�td�|��n�|���s�|dv�r�|}|d7}||k�r�||}|���s�|dk�sАq�|d7}�q�|||�}d||fV|d8}n*||k�rdd|fVdSt�td�|��|d7}q|�rHt�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\\\rr�_r)r/ssyntax errorsunterminated template expansion)
r�bytestr�isspace�_parsetemplater
�
ParseErrorr�isdigit�
startswithr�unescapestr�len�isalnum)Zprogram�start�endZterm�pos�c�s�data�d�token�quoteZsym�rF�9/usr/lib64/python3.9/site-packages/mercurial/templater.py�tokenizeus�

 




����






rH�cCszg}t||||�D]X\}}}|dkr4|�||f�q|dkrH|�|�q|dkr\||fSt�d|��qt�d��dS)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 templateN)�
_scantemplate�appendr
�ProgrammingError)�tmplr=�stoprE�parsed�typ�valr?rFrFrGr6�s
r6FccsXd}t|dt|�|d�D]0\}}}|r2||fV|dkr@dS||f}qt�d��dS)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/rJ)rKr;r
rM)rNrSZlastrQrRr?rFrFrG�scantemplate�s
rTc

#s�d|}tjtjg|}|�t�t�}�zr��k�r�t���fdd�t�|�D�dd�d�}|dkr�d|������fV���q��||d	�}	d}
|s�|�t��|��d
��}
|
dd	kr�d|��|d	��|	�fV|d	�q*|�k�rd|��|���fV|	|k�r2dd
|d	fVWd
S|�	t
�|d	�d��\}���d���slt�
td����d||fV�d	7�q*|�r�t�
td�|��Wn4tj
�y�}zt|���WYd
}~n
d
}~00dd
�fVd
S)zEParse template string into chunks of strings and template expressions�{c3s|]}��|���VqdS�N)�find)�.0r@�r?rOrNrFrG�	<genexpr>rIz _scantemplate.<locals>.<genexpr>cSs|dk|fS)NrrF)�nrFrFrG�<lambda>rIz_scantemplate.<locals>.<lambda>)�keyrr*rr1r&r/N�}�
invalid tokenr+r2)rr:r�identity�elements�minr4r;�rstrip�parserHr9r
r7r�_addparseerrorhint)
rNr=rOrErSZsepcharsZunescape�pr[r@�bsZparseres�instrFrYrGrKsL

� 



rKcCs\|jdurdS|j}|d|��d�}|�dd�}|dd|d|dtd�|_dS)N�
s\n� rs^ shere)�location�count�replacer�hint)rhrN�loc�offsetrFrFrGre=s
recCs�t|t�s|S|d}|dkr>|ftdd�|dd�D��Stdd�|dD��}|s\dSt|�dkr�|ddd	kr�|dS|f|SdS)
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+css|]}t|�VqdSrV��_unnesttemplatelist�rX�xrFrFrGrZdrIz&_unnesttemplatelist.<locals>.<genexpr>rNcss|]}t|�VqdSrVrqrsrFrFrGrZgrI)r*rIr*)�
isinstance�tupler;)�tree�op�xsrFrFrGrrMs
 rrcCs t|dt|��\}}td|f�S)zParse template string into treerr+)r6r;rr)rNrPr?rFrFrGrdpsrdc
CsBz
t|�WStjy<}zt||��WYd}~n
d}~00dS)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
r7re)�exprrhrFrFrG�	parseexprws


r|cCsHt�t�}|�t|dt|���\}}|t|�kr@t�td�|��t|�S)Nrr_)	rrardrHr;r
r7rrr)r{rfrwr?rFrFrGrz�s

rzcCst�|d�S)N)r(r*r))r�prettyformat�rwrFrFrGr}�sr}cCs(|st�td���|d}||||�S)z1Compile parsed template tree to (func, data) pairsmissing argumentr�r
r7r)�exp�context�
curmethods�trFrFrG�
compileexp�sr�cCs.|ddkr|dSt�td�|d��dS)Nrr)rsexpected a symbol, got '%s'r)r�rFrFrG�	getsymbol�sr�cCs0|sgS|ddkr*t|d�|dgS|gS)Nrr'rr&��getlist)rtrFrFrGr��s
r�cCsD|ddvrt||t�S|ddkr2|�|d�St�td���dS)z_Compile given template tree or load named template from map file;
    returns (func, data) pairr)r+r*r)rsexpected template specifierN)r��methods�_loadr
r7r�r�r�rFrFrG�gettemplate�s
r�cCst�td�|��dS)Ns$recursive reference '%s' in template)r
Z
InputErrorr)r��mappingr]rFrFrG�_runrecursivesymbol�sr�cs$�fdd�|dd�D�}tj|fS)Ncsg|]}t|�t��qSrF)r�r�)rX�e�r�rFrG�
<listcomp>�rIz!buildtemplate.<locals>.<listcomp>r)rZruntemplate)r�r�ZctmplrFr�rG�
buildtemplate�sr�cCs�t|d�}||jvr>|j|}t|d|t�}tj||ffS||jvrp|j|}t|d|t||j�}||fSt	�
td�|��dS)Nr&r�unknown function '%s')r��_filtersr�r�r�	runfilter�_funcs�_buildfuncargs�_argspecr
r7r)r�r�r[Zfilt�arg�f�argsrFrFrG�buildfilter�s



r�cCs,t|d|t�}t|d|�}tj||ffS�Nrr&)r�r�r�rZrunmap)r�r��dargZtargrFrFrG�buildmap�sr�cCs*t|d|t�}t|d�}tj||ffSr�)r�r�r�rZ	runmember)r�r�r�ZmembrFrFrG�buildmember�sr�cCst|d|t�}tj|fS�Nr)r��exprmethodsrZ	runnegate)r�r�r�rFrFrG�buildnegate�sr�cCs0t|d|t�}t|d|t�}tj|||ffSr�)r�r�rZ
runarithmetic)r�r��func�left�rightrFrFrG�buildarithmetic�sr�cCs�t|d�}||jvr>|j|}t|d|t||j�}||fS||jvr�t|d|t|dd�}t|�dkr|t�t	d�|��|j|}t
j|d|ffSt�t	d�|��dS)Nrr&)�argspecsfilter %s expects one argumentrr�)r�r�r�r�r�r�r;r
r7rrr�)r�r�r[r�r�rFrFrG�	buildfunc�s



r�c
s���fdd�}��fdd�}|s,|t|��St�|�\}}}	}
}tjt|�||ddd�}t��}|rx||�|��||<|
r�||�|
��||
<|�||��|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|���fVqdSrV�r�)rX�krt�r�r�rFrGrZs�z6_buildfuncargs.<locals>.compiledict.<locals>.<genexpr>)r�sortdictr�	iteritems�ryr�rFrG�compiledicts�z#_buildfuncargs.<locals>.compiledictcs��fdd�|D�S)Ncsg|]}t|����qSrFr�rsr�rFrGr�rIz7_buildfuncargs.<locals>.compilelist.<locals>.<listcomp>rFr�r�rFrG�compilelistsz#_buildfuncargs.<locals>.compilelistr%r))ZkeyvaluenodeZkeynode)r�rZsplitargspecZ
buildargsdictrr��pop�update)
r�r�r��funcnamer�r�r�Z_poskeysZvarkeyZ_keysZoptkeyZtreeargsZcompargsrFr�rGr�s&�r�cCst�td���dS)Ns*can't use a key-value pair in this contextr)r�ZcontentrFrFrG�buildkeyvaluepair3sr�cCstjtd�td�d��dS)Ns can't use a list in this contextscheck place of comma and parens�rnrr�rFrFrG�	buildlist7s�r�cCstj|dfSr�)rZ
runinteger�r�r@rFrFrGr\@rIr\cCstj|dfSr�)rZ	runstringr�rFrFrGr\ArIcCstj|dfSr�)rZ	runsymbolr�rFrFrGr\BrIcCst|d|t�Sr�)r�r�r�rFrFrGr\DrIcCst||dd��S)NcSs||SrVrF��a�brFrFrGr\KrI�<lambda>.<locals>.<lambda>�r�r�rFrFrGr\KrIcCst||dd��S)NcSs||SrVrFr�rFrFrGr\LrIr�r�r�rFrFrGr\LrIcCst||dd��S)NcSs||SrVrFr�rFrFrGr\NrIr�r�r�rFrFrGr\NrIcCst||dd��S)NcSs||SrVrFr�rFrFrGr\OrIr�r�r�rFrFrGr\OrI)r(r*r)r+rrrrrr%r'r r#r!rrr)r(c@s,eZdZdZed�Zee�Zedd��Z	dS)�_aliasrulesz2Parsing and expansion rule set of template aliasesstemplate aliascCsj|ddkr4|dddkr4|ddt|d�fS|ddkrf|dddkrf|dd|dgfSdS)zNReturn (name, args) if tree is func(...) or ...|filter; otherwise
        Nonerrrr)r&rNr�r~rFrFrG�_trygetfunc]sz_aliasrules._trygetfuncN)
�__name__�
__module__�__qualname__�__doc__rZ_section�staticmethodrz�_parser�rFrFrFrGr�Ws
r�cCst�|�}t�||�S)z'Return new tree of aliases are expanded)r�r��expand)rw�aliasesZaliasmaprFrFrG�
expandaliasesgs
r�cCs8t|�dks(|ddvs(|d|dkr,|S|dd�S)z9unwrap quotes if any; otherwise returns unmodified stringr&r�'"���r)r;)rArFrFrG�
unquotestringps(r�c@sNeZdZdZejZejdd��Zejdd��Z	ejdd��Z
ejdd	��Zd
S)�resourcemapperz%Mapper of internal template resourcescCsdS)�BReturn a set of available resource keys based on the given mappingNrF��selfr�rFrFrG�
availablekeys|szresourcemapper.availablekeyscCsdS)�'Return a set of supported resource keysNrF�r�rFrFrG�	knownkeys�szresourcemapper.knownkeyscCsdS)z:Return a resource for the key if available; otherwise NoneNrF�r�r�r]rFrFrG�lookup�szresourcemapper.lookupcCsdS)zcReturn a dict of additional mapping items which should be paired
        with the given new mappingNrF�r�r��origmapping�
newmappingrFrFrG�populatemap�szresourcemapper.populatemapN)r�r�r�r��abc�ABCMetaZ
__metaclass__�abstractmethodr�r�r�r�rFrFrFrGr�ws


r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�nullresourcemappercCst�SrV��setr�rFrFrGr��sz nullresourcemapper.availablekeyscCst�SrVr�r�rFrFrGr��sznullresourcemapper.knownkeyscCsdSrVrFr�rFrFrGr��sznullresourcemapper.lookupcCsiSrVrFr�rFrFrGr��sznullresourcemapper.populatemapN)r�r�r�r�r�r�r�rFrFrFrGr��sr�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||_|duri}||_tj|_|dur,i}|dur:t�}||_||_i|_i|_	dSrV)
�_loaderr�rZfuncsr�r��	_defaults�
_resources�_cache�
_tmplcache)r��loader�filters�defaults�	resourcesrFrFrG�__init__�szengine.__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||�qSrF)�
isdisjoint�_defaultrequires)rXr��v�ZknownresZnewresr�rFrG�
<dictcomp>�s�z%engine.overlaymap.<locals>.<dictcomp>)r�r�r�rr�r�r�)r�r�r�r�rFr�rG�
overlaymap�s
�
�zengine.overlaymapcCs,|j�|�}|dust|�s dSt|dd�S)z?Resource keys required by the specified default symbol functionNrFZ	_requires)r��get�callabler)r�r]r�rFrFrGr��szengine._defaultrequirescCs4d}||j��vr|�|�}|dur0|j�|�}|S)z:Resolve symbol to value or function; None if nothing foundN)r�r�r�r��r�r�r]r�rFrFrG�symbol�s
z
engine.symbolcCs|j�|�S)r�)r�r�r�rFrFrG�availableresourcekeys�szengine.availableresourcekeyscCs
|j��S)r�)r�r�r�rFrFrG�knownresourcekeys�szengine.knownresourcekeyscCs,|j�||�}|dur(t�td�|��|S)zNReturn internal data (e.g. cache) used for keyword/function
        evaluationNs#template resource not available: %s)r�r�rZResourceUnavailablerr�rFrFrG�resource�s
�zengine.resourcecCsZ||jvrP|�|�}t|f|j|<zt||t�|j|<Wn|j|=�Yn0|j|S)z!load, parse, and cache a template)r�r�r�r�r�)r�r�rtrFrFrGr��s

zengine._loadcCs.||jvr$t|�}t||t�|j|<|j|S)z"Parse and cache a literal template)r�rdr�r��r�rNrtrFrFrGr�s
z
engine._parsecCs,z|�|�WdStjy&YdS0dS)z:Load, parse, and cache the specified template if availableTFN)r�r�TemplateNotFound�r�r�rFrFrG�preload
s

zengine.preloadcCs|�|�\}}|�|||�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�rBrFrFrG�processszengine.processcCs|�|�\}}|�|||�S)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�r�)r�rNr�r�rBrFrFrGr�sz
engine.expandcCs8|j�|i|�}|r"|�|�|}t�||||||��SrV)r�r�r�rZflatten)r�r�rBr�ZextramappingrFrFrGr�"s

zengine._expand)NNN)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rFrFrFrGr��s
	

	r�cCsjt�}|std�St�|�}g}|D]6}|�d�}|ddvr@q$|ddkr$|�|d�q$d�t|��S)	Ns7no templates found, try `hg debuginstall` for more inforr�)sorigsrejrsmap-cmdliners, )�templatedirr�os�listdir�splitrL�join�sorted)�path�dirlist�	stylelist�filerrFrFrGr-s

rcCs<tj�|�rt�|d�Stjtd�|td�t�d��dS)N�rbsstyle '%s' not foundsavailable styles: %sr�)	r�r�existsr�	posixfiler
ZAbortrr)�mapfilerFrFrG�
_open_mapfile<s
�rc
s�tjr|�tj�}d�|�}tj�|��t������fdd��|�	�}�j
||ddi�d�i}i}g}��dd�}|�r&|dd	v�r&tj�tj��|��}tj�
|��st�}	|	d
u�rtj�tj�|	|��}
tj�|
�r�|
}n(tj�tj�|
d��}tj�|��r|}t|�}t||�\}}}��d�D]�\}}|�sVt�td���d|���|dd	v�r�|d|d
k�r�t�td���d|���t|�||<n|dk�r0tj��|�||<�q0|���d��|||fS)z.Load template elements from the given map filercs�d}�r6tj�tj��|��}tj�|�r6t�|d�}|s�tj|vrr|}zt	�
d|�}Wq�tynd}Yq�0n8t�}|r�tj�tj�||��}tj�|�r�t�|d�}|r�|�
�}�j||||�d�dS)Nrsmercurial.templates)�sections�remap�include)r�r�normpathr�isfilerr	r�ossepr�
open_resourcerr��readrd)�relr
rZsubresource�abs�dirrB��baseZconfrrFrGrQs8
��z_readmapfile.<locals>.includerI�	templates)r
rs__base__rr�Nsmaps
missing valuer�sunmatched quotess
templatealias)r�	iswindowsrrrr�r�dirnamerrrdr�rrr�rr�_readmapfile�itemsr
r7r�sourcer��extend)
�fpr
�
name_pathsrB�cache�tmapr�rRrrZp2Zp3r]rFrrGrEsP

��
rc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)r�z2Load template fragments optionally from a map filecCs,|duri}|��|_i|_t�|�|_dSrV)�copyr"�_mapr�r��	_aliasmap)r�r"r�rFrFrGr��s

zloader.__init__cCs||jvp||jvSrV)r"r%�r�r]rFrFrG�__contains__�szloader.__contains__c
Cs�||jvr�z$t|j|�\}}|��|j|<Wn�tyj}z$t�td�|jd��WYd}~ndd}~0t	y�}zDtd�|j|t
�|jd�f}t	|jdt�
|���WYd}~n
d}~00|�|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_templater%r�KeyErrorrr�rr��IOErrorrZforcebytestrr	Zstrfromlocalr�)r�r�r
r rh�reasonrFrFrG�load�s
��,zloader.loadcCs t|�}|jrt�|j|�}|SrV)rdr&r�r�r�rFrFrGr��sz
loader._parsecCs�|sdS|d}|dkrh|d}||dvr0dS|d�|�||jvsR||jvrd|�|�|�|�dS|dvrtdS|dkr�|d�t|d��|�|d|�dS|dkr�|d�t|d��|�|d|�dS|dd�D]}|�||�q�dS)Nrr)r>r(r*rr&r)�addr"r%�_findsymbolsusedr.r�)r�rw�symsrxrArtrFrFrGr0�s.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�r0r.)r�r�r1rFrFrG�symbolsused�szloader.symbolsusedN)
r�r�r�r�r�r(r.r�r0r3rFrFrFrGr��sr�c@s�eZdZddd�Zeddd��Zd	d
�Zedd��Zed
d��Z	edd��Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�	templaterNrF��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
r�r$r�r�r�r�r.�_proc�	_minchunk�	_maxchunk)	r�r�r�r�r"r��minchunk�maxchunkZ
allfiltersrFrFrGr��s

ztemplater.__init__c	CsX|||||g||�}	|s t|�}t||�\}}
}|	jj�|�|
|	j_t�|�|	j_|	S)z,Create templater from the specified map file)	rrr�r"r�r%r�r�r&)�clsr
r r�r�r�r"r:r;r�r#r�rFrFrG�frommapfiles
ztemplater.frommapfilecCs
||jvSrV)r�r'rFrFrGr(sztemplater.__contains__cCs|jjSrV)r�r"r�rFrFrGr"sztemplater.cachecCs|jjSrV)r7r�r�rFrFrGr�$sztemplater._filterscCs|jjSrV)r7r�r�rFrFrGr�(sztemplater.defaultscCs|j�|�S)r))r�r.r�rFrFrGr.,sztemplater.loadcCs
|�d�S)z�Look up (keywords, filters/functions) referenced from the default
        unnamed template

        This may load additional templates from the map file.
        rI)r3r�rFrFrG�symbolsuseddefault0sztemplater.symbolsuseddefaultcCs|j�|�Sr2)r�r3r�rFrFrGr38sztemplater.symbolsusedcCs|�d|�S)z?Render the default unnamed template and return result as stringrI)�renderr�rFrFrG�
renderdefault@sztemplater.renderdefaultcCsd�|�||��S)z?Render the specified named template and return result as stringrI)r�generate)r�r�r�rFrFrGr?Dsztemplater.rendercCs,|j�||�}|jr(tj||j|jd�}|S)zVReturn a generator that renders the specified named template and
        yields chunks)rb�max)r7r�r8rZincreasingchunksr9)r�r�r��streamrFrFrGrAHs
�ztemplater.generate)NNNNrFr5r6)NNNNNr5r6)r�r�r�r��classmethodr=r(�propertyr"r�r�r.r>r3r@r?rArFrFrFrGr4�s<�
�


r4cCs,tj�tj�tjd��}tj�|�r(|SdS)z6return the directory used for template files, or None.rN)r�rrrr�datapath�isdir)rrFrFrGr�Ssr�cCs�tj�|�stj�|�r(|t|dd�fS|dur6t�}|dur\tj�||�}|t|dd�fStjrx|�	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	mercurialrr�)
r�rr�isabs�openr�rrrrrrr)�name�templatepathr�r!Z
name_partsZpackage_namerFrFrGr*Ys

�r*c	Cs*zt||�WSttfy$YdS0dS)N)NN)r*�EnvironmentError�ImportError)rLrMrFrFrG�try_open_template|srP)N)rI)F)rIF)N)N)Dr�Z
__future__rrr�r�Zi18nrrrr�rr	r
rr
rrrZutilsrrrarHr6rTrKrerrrdr|rzr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r$r�Zbasealiasrulesr�r�r��objectr�r�r�rrrr�r4r�r*rPrFrFrFrG�<module>s�<,	�
d


-#

/	�		WKl
#

Youez - 2016 - github.com/yon3zu
LinuXploit