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 :  /lib64/python3.9/site-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib64/python3.9/site-packages/mercurial/__pycache__/parser.cpython-39.pyc
a

�+�b�f�@s�ddlmZmZddlmZddlmZmZddlm	Z	Gdd�de
�Zdd	�Zd
d�Z
dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd$dd�Zdd�ZGd d!�d!e
�ZGd"d#�d#e
�ZdS)%�)�absolute_import�print_function�)�_)�error�util)�
stringutilc@sZeZdZddd�Zdd�Zdd�Zdd	�Zdd
d�Zdd
d�Zdd�Z	dd�Z
dd�ZdS)�parserNcCs||_||_d|_dS�N)�	_elements�_methods�current)�self�elements�methods�r�6/usr/lib64/python3.9/site-packages/mercurial/parser.py�__init__szparser.__init__cCs|j}t|jd�|_|S)zadvance the tokenizerN)r
�next�_iter)r�trrr�_advance#szparser._advancecCst|j|jddd��S)z%True if next token may start new termrr�)�anyrr
�rrrr�_hasnewterm)szparser._hasnewtermcCs:|jd|kr.t�td�|jd|jd��|��dS)z0make sure the tokenizer matches an end conditionrsunexpected token: %s�N)r
r�
ParseErrorrr)r�mrrr�_match-s
�z
parser._matchcCs4|r|jd|krd}n
|�|�}|r0|�|�|S)zLgather right-hand-side operand until an end condition or binding
        metrN)r
�_parser)r�bindr�exprrrr�
_parseoperand5s

zparser._parseoperandrc
Cs|��\}}}|j|dd�\}}|r>|r4|��s>||f}n4|r^|d|j|dd��f}nt�td�||��||j|jddk�r|��\}}}|j|dd�\}}	|	r�|r�|��s�|	|f}qr|r�|d||j|dd��f}qrt�td�||��qr|S)Nrrrsnot a prefix: %ssnot an infix: %s)rrrr#rrrr
)
rr!�token�value�posZprimary�prefixr"Zinfix�suffixrrrr @s 

z
parser._parsecCs*||_|��|��}|j\}}}||fS)z!generate a parse tree from tokens)rrr r
)r�	tokeniter�resr$r%r&rrr�parseWs
zparser.parsecs6t|t�s|S�j|d�fdd�|dd�D��S)z4recursively evaluate a parse tree using node methodsrcsg|]}��|��qSr)�eval��.0rrrr�
<listcomp>c�zparser.eval.<locals>.<listcomp>rN)�
isinstance�tupler)r�treerrrr,_s
zparser.evalcCs|�|�}|jr|�|�S|S)z<parse tokens into a parse tree and evaluate if methods given)r+rr,)rr)rrrr�__call__es

zparser.__call__)N)N)r)�__name__�
__module__�__qualname__rrrrr#r r+r,r4rrrrr	s


r	cCs�d}|�d�\}}}|rL|��}|s.t�d��t|�dkrDt�d��|d}|�d�\}}}|��}|��}|r�|s~t�d��||d|dd�|fSgd||fS)	a�Parse spec of function arguments into (poskeys, varkey, keys, optkey)

    >>> splitargspec(b'')
    ([], None, [], None)
    >>> splitargspec(b'foo bar')
    ([], None, ['foo', 'bar'], None)
    >>> splitargspec(b'foo *bar baz **qux')
    (['foo'], 'bar', ['baz'], 'qux')
    >>> splitargspec(b'*foo')
    ([], 'foo', [], None)
    >>> splitargspec(b'**foo')
    ([], None, [], 'foo')
    Ns**sno **optkey name providedrs!excessive **optkey names providedr�*sno *varkey name provided)�	partition�splitr�ProgrammingError�len)�spec�optkeyZpre�sepZpostZpostsZpresrrr�splitargspecms"


