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__/match.cpython-39.pyc
a

�+�bA��
@sRddlmZmZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
mZmZmZm
Z
mZddlmZe�d�Zd	Zd
ZejZdd�Zd\dd�Zdd�Zdd�Zd]dd�Zd^dd�Zd_dd�Zd`dd�Z dadd�Z!dd �Z"dbd!d"�Z#Gd#d$�d$e$�Z%Gd%d&�d&e%�Z&Gd'd(�d(e%�Z'Gd)d*�d*e%�Z(d+d,�Z)Gd-d.�d.e%�Z*Gd/d0�d0e$�Z+Gd1d2�d2e%�Z,Gd3d4�d4e%�Z-Gd5d6�d6e%�Z.d7d8�Z/Gd9d:�d:e%�Z0Gd;d<�d<e%�Z1Gd=d>�d>e%�Z2Gd?d@�d@e%�Z3dcdAdB�Z4dCdD�Z5dEdF�Z6dGdH�Z7dIdJ�Z8dKZ9dLdM�Z:dNdO�Z;dPdQ�Z<dRdS�Z=dTdU�Z>dVdW�Z?dXdY�Z@daAdddZd[�ZBdS)e�)�absolute_import�print_functionN�)�_)�open)�encoding�error�pathutil�policy�pycompat�util)�
stringutil�dirstate)
�re�glob�path�relglob�relpath�relre�rootglob�listfile�	listfile0�set�include�
subinclude�rootfilesin�rrcCs2tj�|�}z|jWSty,|jYS0dS)zZcompile the regexp with the best available regexp engine and return a
    matcher functionN)r�re�compileZ
test_match�AttributeError�match)�regex�m�r#�5/usr/lib64/python3.9/site-packages/mercurial/match.py�
_rematcher2s
r%Fc
Cs�g}g}|D]�\}}}	|dkr�|dur0t�d��|�|j|||d��|r|jD]2}
|�|
�j|||d�}t|
||d�}|�|�qPq|�|||	f�q||fS)zFReturns the kindpats list with the 'set' patterns expanded to matchersrNs"fileset expression with no context��badfn)r�ProgrammingError�appendZmatchfilesetZsubstate�sub�prefixdirmatcher)
�cwd�kindpats�ctx�listsubreposr'�matchers�other�kind�pat�sourceZsubpathZsmZpmr#r#r$�_expandsets=s"�
r5cCs�g}g}|D]�\}}}|dkr�t�t�|��}t�|�}t�||�}t�|�}	|	dgd|gf}
t�|||	�}|rz|d7}|�||
f�q|�|||f�q||fS)z_Returns the list of subinclude matcher args and the kindpats without the
    subincludes in it.r�s
include:%s�/)r	�dirnamer�normpathZpconvert�join�	canonpathr))r-�rootZrelmatchersr1r2r3r4Z
sourceroot�pathZnewroot�matcherargs�prefixr#r#r$�_expandsubincludeUs

r@cCs*|D] \}}}|dks|dvrdSqdS)zQChecks whether the kindspats match everything, as e.g.
    'relpath:.' does.
    r6rFTr#�r-r2r3r4r#r#r$�_kindpatsalwaysmatchnsrBc
Csng}t|||||d�\}}|r6||||d�}	|�|	�|rD|�|�|sRt|d�St|�dkrf|dSt|�S)N�r.r/r'r&rr)r5r)�extend�nevermatcher�len�unionmatcher)
Z
matcherclsr<r,r-r.r/r'r0Zfmsr"r#r#r$�_buildkindpatsmatcherxs$	�



rHrc	stj�|�sJ�tj�|t�|��}t}|rJ|��j��j	���fdd�}|r�|||||||	�}
t
|
�rrt|
�}q�tt
|||
|||
d�}nt|
�}|r�||d||||	�}
tt|||
||dd�}t||�}|r�||d||||	�}
tt|||
||dd�}t||�}|S)a�
build an object to match a set of file patterns

    arguments:
    root - the canonical root of the tree you're matching against
    cwd - the current working directory, if relevant
    patterns - patterns to find
    include - patterns to include (unless they are excluded)
    exclude - patterns to exclude (even if they are included)
    default - if a pattern in patterns has no explicit type, assume this one
    auditor - optional path auditor
    ctx - optional changecontext
    listsubrepos - if True, recurse into subrepositories
    warn - optional function used for printing warnings
    badfn - optional bad() callback for this matcher instead of the default
    icasefs - make a matcher for wdir on case insensitive filesystems, which
        normalizes the given patterns to the case in the filesystem

    a pattern is one of:
    'glob:<glob>' - a glob relative to cwd
    're:<regexp>' - a regular expression
    'path:<path>' - a path relative to repository root, which is matched
                    recursively
    'rootfilesin:<path>' - a path relative to repository root, which is
                    matched non-recursively (will not match subdirectories)
    'relglob:<glob>' - an unrooted glob (*.c matches C files in all dirs)
    'relpath:<path>' - a path relative to cwd
    'relre:<regexp>' - a regexp that needn't match the start of a name
    'set:<fileset>' - a fileset expression
    'include:<path>' - a file of patterns to read and include
    'subinclude:<path>' - a file of patterns to match against files under
                          the same directory
    '<something>' - a pattern of the specified default type

    >>> def _match(root, *args, **kwargs):
    ...     return match(util.localpath(root), *args, **kwargs)

    Usually a patternmatcher is returned:
    >>> _match(b'/foo', b'.', [b're:.*\.c$', b'path:foo/a', b'*.py'])
    <patternmatcher patterns='.*\\.c$|foo/a(?:/|$)|[^/]*\\.py$'>

    Combining 'patterns' with 'include' (resp. 'exclude') gives an
    intersectionmatcher (resp. a differencematcher):
    >>> type(_match(b'/foo', b'.', [b're:.*\.c$'], include=[b'path:lib']))
    <class 'mercurial.match.intersectionmatcher'>
    >>> type(_match(b'/foo', b'.', [b're:.*\.c$'], exclude=[b'path:build']))
    <class 'mercurial.match.differencematcher'>

    Notice that, if 'patterns' is empty, an alwaysmatcher is returned:
    >>> _match(b'/foo', b'.', [])
    <alwaysmatcher>

    The 'default' argument determines which kind of pattern is assumed if a
    pattern has no prefix:
    >>> _match(b'/foo', b'.', [b'.*\.c$'], default=b're')
    <patternmatcher patterns='.*\\.c$'>
    >>> _match(b'/foo', b'.', [b'main.py'], default=b'relpath')
    <patternmatcher patterns='main\\.py(?:/|$)'>
    >>> _match(b'/foo', b'.', [b'main.py'], default=b're')
    <patternmatcher patterns='main.py'>

    The primary use of matchers is to check whether a value (usually a file
    name) matches againset one of the patterns given at initialization. There
    are two ways of doing this check.

    >>> m = _match(b'/foo', b'', [b're:.*\.c$', b'relpath:a'])

    1. Calling the matcher with a file name returns True if any pattern
    matches that file name:
    >>> m(b'a')
    True
    >>> m(b'main.c')
    True
    >>> m(b'test.py')
    False

    2. Using the exact() method only returns True if the file name matches one
    of the exact patterns (i.e. not re: or glob: patterns):
    >>> m.exact(b'a')
    True
    >>> m.exact(b'main.c')
    False
    csnt||||||�}g}|D]N\}}	}
|dvrX|	}�|	�}	||	krX|�vrX|�|||
f�|�||	|
f�q|S)N)rr)�_donormalizer))�patterns�defaultr<r,�auditor�warn�kpr-r2Zpatsr4�p�rZdsnormalizer#r$�	normalize�szmatch.<locals>.normalizerCrN)�osr=�isabsr:r�	localpathrIZreporrQrB�
alwaysmatcherrH�patternmatcher�includematcher�intersectmatchers�differencematcher)r<r,rJZincludeZexcluderKrLr.r/rMr'ZicasefsrQr-r"ZimZemr#rPr$r �s\`

��	
�	
r cCst||d�S)Nr&)�exactmatcher)�filesr'r#r#r$�exact9sr\cCst|�S�N)rUr&r#r#r$�always=sr^cCst|�Sr])rEr&r#r#r$�neverAsr_cCst�|�}||_|S)zWMake a copy of the given matcher, replacing its bad method with the given
    one.
    )�copy�bad)r r'r"r#r#r$�badmatchEs
rbcs�g}�fdd�|D�D�]�\}}|tvr>tj||||d�}�n�|dvrTt�|�}�n�|dvr�z8t�|�}	|dkr||	�d�}	n|	��}	dd�|	D�}	Wn$ty�t	�
td	�|��Yn0t|	�||||�D]\}
}}|�
|
||f�q�qn�|d
k�r�zXtj�|t�|��}
t|
|�}t|�||||�D]"\}
}}|�
|
||�pB|f��q(Wqt	j
�y�}z t	�
d||jf��WYd}~qd}~0t�y�}z.|�r�|td
�|t�|j�f�WYd}~qd}~00q|�
||df�q|S)z�Convert 'kind:pat' from the patterns list to tuples with kind and
    normalized and rooted patterns and with listfiles expanded.csg|]}t|���qSr#��	_patsplit)�.0rO�rKr#r$�
<listcomp>Rr6z _donormalize.<locals>.<listcomp>)rL)rrrr)rrr�cSsg|]}|r|�qSr#r#�re�fr#r#r$rg^r6sunable to read file list (%s)rs%s: %sNs*skipping unreadable pattern file '%s': %s
r6)�cwdrelativepatternkindsr	r;rr9Zreadfile�split�
splitlines�EnvironmentErrorr�AbortrrIr)rRr=r:rT�readpatternfile�message�IOErrorr
Zforcebytestr�strerror)rJrKr<r,rLrMr-r2r3r[�krOr4�fullpathZincludepats�instr#rfr$rINs\
�

������rIc@s�eZdZddd�Zdd�Zdd�ZdZedd	��Zd
d�Z	edd
��Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�basematcherNcCs|dur||_dSr])ra��selfr'r#r#r$�__init__�szbasematcher.__init__cCs
|�|�Sr])�matchfn)ry�fnr#r#r$�__call__�szbasematcher.__call__cCsdS)zoCallback from dirstate.walk for each explicit file that can't be
        found/accessed, with an error message.Nr#�ryrj�msgr#r#r$ra�szbasematcher.badcCsgSr]r#�ryr#r#r$�_files�szbasematcher._filescCs|jS)z�Explicitly listed files or patterns or roots:
        if no patterns or .always(): empty list,
        if exact: list exact files,
        if not .anypats(): list all files and dirs,
        else: optimal roots�r�r�r#r#r$r[�szbasematcher.filescCs
t|j�Sr])�setr�r�r#r#r$�_fileset�szbasematcher._filesetcCs
||jvS)z!Returns True if f is in .files().)r��ryrjr#r#r$r\�szbasematcher.exactcCsdS�NFr#r�r#r#r$r{�szbasematcher.matchfncCsdS)a�Decides whether a directory should be visited based on whether it
        has potential matches in it or one of its subdirectories. This is
        based on the match's primary, included, and excluded patterns.

        Returns the string 'all' if the given directory and all subdirectories
        should be visited. Otherwise returns True or False indicating whether
        the given directory should be visited.
        Tr#�ry�dirr#r#r$�visitdir�s	zbasematcher.visitdircCsdS)a]Decides whether a directory should be visited based on whether it
        has potential matches in it or one of its subdirectories, and
        potentially lists which subdirectories of that directory should be
        visited. This is based on the match's primary, included, and excluded
        patterns.

        This function is very similar to 'visitdir', and the following mapping
        can be applied:

             visitdir | visitchildrenlist
            ----------+-------------------
             False    | set()
             'all'    | 'all'
             True     | 'this' OR non-empty set of subdirs -or files- to visit

        Example:
          Assume matchers ['path:foo/bar', 'rootfilesin:qux'], we would return
          the following values (assuming the implementation of visitchildrenset
          is capable of recognizing this; some implementations are not).

          '' -> {'foo', 'qux'}
          'baz' -> set()
          'foo' -> {'bar'}
          # Ideally this would be 'all', but since the prefix nature of matchers
          # is applied to the entire matcher, we have to downgrade this to
          # 'this' due to the non-prefix 'rootfilesin'-kind matcher being mixed
          # in.
          'foo/bar' -> 'this'
          'qux' -> 'this'

        Important:
          Most matchers do not know if they're representing files or
          directories. They see ['path:dir/f'] and don't know whether 'f' is a
          file or a directory, so visitchildrenset('dir') for most matchers will
          return {'f'}, but if the matcher knows it's a file (like exactmatcher
          does), it may return 'this'. Do not rely on the return being a set
          indicating that there are no files in this dir to investigate (or
          equivalently that if there are files to investigate in 'dir' that it
          will always return 'this').
        �thisr#r�r#r#r$�visitchildrenset�s)zbasematcher.visitchildrensetcCsdS)zcMatcher will match everything and .files() will be empty --
        optimization might be possible.Fr#r�r#r#r$r^�szbasematcher.alwayscCsdS)zcMatcher will match exactly the list of files in .files() --
        optimization might be possible.Fr#r�r#r#r$�isexact�szbasematcher.isexactcCsdS)z_Matcher will match the paths in .files() recursively --
        optimization might be possible.Fr#r�r#r#r$r?�szbasematcher.prefixcCs|��o|��o|��S)z`None of .always(), .isexact(), and .prefix() is true --
        optimizations will be difficult.)r^r�r?r�r#r#r$�anypats�szbasematcher.anypats)N)�__name__�
__module__�__qualname__rzr}ra�traversedir�
propertycacher�r[r�r\r{r�r�r^r�r?r�r#r#r#r$rw�s"


+rwcsJeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)rUzMatches everything.Ncstt|��|�dSr])�superrUrzrx��	__class__r#r$rz�szalwaysmatcher.__init__cCsdS�NTr#r�r#r#r$r^�szalwaysmatcher.alwayscCsdSr�r#r�r#r#r$r{�szalwaysmatcher.matchfncCsdS�N�allr#r�r#r#r$r�szalwaysmatcher.visitdircCsdSr�r#r�r#r#r$r�szalwaysmatcher.visitchildrensetcCsdS)Nz<alwaysmatcher>r#r�r#r#r$�__repr__szalwaysmatcher.__repr__)N)r�r�r��__doc__rzr^r{r�r�r��
__classcell__r#r#r�r$rU�srUcsJeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)rEzMatches nothing.Ncstt|��|�dSr])r�rErzrxr�r#r$rzsznevermatcher.__init__cCsdSr�r#r�r#r#r$r�sznevermatcher.isexactcCsdSr�r#r�r#r#r$r?sznevermatcher.prefixcCsdSr�r#r�r#r#r$r�sznevermatcher.visitdircCst�Sr])r�r�r#r#r$r� sznevermatcher.visitchildrensetcCsdS)Nz<nevermatcher>r#r�r#r#r$r�#sznevermatcher.__repr__)N)r�r�r�r�rzr�r?r�r�r�r�r#r#r�r$rEsrEcs0eZdZdZd�fdd�	Zejdd��Z�ZS)�predicatematcherz/A matcher adapter for a simple boolean functionNcs tt|��|�||_||_dSr])r�r�rzr{�	_predrepr)ryZpredfnZpredreprr'r�r#r$rz*szpredicatematcher.__init__cCs t�|j�pt�|j�}d|S)Ns<predicatenmatcher pred=%s>)r
Z	buildreprr�rZbytereprr{)ry�sr#r#r$r�/s�zpredicatematcher.__repr__)NN)	r�r�r�r�rzr�	strmethodr�r�r#r#r�r$r�'sr�cs|t��}|dkrdS��vr dS|dkrDt�fdd�t���D��Sd�vrPdStjr`td��nd	�t��fd
d��D��S)zDReturns True if `path` (or any parent of `path`) is in `prefix_set`.rFT�c3s|]}|�vVqdSr]r#)reZ	parentdir)�
prefix_setr#r$�	<genexpr>Bsz)path_or_parents_in_set.<locals>.<genexpr>r6r7�/c3s(|] }��|�o�t|��kVqdSr]��
startswithrF)reZpf)r=�slr#r$r�Rr6)rF�anyr	�finddirsrZispy3�ord)r=r��lr#)r=r�r�r$�path_or_parents_in_set7s�
r�csTeZdZdZd�fdd�	Zedd��Zdd�Zd	d
�Zdd�Z	e
jd
d��Z�Z
S)rVa(Matches a set of (kind, pat, source) against a 'root' directory.

    >>> kindpats = [
    ...     (b're', br'.*\.c$', b''),
    ...     (b'path', b'foo/a', b''),
    ...     (b'relpath', b'b', b''),
    ...     (b'glob', b'*.h', b''),
    ... ]
    >>> m = patternmatcher(b'foo', kindpats)
    >>> m(b'main.c')  # matches re:.*\.c$
    True
    >>> m(b'b.txt')
    False
    >>> m(b'foo/a')  # matches path:foo/a
    True
    >>> m(b'a')  # does not match path:b, since 'root' is 'foo'
    False
    >>> m(b'b')  # matches relpath:b, since 'root' is 'foo'
    True
    >>> m(b'lib.h')  # matches glob:*.h
    True

    >>> m.files()
    ['', 'foo/a', 'b', '']
    >>> m.exact(b'foo/a')
    True
    >>> m.exact(b'b')
    True
    >>> m.exact(b'lib.h')  # exact matches are for (rel)path kinds
    False
    Ncs<tt|��|�t|�|_t|�|_t|d|�\|_|_dS)N�$)	r�rVrz�_explicitfilesr��_prefix�_buildmatch�_patsr{)ryr<r-r'r�r#r$rzvs

