HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //usr/lib64/python3.9/site-packages/borg/__pycache__/patterns.cpython-39.opt-1.pyc
a

HZ�h6�@s�ddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZddlmZdd	�Zd5d
d�Zdd
�ZGdd�dej�ZGdd�dej�ZGdd�de�ZGdd�d�Zdd�ZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�ZGd d!�d!e�ZGd"d#�d#e�ZeeeeehZ d$d%�e D�Z!ed&d'�Z"Gd(d)�d)e
�Z#d*d+�Z$d,d-�Z%ed.fd/d0�Z&efd1d2�Z'efd3d4�Z(dS)6�N)�
namedtuple)�Enum�)�shellpattern)�clean_lines)�ErrorcCsHt||d�}|jtjur&|�|j�n|jtjur:|j}n
|�|�|S)zKParse a pattern-file line and act depending on which command it represents.)�fallback)�parse_inclexcl_command�cmd�	IECommand�RootPath�append�val�PatternStyle)�line�roots�ie_commandsrZ
ie_command�r�3/usr/lib64/python3.9/site-packages/borg/patterns.py�parse_patternfile_lines
rcCs,|durt}t|�D]}t||||�}qdS�N)�ShellPatternrr)�fileobjrrrrrrr�load_pattern_filesrcCs t|�D]}|�t|��qdSr)rr
�parse_exclude_pattern)r�patternsZ
patternstrrrr�load_exclude_file#srcs(eZdZd�fdd�	Zddd�Z�ZS)	�ArgparsePatternActionrcst�jfd|i|��dS�N�nargs��super�__init__��selfr�kw��	__class__rrr")szArgparsePatternAction.__init__NcCst|d|j|jt�dS�Nr)r�pathsrr)r$�parser�args�values�
option_stringrrr�__call__,szArgparsePatternAction.__call__)r)N)�__name__�
__module__�__qualname__r"r.�
__classcell__rrr&rr(srcs0eZdZd	�fdd�	Zd
dd�Zdd�Z�ZS)�ArgparsePatternFileActionrcst�jfd|i|��dSrr r#r&rrr"1sz"ArgparsePatternFileAction.__init__Nc
Csv|d}z8t|��}|�||�Wd�n1s40YWn0typ}ztt|���WYd}~n
d}~00dS)z�Load and parse patterns from a file.
        Lines empty or starting with '#' after stripping whitespace on both line ends are ignored.
        rN)�open�parse�FileNotFoundErrorr�str)r$r*r+r,r-�filename�f�errrr.4s
.z"ArgparsePatternFileAction.__call__cCst||j|j�dSr)rr)r�r$Zfobjr+rrrr5?szArgparsePatternFileAction.parse)r)N)r/r0r1r"r.r5r2rrr&rr30s
r3c@seZdZdd�ZdS)�ArgparseExcludeFileActioncCst||j�dSr)rrr;rrrr5DszArgparseExcludeFileAction.parseN)r/r0r1r5rrrrr<Csr<c@sReZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�PatternMatcherz�Represents a collection of pattern objects to match paths against.

    *fallback* is a boolean value that *match()* returns if no matching patterns are found.

    NcCs@g|_||_i|_d|_d|_g|_tjdtjdtj	di|_
dS)NTF)�_itemsr�_path_full_patterns�recurse_dir�recurse_dir_default�include_patternsr�Exclude�ExcludeNoRecurse�Include�is_include_cmd)r$rrrrr"Ns�zPatternMatcher.__init__cCst|j�ot|j�Sr)�lenr>r?�r$rrr�emptyiszPatternMatcher.emptycCs0t|t�r|j}||j|<n|j�||f�dS)z%*cmd* is an IECommand value.
        N)�
isinstance�PathFullPattern�patternr?r>r
)r$rLr
�keyrrr�_addls
zPatternMatcher._addcCs|D]}|�||�qdS)z�Add list of patterns to internal list. *cmd* indicates whether the
        pattern is an include/exclude pattern, and whether recursion should be
        done on excluded folders.
        N�rN)r$rr