r@cs�|\}}}}t�fdd�t|�D�t|��}	|	t|�krTt�td�|t|�d���|s�|	t|�t|�kr�t�td�|t|�t|�d���t��}
t||d|	��D]\}}||
|<q�|r�|t|
�|	�|
|<n(t||t|
�|	��D]\}}||
|<q�|�rt��|
|<||	d�D]�}|�rF|d�k�sF|dd|k�r\t�td	�d
|i��|dd}||v�rx|
}
n(|�s�t�td�||d���n|
|}
||
v�r�t�td
�||d���|d|
|<�q|
S)a�Build dict from list containing positional and keyword arguments

    Arguments are specified by a tuple of ``(poskeys, varkey, keys, optkey)``
    where

    - ``poskeys``: list of names of positional arguments
    - ``varkey``: optional argument name that takes up remainder
    - ``keys``: list of names that can be either positional or keyword arguments
    - ``optkey``: optional argument name that takes up excess keyword arguments

    If ``varkey`` specified, all ``keys`` must be given as keyword arguments.

    Invalid keywords, too few positional arguments, or too many positional
    arguments are rejected, but missing keyword arguments are just omitted.
    c3s&|]\}}|r|d�kr|VqdS�rNr)r.�i�x��keyvaluenoderr�	<genexpr>�r0z buildargsdict.<locals>.<genexpr>s6%(func)s takes at least %(nargs)d positional arguments)�funcsnargss5%(func)s takes at most %(nargs)d positional argumentsNrrs %(func)s got an invalid argumentrGs5%(func)s got an unexpected keyword argument '%(key)s')rGskeys;%(func)s got multiple values for keyword argument '%(key)s'r)	r�	enumerater<rrrrZsortdict�zip)Ztrees�funcnameZargspecrEZkeynodeZposkeysZvarkey�keysr>Zkwstart�args�krC�drrDr�
buildargsdict�sf�����

&�
��
���rOc
CsJzt�|�WStyD}z t�t�|�����WYd}~n
d}~00dSr
)r�unescapestr�
ValueErrorrrZforcebytestr�lower)�s�errrrP�srPcCs�t|t�s |�|t�|�f�n�|d|vrbttj|dd��}|�|d|dd�|�ff�n`|�|d|df�|dd�D]}t|||d|�q�|dd|dddfg|dd�<dS)Nrrs(%s %s)� s(%s����))r1r2�appendrZpprint�map�join�
_prettyformat)r3�	leafnodes�level�linesZrsrSrrrr[�s
"r[cCs*g}t||d|�d�dd�|D��}|S)Nr�
css|]\}}d||VqdS)s  Nr)r.�lrSrrrrF�r0zprettyformat.<locals>.<genexpr>)r[rZ)r3r\r^�outputrrr�prettyformat�srbcs�t|t�s|S|d}|�vrB|ft�fdd�|dd�D��Sg}|}|d|kr||dd�\}}|�t|���|}qJ|�t|���|�|�tt|��S)a_Flatten chained infix operations to reduce usage of Python stack

    >>> from . import pycompat
    >>> def f(tree):
    ...     s = prettyformat(simplifyinfixops(tree, (b'or',)), (b'symbol',))
    ...     print(pycompat.sysstr(s))
    >>> f((b'or',
    ...     (b'or',
    ...       (b'symbol', b'1'),
    ...       (b'symbol', b'2')),
    ...     (b'symbol', b'3')))
    (or
      (symbol '1')
      (symbol '2')
      (symbol '3'))
    >>> f((b'func',
    ...     (b'symbol', b'p1'),
    ...     (b'or',
    ...       (b'or',
    ...         (b'func',
    ...           (b'symbol', b'sort'),
    ...           (b'list',
    ...             (b'or',
    ...               (b'or',
    ...                 (b'symbol', b'1'),
    ...                 (b'symbol', b'2')),
    ...               (b'symbol', b'3')),
    ...             (b'negate',
    ...               (b'symbol', b'rev')))),
    ...         (b'and',
    ...           (b'symbol', b'4'),
    ...           (b'group',
    ...             (b'or',
    ...               (b'or',
    ...                 (b'symbol', b'5'),
    ...                 (b'symbol', b'6')),
    ...               (b'symbol', b'7'))))),
    ...       (b'symbol', b'8'))))
    (func
      (symbol 'p1')
      (or
        (func
          (symbol 'sort')
          (list
            (or
              (symbol '1')
              (symbol '2')
              (symbol '3'))
            (negate
              (symbol 'rev'))))
        (and
          (symbol '4')
          (group
            (or
              (symbol '5')
              (symbol '6')
              (symbol '7'))))
        (symbol '8')))
    rc3s|]}t|��VqdSr
)�simplifyinfixops�r.rC��targetnodesrrrF5r0z#simplifyinfixops.<locals>.<genexpr>rN)r1r2rXrc�reversed)r3rf�opZ
simplifiedrCr`�rrrerrc�s<
$
rccs6|�kr���St|t�s|St��fdd�|D��S)Nc3s|]}t|���VqdSr
)�
_buildtreerd��placeholder�	replstackrrrFJr0z_buildtree.<locals>.<genexpr>)�popr1r2)�templaterlrmrrkrrjEs