zpatternmatcher.__init__cCstt�|j��Sr]�r�r	�dirsr�r�r#r#r$�_dirs}szpatternmatcher._dirscCs*|jr||jvrdS||jvp(t||j�Sr�)r�r�r�r�r�r#r#r$r��szpatternmatcher.visitdircCs0|�|�}|durdS|s t�S|dks,J�dS)NTr�r�)r�r�)ryr��retr#r#r$r��s
zpatternmatcher.visitchildrensetcCs|jSr])r�r�r#r#r$r?�szpatternmatcher.prefixcCsdt�|j�S)Ns<patternmatcher patterns=%r>�r�bytestrr�r�r#r#r$r��szpatternmatcher.__repr__)N)r�r�r�r�rzr�r�r�r�r?rr�r�r�r#r#r�r$rVUs 
	rVc@s2eZdZd
dd�Zdd�Zedd��Zdd	�ZdS)�_dirchildrenNcCs,i|_|pg|_|j}|D]}||�qdSr])r��_onlyinclude�addpath)ry�paths�onlyincluder�rjr#r#r$rz�s

z_dirchildren.__init__cCsN|dkrdS|j}tj}||�D](\}}||jvr4q |�|t���|�q dS�Nr6)r�r��_findsplitdirsr��
setdefaultr��add)ryr=r�Z
findsplitdirs�d�br#r#r$r��s
z_dirchildren.addpathccsbt|�}|�d�}|dkrL|d|�||d|�fV|}|�dd|�}qd|d|�fVdS)Nr7���rrr6)rF�rfind)r=Zoldpos�posr#r#r$r��s
z_dirchildren._findsplitdirscCs|j�|t��Sr])r��getr�)ryr=r#r#r$r��sz_dirchildren.get)N)r�r�r�rzr��staticmethodr�r�r#r#r#r$r��s



