HEX
Server: Apache
System: Linux infong-uk86 4.4.400-icpu-106 #2 SMP Mon Sep 15 08:23:40 UTC 2025 x86_64
User: u44115835 (4976590)
PHP: 8.4.17
Disabled: NONE
Upload Files
File: //kunden/lib/python3/dist-packages/breezy/__pycache__/globbing.cpython-39.pyc
a

�*�^,1�@s�dZddlmZddlZddlmZddlmZmZGdd�de	�Z
e
�Ze�d	d
�e�dd�e�d
d�e�dd�e�dd�e�dd�dd�Z
dd�Zdd�Ze
�Ze�dd�e�dd�e�ded��e�d ed��e�d!e�e
�Ze�d"e�e�d#e
�e�d$d�e�d%d&�e�d'd(�e�d)d*�e�d+d,�e�d-d.�e
�Ze�d#e
�e�d%d&�e�d'd(�e�d+d/�e�d-d0�d1d2�ZGd3d4�d4e	�ZGd5d6�d6e	�ZGd7d8�d8e�Ze�d9�Zd:d;�ZdS)<z�Tools for converting globs to regular expressions.

This module provides functions for converting shell-like globs to regular
expressions.
�)�absolute_importN�)�
lazy_regex)�mutter�warningc@sDeZdZdZe�d�Zddd�Zdd�Zdd	�Z	d
d�Z
dd
�ZdS)�Replacera+Do a multiple-pattern substitution.

    The patterns and substitutions are combined into one, so the result of
    one replacement is never substituted again. Add the patterns and
    replacements via the add method and then call the object. The patterns
    must not contain capturing groups.
    �\\&NcCs4d|_|r$t|j�|_t|j�|_ng|_g|_dS)N)�_pat�list�_pats�_funs)�self�source�r�1/usr/lib/python3/dist-packages/breezy/globbing.py�__init__/szReplacer.__init__cCs"d|_|j�|�|j�|�dS)a^Add a pattern and replacement.

        The pattern must not contain capturing groups.
        The replacement might be either a string template in which \& will be
        replaced with the match, or a function that will get the matching text
        as argument. It does not get match object, because capturing is
        forbidden anyway.
        N)r	r�appendr)r
�pat�funrrr�add8s	zReplacer.addcCs&d|_|j�|j�|j�|j�dS)z�Add all patterns from another replacer.

        All patterns and replacements from replacer are appended to the ones
        already defined.
        N)r	r�extendr)r
Zreplacerrrr�add_replacerEszReplacer.add_replacercCs8|js(t�d�dd�|jD��tj�|_|j�|j|�S)N�|cSsg|]}d|�qS��(%s)r)�.0�prrr�
<listcomp>R�z%Replacer.__call__.<locals>.<listcomp>)	r	r�lazy_compile�joinr�re�UNICODE�sub�_do_sub)r
�textrrr�__call__Os�zReplacer.__call__cCs@|j|jd}t|d�r(||�d��S|j�|�d�|�SdS)Nrr&r)r�	lastindex�hasattr�group�_expandr#)r
�mrrrrr$Vs
zReplacer._do_sub)N)�__name__�
__module__�__qualname__�__doc__rrr*rrrr&r$rrrrr$s

	

rz\[:digit:\]z\dz\[:space:\]z\sz\[:alnum:\]z\wz\[:ascii:\]z\0-\x7fz\[:blank:\]z \tz\[:cntrl:\]z\0-\x1f\x7f-\x9fcCs<|ddvr$dt|dd��dSdt|dd��dS)Nr)�!�^z[^�����]�[)�
_sub_named�r+rrr�
_sub_groupgsr8cs�fdd�}|S)Ncstd|�f��S)NzA'%s' not allowed within a regular expression. Replacing with '%s')rr7��replrr�_ns�z_invalid_regex.<locals>._r)r:r;rr9r�_invalid_regexmsr<cCs(t|�ddkr$td�|dd�S|S)z�Check trailing backslashes.

    Does a head count on trailing backslashes to ensure there isn't an odd
    one on the end that would escape the brackets we wrap the RE in.
    r2rzQRegular expressions cannot end with an odd number of '\'. Dropping the final '\'.Nr3)�lenrr7rrr�_trailing_backslashes_regexusr>z^RE:�z\((?!\?)z(?:z	\(\?P<.*>z
\(\?P=[^)]*\)z\\+$z^RE:.*z \[\^?\]?(?:[^][]|\[:[^]]+:\])+\]z(?:(?<=/)|^)(?:\.?/)+z\\.z\&z[(){}|^$+.]rz(?:(?<=/)|^)\*\*+/z(?:.*/)?z\*+z[^/]*z\?z[^/]z.*�.cCst|dd��S)Nr2)�
_sub_basename��patternrrr�_sub_extension�srDc@sheZdZdZgd�Zedd�edd�edd�d�Zdd�Z	dd	d
�Z
dd�Zed
d��Z
edd��ZdS)�GlobsterawA simple wrapper for a set of glob patterns.

    Provides the capability to search the patterns to find a match for
    a given filename (including the full path).

    Patterns are translated to regular expressions to expidite matching.

    The regular expressions for multiple patterns are aggregated into
    a super-regex containing groups of up to 99 patterns.
    The 99 limitation is due to the grouping limit of the Python re module.
    The resulting super-regex and associated patterns are stored as a list of
    (regex,[patterns]) in _regex_patterns.

    For performance reasons the patterns are categorised as extension patterns
    (those that match against a file extension), basename patterns
    (those that match against the basename of the filename),
    and fullpath patterns (those that match against the full path).
    The translations used for extensions and basenames are relatively simpler
    and therefore faster to perform than the fullpath patterns.

    Also, the extension patterns are more likely to find a match and
    so are matched first, then the basename patterns, then the fullpath
    patterns.
    ��	extension�basename�fullpathz(?:.*/)?(?!.*/)(?:.*\.))�
translator�prefixz(?:.*/)?(?!.*/)r?cCspg|_gggd�}|D] }t|�}|t�|��|�qtj}tjD]&}|�||||d||d�qDdS)NrFrJrK)�_regex_patterns�normalize_patternrE�identifyr�pattern_info�
pattern_types�
_add_patterns)r
�patternsZ
pattern_listsrZpi�trrrr�s�

�zGlobster.__init__csd|r`�fdd�|dd�D�}d|d�|�f}|j�t�|tj�|dd�f�|dd�}qdS)Ncsg|]}d�|��qSrr)rr�rJrrr�sz*Globster._add_patterns.<locals>.<listcomp>�cz	%s(?:%s)$r)r rLrrrr!r")r
rRrJrKZ
grouped_rulesZjoined_rulerrTrrQ�s

�
�zGlobster._add_patternsc	
Cs�z6|jD]*\}}|�|�}|r||jdWSqWn~tjy�}zdtd|j�d|_d}|jD](\}}|D]}t�|�sp|d|7}qpqd|j|7_|�WYd}~n
d}~00dS)��Searches for a pattern that matches the given filename.

        :return A matching pattern or None if there is no matching pattern.
        rz#Invalid pattern found in regex: %s.z=File ~/.config/breezy/ignore or .bzrignore contains error(s).r?z
  %sN)	rL�matchr'r�InvalidPatternr�msgrE�is_pattern_valid)	r
�filenameZregexrRrW�eZbad_patternsr;rrrrrW�s"
�
zGlobster.matchcCs,|�d�sd|vrdS|�d�r$dSdSdS)z�Returns pattern category.

        :param pattern: normalized pattern.
        Identify if a pattern is fullpath, basename or extension
        and returns the appropriate type.
        �RE:�/rIz*.rGrHN)�
startswithrBrrrrNs

zGlobster.identifycCs^d}tjt�|�d}d||�}zt�|tj�}|�d�WntjyXd}Yn0|S)z�Returns True if pattern is valid.

        :param pattern: Normalized pattern.
        is_pattern_valid() assumes pattern to be normalized.
        see: globbing.normalize_pattern
        TrJrr?F)	rErOrNrrr!r"�searchrX)rC�resultrJZtpatternZre_objrrrrZs��
zGlobster.is_pattern_validN)r?)r,r-r.r/rPrDrA�
_sub_fullpathrOrrQrW�staticmethodrNrZrrrrrE�s&����

rEc@s eZdZdZdd�Zdd�ZdS)�ExceptionGlobstera�A Globster that supports exception patterns.

    Exceptions are ignore patterns prefixed with '!'.  Exception
    patterns take precedence over regular patterns and cause a
    matching filename to return None from the match() function.
    Patterns using a '!!' prefix are highest precedence, and act
    as regular ignores. '!!' patterns are useful to establish ignores
    that apply under paths specified by '!' exception patterns.
    cCszgggg}|D]V}|�d�r4|d�|dd��q|�d�rV|d�|dd��q|d�|�qdd�|D�|_dS)Nz!!r2r0rrcSsg|]}t|��qSr)rE)r�irrrr>rz.ExceptionGlobster.__init__.<locals>.<listcomp>)r_r�_ignores)r
rRZignoresrrrrr5s


zExceptionGlobster.__init__cCsD|jd�|�}|rd|S|jd�|�r0dS|jd�|�SdS)rVr2z!!%srNr)rfrW)r
r[Z
double_negrrrrW@szExceptionGlobster.matchN)r,r-r.r/rrWrrrrrd*s
rdc@seZdZdZdd�ZdS)�_OrderedGlobsterz$A Globster that keeps pattern order.cCsJg|_|D]:}t|�}t�|�}|�|gtj|dtj|d�q
dS)zIConstructor.

        :param patterns: sequence of glob patterns
        rJrKN)rLrMrErNrQrO)r
rRrrSrrrrQs
�z_OrderedGlobster.__init__N)r,r-r.r/rrrrrrgNsrgz[\\/]+cCs:|�d�s |�d�s t�d|�}t|�dkr6|�d�}|S)z�Converts backslashes in path patterns to forward slashes.

    Doesn't normalize regular expressions - they may contain escapes.
    r]z!RE:r^r)r_�_slashesr#r=�rstriprBrrrrMbs

rM)r/Z
__future__rr!r?rZtracerr�objectrr6rr8r<r>Z_sub_rerbrArDrErdrgrrhrMrrrr�<module>s^:
��$