rjcGs>t|t�st�d��tt|��}t|||�}|r:t�d��|S)a�Create new tree by substituting placeholders by replacements

    >>> _ = (b'symbol', b'_')
    >>> def f(template, *repls):
    ...     return buildtree(template, _, *repls)
    >>> f((b'func', (b'symbol', b'only'), (b'list', _, _)),
    ...   ('symbol', '1'), ('symbol', '2'))
    ('func', ('symbol', 'only'), ('list', ('symbol', '1'), ('symbol', '2')))
    >>> f((b'and', _, (b'not', _)), (b'symbol', b'1'), (b'symbol', b'2'))
    ('and', ('symbol', '1'), ('not', ('symbol', '2')))
    � placeholder must be a node tuplestoo many replacements)r1r2rr;�listrgrj)rorlZreplsrmrirrr�	buildtreeMs


rrcsz||krdSt|t�r t|t�s$dS|�krF|d�vrF��|�dSt|�t|�krZdSt���fdd�t||�D��S)NTFrc3s"|]\}}t||����VqdSr
)�
_matchtree)r.�prC��incompletenodes�matchesrlrrrFls�z_matchtree.<locals>.<genexpr>)r1r2rXr<�allrI��patternr3rlrvrwrrurrsbs
�rsNrcCs:|durt|t�st�d��|g}t|||||�r6|SdS)a	If a tree matches the pattern, return a list of the tree and nodes
    matched with the placeholder; Otherwise None

    >>> def f(pattern, tree):
    ...     m = matchtree(pattern, tree, _, {b'keyvalue', b'list'})
    ...     if m:
    ...         return m[1:]

    >>> _ = (b'symbol', b'_')
    >>> f((b'func', (b'symbol', b'ancestors'), _),
    ...   (b'func', (b'symbol', b'ancestors'), (b'symbol', b'1')))
    [('symbol', '1')]
    >>> f((b'func', (b'symbol', b'ancestors'), _),
    ...   (b'func', (b'symbol', b'ancestors'), None))
    >>> f((b'range', (b'dagrange', _, _), _),
    ...   (b'range',
    ...     (b'dagrange', (b'symbol', b'1'), (b'symbol', b'2')),
    ...     (b'symbol', b'3')))
    [('symbol', '1'), ('symbol', '2'), ('symbol', '3')]

    The placeholder does not match the specified incomplete nodes because
    an incomplete node (e.g. argument list) cannot construct an expression.

    >>> f((b'func', (b'symbol', b'ancestors'), _),
    ...   (b'func', (b'symbol', b'ancestors'),
    ...     (b'list', (b'symbol', b'1'), (b'symbol', b'2'))))

    The placeholder may be omitted, but which shouldn't match a None node.

    >>> _ = None
    >>> f((b'func', (b'symbol', b'ancestors'), None),
    ...   (b'func', (b'symbol', b'ancestors'), (b'symbol', b'0')))
    Nrp)r1r2rr;rsryrrr�	matchtreers