r�csHeZdZd�fdd�	Zdd�Zedd��Zdd	�Zej	d
d��Z
�ZS)
rWNcshtt|��|�tdur||_t|d|�\|_|_t|�|_t	|�\}}}t
|�|_t
|�|_||_
dS)N�(?:/|$))r�rWrz�rustmodZ	_kindpatsr�r�r{r��_rootsdirsandparentsr��_rootsr��_parents)ryr<r-r'�rootsr��parentsr�r#r$rz�s


zincludematcher.__init__cCs4|jr||jvrdS||jvp2||jvp2t||j�Sr�)r�r�r�r�r�r�r#r#r$r��s
�
�zincludematcher.visitdircCstt�|j|j|j�|jd�S)N)r�)r��	itertools�chainr�r�r�r�r#r#r$�_allparentschildren�s�z"includematcher._allparentschildrencCsZ|jr||jvrdSd|jvs4||jvs4t||j�r8dS||jvrT|j�|�pRt�St�S)Nr�r6r�)r�r�r�r�r�r�r�r�r�r#r#r$r��s��
�
zincludematcher.visitchildrensetcCsdt�|j�S)Ns<includematcher includes=%r>r�r�r#r#r$r��szincludematcher.__repr__)N)r�r�r�rzr�r�r�r�rr�r�r�r#r#r�r$rW�s	
rWcsreZdZdZd�fdd�	ZejZedd��Z	dd�Z
ed	d
��Zedd��Zd
d�Z
dd�Zejdd��Z�ZS)rZa�Matches the input files exactly. They are interpreted as paths, not
    patterns (so no kind-prefixes).

    >>> m = exactmatcher([b'a.txt', br're:.*\.c$'])
    >>> m(b'a.txt')
    True
    >>> m(b'b.txt')
    False

    Input files that would be matched are exactly those returned by .files()
    >>> m.files()
    ['a.txt', 're:.*\\.c$']

    So pattern 're:.*\.c$' is not considered as a regex, but as a file name
    >>> m(b'main.c')
    False
    >>> m(br're:.*\.c$')
    True
    Ncs0tt|��|�t|t�r"||_n
t|�|_dSr])r�rZrz�
isinstance�listr�)ryr[r'r�r#r$rzs
zexactmatcher.__init__cCstt�|j��Sr]r�r�r#r#r$r�szexactmatcher._dirscCs
||jvSr])r�r�r#r#r$r�szexactmatcher.visitdircCs|j|jdhBS)z2A memoized set of candidates for visitchildrenset.r6)r�r�r�r#r#r$�_visitchildrenset_candidates"sz)exactmatcher._visitchildrenset_candidatescCs
t|j�S)z:A memoized sorted list of candidates for visitchildrenset.)�sortedr�r�r#r#r$�#_sorted_visitchildrenset_candidates'sz0exactmatcher._sorted_visitchildrenset_candidatescs�|jr||jvrt�S|dkr&|j}nf|j}|d}t�||�}|t�t	t
d�d��}tj|||d�}t|���fdd�|||�D�}dd�|D�}|s�J�|S)Nr6r7r)�locsh|]}|�d��qSr]r#�re�c�Zdlenr#r$�	<setcomp>Ar6z0exactmatcher.visitchildrenset.<locals>.<setcomp>cSsh|]}d|vr|�qS)r7r#r�r#r#r$r�Gr6)r�r�r�r�r��bisectZbisect_leftrZ
strtolocal�chrr�rF)ryr�Z
candidatesr��firstZdnextZlastr�r#r�r$r�,szexactmatcher.visitchildrensetcCsdSr�r#r�r#r#r$r�Mszexactmatcher.isexactcCs
d|jS)Ns<exactmatcher files=%r>r�r�r#r#r$r�Pszexactmatcher.__repr__)N)r�r�r�r�rzrwr\r{r�r�r�r�r�r�r�rr�r�r�r#r#r�r$rZ�s