rLrrr�adduszPatternMatcher.addcCs.dd�|D�}|�|tj�||_||_dS)zHUsed to add inclusion-paths from args.paths (from commandline).
        cSsg|]}t|t��qSr)�
parse_pattern�PathPrefixPattern��.0�prrr�
<listcomp>��z3PatternMatcher.add_includepaths.<locals>.<listcomp>N)rPrrErrB)r$Z
include_pathsrBrrr�add_includepaths}szPatternMatcher.add_includepathscCsdd�|jD�S)z�Note that this only returns patterns added via *add_includepaths* and it
           won't return PathFullPattern patterns as we do not match_count for them.
        cSs$g|]}|jdkrt|t�s|�qS)r)�match_countrJrKrSrrrrV�s�zAPatternMatcher.get_unmatched_include_patterns.<locals>.<listcomp>)rBrHrrr�get_unmatched_include_patterns�sz-PatternMatcher.get_unmatched_include_patternscCs|D]\}}|�||�qdS)zBAdd list of patterns (of type CmdTuple) to internal list.
        NrO)r$rrLr
rrr�add_inclexcl�szPatternMatcher.add_inclexclcCs�t|��tjj�}t�}|j�||�}||urBt|�|_	|j
|S|jD],\}}|j|dd�rH|j	|_	|j
|SqH|j
|_	|jS)z�Return True or False depending on whether *path* is matched.

        If no match is found among the patterns in this matcher, then the value
        in self.fallback is returned (defaults to None).

        F)�	normalize)�normalize_path�lstrip�os�path�sep�objectr?�get�command_recurses_dirr@rFr>�matchrAr)r$r`Znon_existent�valuerLr
rrrre�s

zPatternMatcher.match)N)r/r0r1�__doc__r"rIrNrPrXrZr[rerrrrr=Hs
	r=cCstjdkrt�d|�S|S)z=normalize paths for MacOS (but do nothing on other platforms)�darwinZNFD)�sys�platform�unicodedatar\)r`rrrr]�sr]c@sHeZdZdZeZddd�Zddd�Zdd	�Zd
d�Z	dd
�Z
dd�ZdS)�PatternBasez3Shared logic for inclusion/exclusion patterns.
    FcCs(||_d|_t|�}|�|�||_dSr()�pattern_origrYr]�_preparer@)r$rLr@rrrr"�s

zPatternBase.__init__TcCs,|rt|�}|�|�}|r(|jd7_|S)aReturn a boolean indicating whether *path* is matched by this pattern.

        If normalize is True (default), the path will get normalized using normalize_path(),
        otherwise it is assumed that it already is normalized using that function.
        r)r]�_matchrY)r$r`r\�matchesrrrre�s
zPatternBase.matchcCst|��d|j�d�S)N�(�))�typerLrHrrr�__repr__�szPatternBase.__repr__cCs|jSr)rmrHrrr�__str__�szPatternBase.__str__cCst�dS)z$Should set the value of self.patternN��NotImplementedError�r$rLrrrrn�szPatternBase._preparecCst�dSrrv�r$r`rrrro�szPatternBase._matchN)F)T)r/r0r1rg�NotImplemented�PREFIXr"rertrurnrorrrrrl�s