"
r{cCs(|jdurtd�|j|jfS|jSdS)z6Compose error message from specified ParseError objectNs	at %d: %s)�locationr�message)�instrrr�parseerrordetail�s
rc@seZdZdZdd�ZdS)�aliaszParsed result of aliascCs"||_||_||_||_d|_dS)NF)�namerLr�replacementZwarned)rr�rL�errr�rrrr�s
zalias.__init__N)r5r6r7�__doc__rrrrrr��sr�c@s�eZdZdZdZdZdd�Zedd��Zedd	��Z	e
d
d��Ze
dd
��Ze
dd��Z
e
dd��Ze
dd��Ze
dd��Ze
dd��Ze
dd��Ze
dd��ZdS)�basealiasrulesawParsing and expansion rule set of aliases

    This is a helper for fileset/revset/template aliases. A concrete rule set
    should be made by sub-classing this and implementing class/static methods.

    It supports alias expansion of symbol and function-call styles::

        # decl = defn
        h = heads(default)
        b($1) = ancestors($1) - ancestors(default)
    NssymbolcCstd|j��dS)Ns'%s' is not instantiatable)�	TypeErrorr5��clsrrr�__new__�szbasealiasrules.__new__cCst�dS)z-Parse an alias name, arguments and definitionN��NotImplementedError)r=rrrr �szbasealiasrules._parsecCst�dS)z9Return (name, args) if tree is a function; otherwise NoneNr�)r3rrr�_trygetfunc�szbasealiasrules._trygetfuncc
sz��|�}Wn4tjyB}z|dt|�fWYd}~Sd}~00|d�jkr�|d}|�d�rv|dtd�|fS|ddfS��|�}|�r|\}}|�d�r�|dtd�|fSt�fdd�|D��r�|dtd	�fSt	|�t	t
|��k�r�|dtd
�fS|dd�|D�dfS|dtd
�fS)a�
Parse an alias declaration into ``(name, args, errorstr)``

        This function analyzes the parsed tree. The parsing rule is provided
        by ``_parse()``.

        - ``name``: of declared alias (may be ``decl`` itself at error)
        - ``args``: list of argument names (or None for symbol declaration)
        - ``errorstr``: detail about detected error (or None)

        >>> sym = lambda x: (b'symbol', x)
        >>> symlist = lambda *xs: (b'list',) + tuple(sym(x) for x in xs)
        >>> func = lambda n, a: (b'func', sym(n), a)
        >>> parsemap = {
        ...     b'foo': sym(b'foo'),
        ...     b'$foo': sym(b'$foo'),
        ...     b'foo::bar': (b'dagrange', sym(b'foo'), sym(b'bar')),
        ...     b'foo()': func(b'foo', None),
        ...     b'$foo()': func(b'$foo', None),
        ...     b'foo($1, $2)': func(b'foo', symlist(b'$1', b'$2')),
        ...     b'foo(bar_bar, baz.baz)':
        ...         func(b'foo', symlist(b'bar_bar', b'baz.baz')),
        ...     b'foo(bar($1, $2))':
        ...         func(b'foo', func(b'bar', symlist(b'$1', b'$2'))),
        ...     b'foo($1, $2, nested($1, $2))':
        ...         func(b'foo', (symlist(b'$1', b'$2') +
        ...                      (func(b'nested', symlist(b'$1', b'$2')),))),
        ...     b'foo("bar")': func(b'foo', (b'string', b'bar')),
        ...     b'foo($1, $2': error.ParseError(b'unexpected token: end', 10),
        ...     b'foo("bar': error.ParseError(b'unterminated string', 5),
        ...     b'foo($1, $2, $1)': func(b'foo', symlist(b'$1', b'$2', b'$1')),
        ... }
        >>> def parse(expr):
        ...     x = parsemap[expr]
        ...     if isinstance(x, Exception):
        ...         raise x
        ...     return x
        >>> def trygetfunc(tree):
        ...     if not tree or tree[0] != b'func' or tree[1][0] != b'symbol':
        ...         return None
        ...     if not tree[2]:
        ...         return tree[1][1], []
        ...     if tree[2][0] == b'list':
        ...         return tree[1][1], list(tree[2][1:])
        ...     return tree[1][1], [tree[2]]
        >>> class aliasrules(basealiasrules):
        ...     _parse = staticmethod(parse)
        ...     _trygetfunc = staticmethod(trygetfunc)
        >>> builddecl = aliasrules._builddecl
        >>> builddecl(b'foo')
        ('foo', None, None)
        >>> builddecl(b'$foo')
        ('$foo', None, "invalid symbol '$foo'")
        >>> builddecl(b'foo::bar')
        ('foo::bar', None, 'invalid format')
        >>> builddecl(b'foo()')
        ('foo', [], None)
        >>> builddecl(b'$foo()')
        ('$foo()', None, "invalid function '$foo'")
        >>> builddecl(b'foo($1, $2)')
        ('foo', ['$1', '$2'], None)
        >>> builddecl(b'foo(bar_bar, baz.baz)')
        ('foo', ['bar_bar', 'baz.baz'], None)
        >>> builddecl(b'foo($1, $2, nested($1, $2))')
        ('foo($1, $2, nested($1, $2))', None, 'invalid argument list')
        >>> builddecl(b'foo(bar($1, $2))')
        ('foo(bar($1, $2))', None, 'invalid argument list')
        >>> builddecl(b'foo("bar")')
        ('foo("bar")', None, 'invalid argument list')
        >>> builddecl(b'foo($1, $2')
        ('foo($1, $2', None, 'at 10: unexpected token: end')
        >>> builddecl(b'foo("bar')
        ('foo("bar', None, 'at 5: unterminated string')
        >>> builddecl(b'foo($1, $2, $1)')
        ('foo', None, 'argument names collide with each other')
        Nrr�$�invalid symbol '%s'sinvalid function '%s'c3s|]}|d�jkVqdSrA)�_symbolnoder-r�rrrF/r0z,basealiasrules._builddecl.<locals>.<genexpr>sinvalid argument lists&argument names collide with each othercSsg|]}|d�qS)rrr-rrrr/7r0z-basealiasrules._builddecl.<locals>.<listcomp>sinvalid format)r rrrr��
startswithrr�rr<�set)r��declr3r~r��funcrLrr�r�
_builddecl�s.M$



�zbasealiasrules._builddeclcs�t|t�s|S|d}|�jkrF|ft��fdd�|dd�D��St|�dksVJ�|d}|�vrld}n|�d�r�t�td	�|��||fS)
z%Mark alias arguments as ``_aliasarg``rc3s|]}��|��VqdSr
)�_relabelargsrd�rLr�rrrFBr0z.basealiasrules._relabelargs.<locals>.<genexpr>rNr�	_aliasargr�r�)r1r2r�r<r�rrr)r�r3rLrh�symrr�rr�;s

&
zbasealiasrules._relabelargscCs*|�|�}|rt|�}nt�}|�||�S)a�Parse an alias definition into a tree and marks substitutions

        This function marks alias argument references as ``_aliasarg``. The
        parsing rule is provided by ``_parse()``.

        ``args`` is a list of alias argument names, or None if the alias
        is declared as a symbol.

        >>> from . import pycompat
        >>> parsemap = {
        ...     b'$1 or foo': (b'or', (b'symbol', b'$1'), (b'symbol', b'foo')),
        ...     b'$1 or $bar':
        ...         (b'or', (b'symbol', b'$1'), (b'symbol', b'$bar')),
        ...     b'$10 or baz':
        ...         (b'or', (b'symbol', b'$10'), (b'symbol', b'baz')),
        ...     b'"$1" or "foo"':
        ...         (b'or', (b'string', b'$1'), (b'string', b'foo')),
        ... }
        >>> class aliasrules(basealiasrules):
        ...     _parse = staticmethod(parsemap.__getitem__)
        ...     _trygetfunc = staticmethod(lambda x: None)
        >>> builddefn = aliasrules._builddefn
        >>> def pprint(tree):
        ...     s = prettyformat(tree, (b'_aliasarg', b'string', b'symbol'))
        ...     print(pycompat.sysstr(s))
        >>> args = [b'$1', b'$2', b'foo']
        >>> pprint(builddefn(b'$1 or foo', args))
        (or
          (_aliasarg '$1')
          (_aliasarg 'foo'))
        >>> try:
        ...     builddefn(b'$1 or $bar', args)
        ... except error.ParseError as inst:
        ...     print(pycompat.sysstr(parseerrordetail(inst)))
        invalid symbol '$bar'
        >>> args = [b'$1', b'$10', b'foo']
        >>> pprint(builddefn(b'$10 or baz', args))
        (or
          (_aliasarg '$10')
          (symbol 'baz'))
        >>> pprint(builddefn(b'"$1" or "foo"', args))
        (or
          (string '$1')
          (string 'foo'))
        )r r�r�)r��defnrLr3rrr�
_builddefnLs
/

zbasealiasrules._builddefnc	
Cs�d}}|�|�\}}}|r&td�}nHz|�||�}Wn6tjyl}zt|�}td�}WYd}~n
d}~00|r�||j||d�}t||||�S)z>Parse an alias declaration and definition into an alias objectNs4bad declaration of %(section)s "%(name)s": %(error)ss3bad definition of %(section)s "%(name)s": %(error)s)�section�nameserror)r�rr�rrr�_sectionr�)	r�r�r��replZefmtr�rLr�r~rrr�build�s 
�zbasealiasrules.buildcCs,i}|D]\}}|�||�}|||j<q|S)zTParse a list of alias (name, replacement) pairs into a dict of
        alias objects)r�r�)r��items�aliasesr�r��arrr�buildmap�s
zbasealiasrules.buildmapcCs~t|t�sdS|d|jkrD|d}|�|�}|rD|jdurD|dfS|�|�}|rz|\}}|�|�}|rz|jdurz||fSdS)zrIf tree looks like an unexpanded alias, return (alias, pattern-args)
        pair. Return None otherwise.
        Nrr)r1r2r��getrLr�)r�r�r3r�r�r�rLrrr�	_getalias�s



zbasealiasrules._getaliascsBt|t�s|S|ddkr*|d}�|St��fdd�|D��S)zoReplace _aliasarg instances with the substitution value of the
        same name in args, recursively.
        rr�rc3s|]}��|��VqdSr
)�_expandargsr-r�rrrF�r0z-basealiasrules._expandargs.<locals>.<genexpr>)r1r2)r�r3rLr�rr�rr��s
zbasealiasrules._expandargsc	st|t�s|S���|�}|dur>t����fdd�|D��S|\}}|jrXt�|j��|�vr|t�td��j|jd�����	|�|j�vr���
�|j����|j<�|j}���|j
dur�|St|�t|j
�kr�t�td�t|������fdd�|D�}��|tt|j
|���S)Nc3s|]}���|���VqdSr
��_expandr-�r��cacher��	expandingrrrF�sz)basealiasrules._expand.<locals>.<genexpr>s5infinite expansion of %(section)s "%(name)s" detected)r�r�sinvalid number of arguments: %dcsg|]}���|g���qSrr�r-)r�r�r�rrr/�r0z*basealiasrules._expand.<locals>.<listcomp>)r1r2r�rZAbortrrr�r�rXr�r�rnrLr<r��dictrI)	r�r�r3r�r�rir�r`�resultrr�rr��s>
���


�


�zbasealiasrules._expandcCs|�||gi�S)zExpand aliases in tree, recursively.

        'aliases' is a dictionary mapping user defined aliases to alias objects.
        r�)r�r�r3rrr�expand�szbasealiasrules.expand)r5r6r7r�r�r�r��staticmethodr r��classmethodr�r�r�r�r�r�r�r�r�rrrrr��s4



j

5

	


"r�)Nr)Z
__future__rrZi18nr�rrZutilsr�objectr	r@rOrPr[rbrcrjrrrsr{rr�r�rrrr�<module>s"P"F
P
)

Youez - 2016 - github.com/yon3zu
LinuXploit