!rZcsZeZdZdZ�fdd�Zdd�Zedd��Zdd	�Zd
d�Z	dd
�Z
ejdd��Z
�ZS)rYz�Composes two matchers by matching if the first matches and the second
    does not.

    The second matcher's non-matching-attributes (bad, traversedir) are ignored.
    cs.tt|���||_||_|j|_|j|_dSr])r�rYrz�_m1�_m2rar��ry�m1�m2r�r#r$rz\s
zdifferencematcher.__init__cCs|�|�o|�|�Sr]�r�r�r�r#r#r$r{cszdifferencematcher.matchfncs*���r �fdd��j��D�S�j��S)Ncsg|]}�|�r|�qSr#r#rir�r#r$rgir6z,differencematcher._files.<locals>.<listcomp>)r�r�r[r�r#r�r$r�fszdifferencematcher._filescCs<|j�|�dkrdS|j�|�s,|j�|�St|j�|��S)Nr�F)r�r�r��boolr�r#r#r$r�qs
zdifferencematcher.visitdircCs>|j�|�}|dkrt�S|j�|�}|s.|S|dvr:dS|S)Nr�)r�r�r�)r�r�r�r�)ryr��m2_set�m1_setr#r#r$r�ysz"differencematcher.visitchildrensetcCs
|j��Sr])r�r�r�r#r#r$r��szdifferencematcher.isexactcCsd|j|jfS)Ns <differencematcher m1=%r, m2=%r>r�r�r#r#r$r��szdifferencematcher.__repr__)r�r�r�r�rzr{r�r�r�r�r�rr�r�r�r#r#r�r$rYUs

rYcCs^|dus|dur|p|S|��r>t�|�}|j|_|j|_|S|��rTt�|�}|St||�S)z�Composes two matchers by matching if both of them match.

    The second matcher's non-matching-attributes (bad, traversedir) are ignored.
    N)r^r`rar��intersectionmatcher)r�r�r"r#r#r$rX�s

rXcs^eZdZ�fdd�Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
ejdd��Z
�ZS)r�cs.tt|���||_||_|j|_|j|_dSr])r�r�rzr�r�rar�r�r�r#r$rz�s
zintersectionmatcher.__init__csR|��r>|j|j}�|��s(�|}��fdd�|��D�S|j��|j��S)Ncsg|]}�|�r|�qSr#r#ri�r�r#r$rg�r6z.intersectionmatcher._files.<locals>.<listcomp>)r�r�r�r[)ryr�r#r�r$r��s
zintersectionmatcher._filescCs|�|�o|�|�Sr]r�r�r#r#r$r{�szintersectionmatcher.matchfncCs4|j�|�}|dkr |j�|�St|o0|j�|��Sr�)r�r�r�r�)ryr�Zvisit1r#r#r$r��szintersectionmatcher.visitdircCsz|j�|�}|st�S|j�|�}|s,t�S|dkr8|S|dkrD|S|dksT|dkrXdSt|t�rlt|t�spJ�|�|�S)Nr�r�)r�r�r�r�r��intersection)ryr�r�r�r#r#r$r��sz$intersectionmatcher.visitchildrensetcCs|j��o|j��Sr])r�r^r�r�r#r#r$r^�szintersectionmatcher.alwayscCs|j��p|j��Sr])r�r�r�r�r#r#r$r��szintersectionmatcher.isexactcCsd|j|jfS)Ns"<intersectionmatcher m1=%r, m2=%r>r�r�r#r#r$r��szintersectionmatcher.__repr__)r�r�r�rzr�r�r{r�r�r^r�rr�r�r�r#r#r�r$r��s
r�cs^eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
ejdd��Z
�ZS)�
subdirmatchera�Adapt a matcher to work on a subdirectory only.

    The paths are remapped to remove/insert the path as needed:

    >>> from . import pycompat
    >>> m1 = match(util.localpath(b'/root'), b'', [b'a.txt', b'sub/b.txt'], auditor=lambda name: None)
    >>> m2 = subdirmatcher(b'sub', m1)
    >>> m2(b'a.txt')
    False
    >>> m2(b'b.txt')
    True
    >>> m2.matchfn(b'a.txt')
    False
    >>> m2.matchfn(b'b.txt')
    True
    >>> m2.files()
    ['b.txt']
    >>> m2.exact(b'b.txt')
    True
    >>> def bad(f, msg):
    ...     print(pycompat.sysstr(b"%s: %s" % (f, msg)))
    >>> m1.bad = bad
    >>> m2.bad(b'x.txt', b'No such file')
    sub/x.txt: No such file
    cs`tt|����|_||_|��|_�fdd�|jD�|_|��r\t	�fdd�|jD��|_dS)Ncs.g|]&}|��d�r|t��dd��qS)r7rNr�ri�r=r#r$rgs�z*subdirmatcher.__init__.<locals>.<listcomp>c3s|]}|�kVqdSr]r#rir�r#r$r�r6z)subdirmatcher.__init__.<locals>.<genexpr>)
r�r�rz�_path�_matcherr^�_alwaysr�r?r�)ryr=�matcherr�r�r$rzs

