Server : Apache System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64 User : dh_edsupp ( 6597262) PHP Version : 8.2.26 Disable Function : NONE Directory : /lib/python3/dist-packages/duplicity/__pycache__/ |
Upload File : |
o ��`�W � @ s� d dl mZ d dl mZ d dl mZ d dlZd dlZd dlZd dlZd dlm Z d dlm Z d dlmZ d dlmZ d d l mZmZmZ d d lT G dd� de�ZdS ) � )�next)�str)�objectN)�config)�diffdir)�log)�util)� GlobbingError�FilePrefixError�select_fn_from_glob)�*c @ s� e Zd ZdZe�dejejB �Zdd� Z dd� Z dd� Zd d � Zdd� Z d d� Zdd� Zdd� Zdd� Zd*dd�Zdd� Zdd� Zdd� Zdd� Zd d!� Zd"d#� Zd$d%� Zd&d'� Zd(d)� ZdS )+�Selectay Iterate appropriate Paths in given directory This class acts as an iterator on account of its next() method. Basically, it just goes through all the files in a directory in order (depth-first) and subjects each file to a bunch of tests (selection functions) in order. The first test that includes or excludes the file means that the file gets included (iterated) or excluded. The default is include, so with no tests we would just iterate all the files in the directory in order. The one complication to this is that sometimes we don't know whether or not to include a directory until we examine its contents. For instance, if we want to include all the **.py files. If /home/ben/foo.py exists, we should also include /home and /home/ben, but if these directories contain no **.py files, they shouldn't be included. For this reason, a test may not include or exclude a directory, but merely "scan" it. If later a file in the directory gets included, so does the directory. As mentioned above, each test takes the form of a selection function. The selection function takes a path, and returns: None - means the test has nothing to say about the related file 0 - the file is excluded by the test 1 - the file is included 2 - the test says the file (must be directory) should be scanned Also, a selection function f has a variable f.exclude which should be true iff f could potentially exclude some file. This is used to signal an error if the last function only includes, which would be redundant and presumably isn't what the user intends. z(.*[*?[]|ignorecase\:)c C s0 t |t�sJ t|���g | _|| _| jj| _dS )z/Initializer, called with Path of root directoryN)� isinstance�Pathr �selection_functions�rootpath�uc_name�prefix)�self�path� r �5/usr/lib/python3/dist-packages/duplicity/selection.py�__init__T s zSelect.__init__c C s | S �Nr �r r r r �__iter__[ s zSelect.__iter__c C s t | j�S r )r �iterr r r r �__next__^ s zSelect.__next__c C s | j �� | �| j �| _| S )z)Initialize generator, prepare to iterate.)r �setdata�Iterater r r r r �set_itera s zSelect.set_iterc # sD � dd� � � �fdd�}|j st�td�|j � dS t�td�|j � |V |�� s.dS ||�g}g }|r�z t|d �\}}W n tyT |� � |rR|� � Y q5w |d kr�|rs|D ]}t� td�|j d � |V q]|dd�= t�td�|j � |V |�� r�|�||�� n|dkr�|�|� |�||�� |s7dS dS )a Return iterator yielding paths in path This function looks a bit more complicated than it needs to be because it avoids extra recursion (and no extra function calls for non-directory files) while still doing the "directory scanning" bit. c S s� t j�|j|�}z9t �|�tj }t�|�r,t�t d�t �|� tjj t �|�� W d S t�t d�t �|� tjjt �|�� W d S ty^ t�t d�t �|� tjjt �|�� Y d S w )NzSkipping socket %szError initializing file %s�'Error accessing possibly locked file %s)�osr �join�name�stat�ST_MODE�S_ISSOCKr �Info�_r �fsdecode�InfoCode�skipping_socket�escape�Warn�WarningCode�cannot_iterate�OSError�cannot_stat)�excr �filename�fullpath�moder r r � error_handlerr s( � �����z%Select.Iterate.<locals>.error_handlerc 3 s� � ddl m} |�| �D ]]}|�� tj| |f�}|ri��|�}|jdv rRt� |j tj�sR|dks4|dkrRt� td�|j tjjt�|j �� tjrQtj jd7 _q|dkr\|dfV q|dkri|�� ri|dfV qdS )a Generate relevant files in directory path Returns (path, num) where num == 0 means path should be generated normally, num == 1 means the path is a directory and should be included iff something inside is included. r )�robust)�reg�dir� � r! N)� duplicityr8 �listpath�check_common_errorr �appendr �typer"