%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/duplicity/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/duplicity/__pycache__/dup_temp.cpython-312.pyc

�

�2e� ���dZddlZddlZddlZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
d	�ZGd
�de	j�Z
dd�Zd
�ZGd�de	j �ZGd�de�ZGd�de�ZGd�de�Zy)zManage temporary files�N)�config)�file_naming)�gpg)�log)�path)�tempdirc�\�tj�j�}t|�S)z
    Return a new TempPath
    )r�default�mktemp�TempPath)�filenames �4/usr/lib/python3/dist-packages/duplicity/dup_temp.py�new_temppathr$s$����� �'�'�)�H��H���c��eZdZdZd�Zd�Zy)rz.
    Path object used as a temporary file
    c��tjj|�tj�j|j�y�z#
        Forget and delete
        N)r�Path�deleterr
�forget�name��selfs rrzTempPath.delete1s/��	
�	�	��������� � ����+rc��ttjj||��}|j	|j
�|S)�F
        Returns a fileobj.  When that is closed, delete file
        )�
FileobjHookedrr�open�addhookr�r�mode�fhs   r�open_with_deletezTempPath.open_with_delete8s2���4�9�9�>�>�$��5�
6��
�
�
�4�;�;���	rN)�__name__�
__module__�__qualname__�__doc__rr"�rrrr,s���,�rrc�����	�
��tjsptj�j��	�	j��t
�tj�����
t�
jd��
��||��}nHtj�j�f��}d}|rd}t|j|�d��||��}���	�
�fd�}tjs|j|�|S)a
    Return a file object open for writing, will write to filename

    Data will be processed and written to a temporary file.  When the
    return fileobject is closed, rename to final position.  filename
    must be a recognizable duplicity data file.
    ��parseresults�wb)�tdp�dirpath�partname�permname�remname)�index�abNc�h���j�j����j��y�N)�rename�appendr)r-r.�tdr,�tdpnames�����r�rename_and_forgetz.get_fileobj_duppath.<locals>.rename_and_forgetcs$����
�
�7�>�>�(�+�,�
�	�	�'�r)r�restartr�TemporaryDirectoryrr�TempDupPathr�parser�
filtered_openr�DupPathr)r-r.r/r0�	overwriter!�dpr r9r7r,r8s``       @@@r�get_fileobj_duppathrBAs�����>�>�
�
'�
'����
5���)�)�+���'��0A�0A�(�0K�L��
����d�#������

���\�\�'�,�,�x�k�
:������D�
����T�"������

�����>�>�
�
�
�$�%�
�Irc�`�tj�j�}t||��S)zD
    Return a new TempDupPath, using settings from parseresults
    r))rr
rr<)r*r
s  r�new_tempduppathrDms&����� �'�'�)�H��x�l�;�;rc�$�eZdZdZd�Zd�Zdd�Zy)r<z1
    Like TempPath, but build around DupPath
    c��tjj|�tj�j|j�yr)rr?rrr
rrrs rrzTempDupPath.deletezs/��	
�����D�!����� � ����+rc��ttjj||��}|j	|j
�|S)zO
        Returns a filtered fileobj.  When that is closed, delete file
        )rrr?r>rrrs   r�filtered_open_with_deletez%TempDupPath.filtered_open_with_delete�s4���4�<�<�5�5�d�D�A�
B��
�
�
�4�;�;���	rc��|dk(sJ�ttjj||��}|j	|j
�|S)r�rb)rrr?rrrrs   rr"zTempDupPath.open_with_delete�s@���t�|��|�
�4�<�<�,�,�T�4�8�
9��
�
�
�4�;�;���	rN)rJ)r#r$r%r&rrHr"r'rrr<r<us���,��rr<c�|�eZdZdZ					dd�Zd�Zd�Zd�Zd�Zd�Z	dd	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zee�Zy)rz0
    Simulate a file, but add hook on close
    Nc�t�||_d|_g|_||_||_||_||_||_y)zF
        Initializer.  fileobj is the file object to simulate
        FN)�fileobj�closed�hooklistr,r-r.r/r0)rrMr,r-r.r/r0s       r�__init__zFileobjHooked.__init__�s<����������
������� ��
� ��
���rc�8�|jj|�S)z9
        Write fileobj, return result of write()
        )rM�write)r�bufs  rrRzFileobjHooked.write�s���|�|�!�!�#�&�&rc��|jj�tj|jj	��y)z/
        Flush fileobj and force sync.
        N)rM�flush�os�fsync�filenors rrUzFileobjHooked.flush�s-��	
������
������$�$�&�'rc���tjrJ�|jj|jj|j��|jj�|jd=y)zY
        We have achieved the first checkpoint, make file visible and permanent.
        rN)
rr:r,r5r-r6r.rMrUrOrs r�
to_partialzFileobjHooked.to_partial�sP���>�>�!�!���������+�+�D�M�M�:�;��������M�M�!�rc��tj|j�}|jj	|j
�}|jj	|j�}t
|�}|jr1tj||jtj��nv|jr@tj||jtj tj��n*t#j$|j|j�tj&j)|�y)z�
        We have written the last checkpoint, now encrypt or compress
        and send a copy of it to the remote for final storage.
        ��sizeN)rr=r0r-r6r.�SrcIter�
compressedr�
GzipWriteFiler�sys�maxsize�	encrypted�GPGWriteFiler�gpg_profile�shutil�copyfile�backend�move)r�pr�src�tgt�src_iters     r�	to_remotezFileobjHooked.to_remote�s���
�
�
�t�|�|�
,���l�l�!�!�$�-�-�0���l�l�!�!�$�,�,�/���3�<��
�=�=����h����s�{�{�C�
�\�\����X�s�x�x��1C�1C�#�+�+�V��O�O�C�H�H�c�h�h�/������C� rc��|jj|j�}|jj|j�}t	|�}tj|j�}|jrPtj||jtj��tj|j�ytj|j|j�y)zC
        We are finished, rename to final, gzip if needed.
        r\N)r-r6r.r/r^rr=r_rr`rrarbrV�unlinkr5)rrkrlrmrjs     r�to_finalzFileobjHooked.to_final�s����l�l�!�!�$�-�-�0���l�l�!�!�$�-�-�0���3�<��
�
�
�t�}�}�
-��
�=�=����h����s�{�{�C��I�I�c�h�h���I�I�c�h�h����)rc�8�|jj|�S)z7
        Read fileobj, return result of read()
        )rM�read)r�lengths  rrszFileobjHooked.read�����|�|� � ��(�(rc�6�|jj�S)z5
        Returns current location of fileobj
        )rM�tellrs rrwzFileobjHooked.tell�s���|�|� � �"�"rc�8�|jj|�S)z0
        Seeks to a location of fileobj
        )rM�seek)r�offsets  rryzFileobjHooked.seek�rurc�l�|jj�rJ�|jD]	}|��y)z?
        Close fileobj, running hooks right afterwards
        N)rM�closerO�r�hooks  rr|zFileobjHooked.close�s2���<�<�%�%�'�'�'��M�M�	�D��F�	rc�j�|jj|j�j�y)z&
        delete partial files
        N)r-r6r.rrs r�clean_upzFileobjHooked.clean_up�s#��	
�����D�M�M�*�1�1�3rc�:�|jj|�y)zM
        Add hook (function taking no arguments) to run upon closing
        N)rOr6r}s  rrzFileobjHooked.addhooks��	
�
�
���T�"rc�.�|jjS)z-
        Return the name of the file
        )rMrrs r�get_namezFileobjHooked.get_names���|�|� � � r)NNNNN)���)r#r$r%r&rPrRrUrZrnrqrsrwryr|r�rr��propertyrr'rrrr�se���
������*'�(��!�"*�)�#�)��4�#�!��H��Drrc��eZdZdZd�Zy)�Blockz+
    Data block to return from SrcIter
    c��||_yr4)�data)rr�s  rrPzBlock.__init__s	����	rN)r#r$r%r&rPr'rrr�r�s���rr�c�(�eZdZdZd�Zd�Zd�Zd�Zy)r^z7
    Iterate over source and return Block of data.
    c�>�||_|jd�|_y)NrJ)rkr�fp)rrks  rrPzSrcIter.__init__s������(�(�4�.��rc��	t|jj|j���}js |jj�t �|S#t$retjtd�|jjtj�fzt
jj�Y��wxYw)NzFailed to read %s: %s)r�r�rs�
get_read_size�	Exceptionr�
FatalError�_rk�uc_namera�exc_info�	ErrorCode�genericr�r|�
StopIteration)r�ress  r�__next__zSrcIter.__next__#s���	�������T�%7�%7�%9�:�;�C��x�x��G�G�M�M�O����
���	��N�N��)�*�d�h�h�.>�.>�����-O�O��
�
�%�%�
�	�s�2A"�"A+C�Cc��y)Nir'rs rr�zSrcIter.get_read_size0s��rc��y)Nrr'rs r�
get_footerzSrcIter.get_footer3s��rN)r#r$r%r&rPr�r�r�r'rrr^r^s���!���rr^)F)r&rVrfra�	duplicityrrrrrrrrrrBrDr?r<�objectrr�r^r'rr�<module>r�s|��,�	�
�
��!�������t�y�y��*)�X<��$�,�,��<{�F�{�|�F���f�r

Zerion Mini Shell 1.0