�zsubdirmatcher.__init__cCs|j�|jd||�dS�Nr7)r�rar�r~r#r#r$raszsubdirmatcher.badcCs|j�|jd|�Sr�)r�r{r�r�r#r#r$r{szsubdirmatcher.matchfncCs*|dkr|j}n|jd|}|j�|�S�Nr6r7)r�r�r�r�r#r#r$r�!szsubdirmatcher.visitdircCs*|dkr|j}n|jd|}|j�|�Sr�)r�r�r�r�r#r#r$r�(szsubdirmatcher.visitchildrensetcCs|jSr])r�r�r#r#r$r^/szsubdirmatcher.alwayscCs|j��o|jSr])r�r?r�r�r#r#r$r?2szsubdirmatcher.prefixcCsd|j|jfS)Ns#<subdirmatcher path=%r, matcher=%r>)r�r�r�r#r#r$r�5s�zsubdirmatcher.__repr__)r�r�r�r�rzrar{r�r�r^r?rr�r�r�r#r#r�r$r��sr�cspeZdZdZd�fdd�	Zedd��Zdd�Zed	d
��Zdd�Z	d
d�Z
dd�Zdd�Ze
jdd��Z�ZS)r+aAdapt a matcher to work on a parent directory.

    The matcher's non-matching-attributes (bad, traversedir) are ignored.

    The prefix path should usually be the relative path from the root of
    this matcher to the root of the wrapped matcher.

    >>> m1 = match(util.localpath(b'/root/d/e'), b'f', [b'../a.txt', b'b.txt'], auditor=lambda name: None)
    >>> m2 = prefixdirmatcher(b'd/e', m1)
    >>> m2(b'a.txt')
    False
    >>> m2(b'd/e/a.txt')
    True
    >>> m2(b'd/e/b.txt')
    False
    >>> m2.files()
    ['d/e/a.txt', 'd/e/f/b.txt']
    >>> m2.exact(b'd/e/a.txt')
    True
    >>> m2.visitdir(b'd')
    True
    >>> m2.visitdir(b'd/e')
    True
    >>> m2.visitdir(b'd/e/f')
    True
    >>> m2.visitdir(b'd/e/g')
    False
    >>> m2.visitdir(b'd/ef')
    False
    Ncs8tt|��|�|st�d��||_|d|_||_dS)Nsprefix path must not be emptyr7)r�r+rzrr(r��_pathprefixr�)ryr=r�r'r�r#r$rz]s

zprefixdirmatcher.__init__cs�fdd��jjD�S)Ncsg|]}�j|�qSr#)r�rir�r#r$rggr6z+prefixdirmatcher._files.<locals>.<listcomp>)r�r�r�r#r�r$r�eszprefixdirmatcher._filescCs*|�|j�sdS|j�|t|j�d��Sr�)r�r�r�r{rFr�r#r#r$r{iszprefixdirmatcher.matchfncCstt�|j��Sr])r�r	r�r�r�r#r#r$�	_pathdirsnszprefixdirmatcher._pathdirscCsF||jkr|j�d�S|�|j�r<|j�|t|j�d��S||jvSr�)r�r�r�r�r�rFr�r�r#r#r$r�rs

zprefixdirmatcher.visitdircCsP||jkr|j�d�S|�|j�r<|j�|t|j�d��S||jvrJdSt�S)Nr6r�)r�r�r�r�r�rFr�r�r�r#r#r$r�ys

z!prefixdirmatcher.visitchildrensetcCs
|j��Sr])r�r�r�r#r#r$r��szprefixdirmatcher.isexactcCs
|j��Sr])r�r?r�r#r#r$r?�szprefixdirmatcher.prefixcCsdt�|j�|jfS)Ns&<prefixdirmatcher path=%r, matcher=%r>)rr�r�r�r�r#r#r$r��s
�zprefixdirmatcher.__repr__)N)r�r�r�r�rzr�r�r{r�r�r�r�r?rr�r�r�r#r#r�r$r+=s

	r+csFeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zej	d
d��Z
�ZS)rGz�A matcher that is the union of several matchers.

    The non-matching-attributes (bad, traversedir) are taken from the first
    matcher.
    cs(|d}tt|���|j|_||_dS)Nr)r�rGrzr��	_matchers)ryr0r�r�r#r$rz�szunionmatcher.__init__cCs|jD]}||�rdSqdS�NTF�r�)ryrjr r#r#r$r{�s
zunionmatcher.matchfncCs6d}|jD]&}|�|�}|dkr(|S||O}q
|S)NFr�)r�r�)ryr��rr"�vr#r#r$r��s


zunionmatcher.visitdircCslt�}d}|jD]N}|�|�}|s$q|dkr4|S|s@|dkrFd}qt|t�sTJ�|�|�}q|rhdS|S)NFr�r�T)r�r�r�r��union)ryr�r��thisr"r�r#r#r$r��s 

zunionmatcher.visitchildrensetcCs
d|jS)Ns<unionmatcher matchers=%r>r�r�r#r#r$r��szunionmatcher.__repr__)r�r�r�r�rzr{r�r�rr�r�r�r#r#r�r$rG�s	rGcCst||�dS)aIf pattern is 'kind:pat' with a known kind, return kind.

    >>> patkind(br're:.*\.c$')
    're'
    >>> patkind(b'glob:*.c')
    'glob'
    >>> patkind(b'relpath:test.py')
    'relpath'
    >>> patkind(b'main.py')
    >>> patkind(b'main.py', default=b're')
    're'
    rrc)�patternrKr#r#r$�patkind�s
r�cCs0d|vr(|�dd�\}}|tvr(||fS||fS)zPSplit a string into the optional pattern kind prefix and the actual
    pattern.�:r)rl�allpatternkinds)r�rKr2r3r#r#r$rd�s
