%PDF- %PDF-
Direktori : /lib/python3/dist-packages/duplicity/__pycache__/ |
Current File : //lib/python3/dist-packages/duplicity/__pycache__/selection.cpython-312.pyc |
� �2e�r � �Z � d dl Z d dlmZ d dlmZ d dlmZmZmZ d dl � G d� de � Zy)� N)�dedent)�diffdir)� GlobbingError�FilePrefixError�select_fn_from_glob)�*c � � e Zd ZdZd� Zd� Zd� Zd� Zd� Zd� Z d� Z d � Zd � Zd� Z dd �Zd� Zdd�Zd� Zdd�Zd� Zdd�Zd� Zdd�Zdd�Zd� Zdd�Zy)�Selectav 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 if 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. c � � t |t � sJ t |� � �g | _ || _ | j j | _ d| _ y)z/Initializer, called with Path of root directoryN)� isinstance�Path�str�selection_functions�rootpath�uc_name�prefix� files_from)�self�paths �5/usr/lib/python3/dist-packages/duplicity/selection.py�__init__zSelect.__init__M sB � ��$��%�0�s�4�y�0�%�#%�� ��� ��m�m�+�+������ c � � | S �N� �r s r �__iter__zSelect.__iter__U s � ��r c �, � t | j � S r )�next�iterr s r �__next__zSelect.__next__X s � ��D�I�I��r c �z � | j j � | j | j � | _ | S )z)Initialize generator, prepare to iterate.)r �setdata�Iterater r s r �set_iterzSelect.set_iter[ s- � � � � �����L�L����/�� ��r c # �: � �K � d� ��� fd�}|j s,t j t d� |j z � yt j t d� |j z � |�� |j � sy ||� g}g }|r� t |d � \ }}|r)|j |� |j ||� � n�|r<|D ]2 }t j t d� |j z d� |�� �4 |dd�= t j t d� |j z � |�� |j � r|j ||� � |r��yy# t $ r& |j � |r|j � Y ��w xY w�w)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 �8 � t j j |j |� } t j |� t j }t j |� rbt j t d� t j |� z t j j t j |� � y t j t d� t j |� z t j j"