rlc@s$eZdZdZdZdd�Zdd�ZdS)rKzFull match of a path.ZpfcCstj�|��tjj�|_dSr)r_r`�normpathr^rarLrxrrrrn�szPathFullPattern._preparecCs
||jkSr)rLryrrrro�szPathFullPattern._matchN�r/r0r1rgr{rnrorrrrrK�srKc@s$eZdZdZdZdd�Zdd�ZdS)rRz�Literal files or directories listed on the command line
    for some operations (e.g. extract, but not create).
    If a directory is specified, all paths that start with that
    path match as well.  A trailing slash makes no difference.
    �ppcCs*tjj}tj�|��|�|�|�|_dSr)r_r`rar|�rstripr^rL�r$rLrarrrrn�szPathPrefixPattern._preparecCs|tjj�|j�Sr)r_r`ra�
startswithrLryrrrro�szPathPrefixPattern._matchNr}rrrrrR�srRc@s$eZdZdZdZdd�Zdd�ZdS)�FnmatchPattern��Shell glob patterns to exclude.  A trailing slash means to
    exclude the contents of a directory, but not the directory itself.
    ZfmcCsz|�tjj�r:tj�|��tjj�tjjdtjj}ntj�|�tjjd}|�tjj�|_t�	t
�|j��|_dS)N�*)
�endswithr_r`rar|rr^rL�re�compile�fnmatch�	translate�regexrxrrrrns
,zFnmatchPattern._preparecCs|j�|tjj�duSr�r�rer_r`raryrrrroszFnmatchPattern._matchNr}rrrrr��sr�c@s$eZdZdZdZdd�Zdd�ZdS)rr��shcCsztjj}|�|�r:tj�|��|�|d|d|}ntj�|�|d|d}|�|�|_t�	t
�|j��|_dS)Nz**r�)
r_r`rar�r|rr^rLr�r�rr�r�r�rrrrns
(zShellPattern._preparecCs|j�|tjj�duSrr�ryrrrro$szShellPattern._matchNr}rrrrrsrc@s$eZdZdZdZdd�Zdd�ZdS)�RegexPatternz#Regular expression to exclude.
    r�cCs||_t�|�|_dSr)rLr�r�r�rxrrrrn-szRegexPattern._preparecCs,tjjdkr|�tjjd�}|j�|�duS)N�/)r_r`ra�replacer��searchryrrrro1szRegexPattern._matchNr}rrrrr�(sr�cCsi|]}|j|�qSr)r{)rT�irrr�
<dictcomp>ArWr��CmdTuplezval cmdc@s$eZdZdZdZdZdZdZdZdS)rz8A command that an InclExcl file line can represent.
    r����N)	r/r0r1rgrrrErCrDrrrrrFsrcCs|tjfvSr)rrD)r
rrrrdPsrdcCs2z
t|WSty,td|���d�Yn0dS)NzUnknown pattern style: )�_PATTERN_CLASS_BY_PREFIX�KeyError�
ValueError)�prefixrrr�get_pattern_classUs
r�TcCsZt|�dkrL|ddkrL|dd���rL|dd�|dd�}}t|�}n|}|||�S)z^Read pattern from string and return an instance of the appropriate implementation class.

    r��:Nr�)rG�isalnumr�)rLrr@Zstyle�clsrrrrQ\s
(
rQcCst||dd�}t|tj�S)z]Read pattern from string and return an instance of the appropriate implementation class.
    F)r@)rQr�rrD)Zpattern_strrZepattern_objrrrrhsrcCs�tjtjtjtjtjtjtjd�}|s0t�d��|�|d�}|durZt�dd�	|���|dd��
�}|sxt�d��|tjur�|}nP|tjur�zt|�}Wq�ty�t�d	|����Yq�0nt
|�}t|||�}t||�S)
zHRead a --patterns-from command from string and return a CmdTuple object.)�-�!�+�R�r�PrUz$A pattern/command must not be empty.rNz,A pattern/command must start with any of: %sz, rz)A pattern/command must have a value part.zInvalid pattern style: )rrCrDrErr�argparse�ArgumentTypeErrorrc�joinr^r�r�rdrQr�)Zcmd_line_strrZcmd_prefix_mapr
Z
remainder_strrr@rrrr	os8�	
�


r	)N))r�r�Zos.pathr_r�rirk�collectionsr�enumr�rZhelpersrZhelpers.errorsrrrr�Actionrr3r<r=r]rlrKrRr�rr�Z_PATTERN_CLASSESr�r�rrdr�rQrr	rrrr�<module>sL
f'