rdc	sNdt����d}d}tjjj}���fdd�}��k�rJ���d�}�d7�|dvrj||||�7}q0|dkr�|�dkr��d7�|�dkr��d7�|d	7}q�|d
7}n|d7}q0|dkr�|d
7}q0|dk�r��}|�k�r��||d�dv�r�|d7}|�k�r(�||d�dk�r(|d7}�q�|�k�r<|d7}nf��|��dd�}|d�|dd�dk�r|d|dd�}n|dd�dk�r�d|}d||f}q0|dk�r�|d7}|d7}q0|dk�r�|�r�|d7}|d8}q0|dk�r�|�r�|d7}q0|dk�r:|�}|�r*�d7�||||�7}n||||�7}q0||||�7}q0|S)a
Convert an extended glob string to a regexp string.

    >>> from . import pycompat
    >>> def bprint(s):
    ...     print(pycompat.sysstr(s))
    >>> bprint(_globre(br'?'))
    .
    >>> bprint(_globre(br'*'))
    [^/]*
    >>> bprint(_globre(br'**'))
    .*
    >>> bprint(_globre(br'**/a'))
    (?:.*/)?a
    >>> bprint(_globre(br'a/**/b'))
    a/(?:.*/)?b
    >>> bprint(_globre(br'[a*?!^][^b][!c]'))
    [a*?!^][\^b][^c]
    >>> bprint(_globre(br'{a,b}'))
    (?:a|b)
    >>> bprint(_globre(br'.\*\?'))
    \.\*\?
    rr6cs��ko���d�S)Nrr#r#��i�nr3r#r$�peek�sz_globre.<locals>.peekrs*?[{},\�*r7s(?:.*/)?�.*�[^/]*�?�.�[s!]�]s\[�\s\\�!�^Ns%s[%s]�{s(?:�}�)�,�|)rFrr
Zregexbytesescapemapr��replace)	r3�res�group�escaperr��j�stuffrOr#r�r$�_globre�sf








  






rcCs�|s|dvrdS|dkr|S|dvr@|dkr0dStj�|�dS|dkrn|dkrVd}ntj�|�d}|d	S|d
kr�t|�}|�d�r�d|td�d
�|Sd||S|dkr�|�d�r�|Sd|S|dvr�t|�|St�d||f��d
S)z|Convert a (normalized) pattern of any kind into a
    regular expression.
    globsuffix is appended to the regexp of globs.)rrr6r�rrrr�rr7s[^/]+$rrrNs(?:|.*/)rr�rrsnot a regex pattern: %s:%s)rr
Zreescaperr�rFrr()r2r3�
globsuffixZescapedZglobrer#r#r$�_regex2s2

rcs�g�t||�\�}�r2i���fdd�}��|�d}|r�tdd�|D��r�dd�|D���fdd	�}d
t�tt����}��|�nt||�\}}��|�t��dkr�|�dfS|�fd
d�fSdS)zlReturn regexp string and a matcher function for kindpats.
    globsuffix is appended to the regexp of globs.csX�D]N\}}|�|�r��|�}|dur8t|�}|�|<||t|�d��rdSqdSr�)r�r�r rF)rjr?r>�mf)�subincludes�submatchersr#r$�matchsubinclude_s

z$_buildmatch.<locals>.matchsubincluder6css|]\}}}|dkVqdS)rNr#�rertrOr�r#r#r$r�or6z_buildmatch.<locals>.<genexpr>cSsh|]\}}}|�qSr#r#r!r#r#r$r�pr6z_buildmatch.<locals>.<setcomp>cs,|�d�}|dkr |d|�}nd}|�vS)Nr7rr)r�)rjrr�)r�r#r$rrs

z_buildmatch.<locals>.mfsrootfilesin: %srrcst�fdd��D��S)Nc3s|]}|��VqdSr]r#)rer�rjr#r$r��r6z0_buildmatch.<locals>.<lambda>.<locals>.<genexpr>�r�r")�
matchfuncsr"r$�<lambda>�r6z_buildmatch.<locals>.<lambda>N)	r@r)�allr
Zpprintr�r��_buildregexmatchrF)r-rr<r r!rr#)r�r$rrr$r�Vs$

r�i NcCs
d�|�S)z5gather multiple regular expressions into a single oner)r:)�regexpsr#r#r$�_joinregexes�sr)c
s�z�g}�fdd�|D�}t|�}d}d}t|�D]j\}}t|�}	|	tkr`td�|	}
t�|
��n.||	tkr�|||�}|�t|��|}d}||	d7}q0|dkr�t|���fdd�}n4||d�}|�t|��d	d�|D���fd
d�}||fWSt	j�y�|D]n\}
}}ztt
|
|���WnLt	j�yv|�r\t�td�||
|f��nt�td�|
|f��Yn0�qt�td
���Yn0dS)aKBuild a match function from a list of kinds and kindpats,
    return regexp string and a matcher function.

    Test too large input
    >>> _buildregexmatch([
    ...     (b'relglob', b'?' * MAX_RE_SIZE, b'')
    ... ], b'$')
    Traceback (most recent call last):
    ...
    Abort: matcher pattern is too long (20009 bytes)
    csg|]\}}}t||���qSr#)rr!)rr#r$rg�r6z$_buildregexmatch.<locals>.<listcomp>rs&matcher pattern is too long (%d bytes)rcst�|��Sr])r��r�)r�r#r$r%�r6z"_buildregexmatch.<locals>.<lambda>NcSsg|]}t|��qSr#)r%)re�gr#r#r$rg�r6cst�fdd��D��S)Nc3s|]}|��VqdSr]r#)rer"r*r#r$r��r6z5_buildregexmatch.<locals>.<lambda>.<locals>.<genexpr>r#r*)�allmatchersr*r$r%�r6s%s: invalid pattern (%s): %ssinvalid pattern (%s): %ssinvalid pattern)r)�	enumeraterF�MAX_RE_SIZErrror)r%rr)r-rZ	allgroupsr(Z
fullregexpZstartidxZ	groupsize�idxr�Z	piecesizerr�funcrtrOr�r#)r,rr�r$r'�sH
� r'cCs�g}g}|D]�\}}}|dvrrg}|�d�D]2}d|vsPd|vsPd|vsPd|vrTq`|�|�q,|�d�|��q|dvr�|dkr�d	}|�|�q|d
vr�|dkr�d	}|�|�q|�d	�q||fS)a1Returns roots and directories corresponding to each pattern.

    This calculates the roots and directories exactly matching the patterns and
    returns a tuple of (roots, dirs) for each. It does not return other
    directories which may also need to be considered, like the parent
    directories.
    rr7rr
rr)rrrr6�r)rlr)r:)r-r�r�r2r3r4r<rOr#r#r$�_patternrootsanddirs�s( r2cCst|�\}}|S)zFReturns root directories to match recursively from the given patterns.)r2)r-r�r�r#r#r$r��sr�cCs<t|�\}}t�}|�t�|��|�t�|��|||fS)a�Returns roots and exact directories from patterns.

    `roots` are directories to match recursively, `dirs` should
    be matched non-recursively, and `parents` are the implicitly required
    directories to walk to items in either roots or dirs.

    Returns a tuple of (roots, dirs, parents).

    >>> r = _rootsdirsandparents(
    ...     [(b'glob', b'g/h/*', b''), (b'glob', b'g/h', b''),
    ...      (b'glob', b'g*', b'')])
    >>> print(r[0:2], sorted(r[2])) # the set has an unstable output
    (['g/h', 'g/h', ''], []) ['', 'g']
    >>> r = _rootsdirsandparents(
    ...     [(b'rootfilesin', b'g/h', b''), (b'rootfilesin', b'', b'')])
    >>> print(r[0:2], sorted(r[2])) # the set has an unstable output
    ([], ['g/h', '']) ['', 'g']
    >>> r = _rootsdirsandparents(
    ...     [(b'relpath', b'r', b''), (b'path', b'p/p', b''),
    ...      (b'path', b'', b'')])
    >>> print(r[0:2], sorted(r[2])) # the set has an unstable output
    (['r', 'p/p', ''], []) ['', 'p']
    >>> r = _rootsdirsandparents(
    ...     [(b'relglob', b'rg*', b''), (b're', b're/', b''),
    ...      (b'relre', b'rr', b'')])
    >>> print(r[0:2], sorted(r[2])) # the set has an unstable output
    (['', '', ''], []) ['']
    )r2r��updater	r�)r-r�r�rOr#r#r$r��s
r�cCsdd�|D�}t|�S)z�Returns the potential explicit filenames from the patterns.

    >>> _explicitfiles([(b'path', b'foo/bar', b'')])
    ['foo/bar']
    >>> _explicitfiles([(b'rootfilesin', b'foo/bar', b'')])
    []
    cSsg|]}|ddvr|�qS)rr1r#)rerNr#r#r$rgr6z"_explicitfiles.<locals>.<listcomp>)r�)r-Zfilabler#r#r$r�s
r�cCs"|D]\}}}|dvrdSqdS)z:Whether all the patterns match a prefix (i.e. recursively)rFTr#rAr#r#r$r�#sr�c
	Cs�ddddddd�}d}g}t|d�}tt�|�dd	�D�]D\}}d
|vr�tsXtj�d�at�|�}	|	rx|d|	�d��}|�	d
d
�}|�
�}|s�q6|�d�r�|dd���}
z||
}Wq6t
y�|r�|td�||
f�Yq60q6|}t�|�D]\\}
}|�|��r$|}|t|�d�}�qRq�|�|
d�r�|}|t|
�dd�}�qRq�|�rn|�||||f�q6|�||�q6|��|S)a.parse a pattern file, returning a list of
    patterns. These patterns should be given to compile()
    to be validated and converted into a match function.

    trailing white space is dropped.
    the escape character is backslash.
    comments start with #.
    empty lines are skipped.

    lines can be of the following formats:

    syntax: regexp # defaults following lines to non-rooted regexps
    syntax: glob   # defaults following lines to non-rooted globs
    re:pattern     # non-rooted regular expression
    glob:pattern   # non-rooted glob
    rootglob:pat   # rooted glob (same root as ^ in regexps)
    pattern        # pattern of the current default type

    if sourceinfo is set, returns a list of tuples:
    (pattern, lineno, originalline).
    This is useful to debug ignore patterns.
    srelre:srelglob:s	rootglob:rr)rsregexprrrrsrbr)�start�#s((?:^|[^\\])(?:\\\\)*)#.*Ns\#ssyntax:�s!%s: ignoring invalid syntax '%s'
r�)rr-rZiterfile�
_commentrerr�search�endr�rstripr��strip�KeyErrorrrZ	iteritemsrFr)�close)
�filepathrMZ
sourceinfoZsyntaxesZsyntaxrJ�fp�lineno�liner"r�Z
linesyntaxZrelsr#r#r$rp.s\�


�
rp)NFN)NFN)
NNNrNNFNNF)N)N)N)NN)N)F)CZ
__future__rrr�r`r�rRrZi18nrrr�rrr	r
rZutilsr
Z
importrustr�r�rkr�r%r5r@rBrHr r\r^r_rbrI�objectrwrUrEr�r�rVr�rWrZrYrXr�r�r+rGr�rdrrr�r.r)r'r2r�r�r�r�r7rpr#r#r#r$�<module>s� 

�
 �
%


	
4tE%=YE=RS4

T$06,

Youez - 2016 - github.com/yon3zu
LinuXploit