%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__/statistics.cpython-312.pyc

�

�2e=���dZddlZddlZddlZddlZddlmZddlmZddlmZddlm	Z	Gd�de
�ZGd	�d
e�Z
Gd�de
�Zy)
z&Generate and process backup statistics�N)�config)�dup_time)�util)�logc��eZdZy)�StatsExceptionN)�__name__�
__module__�__qualname__���6/usr/lib/python3/dist-packages/duplicity/statistics.pyrr#s��r
rc���eZdZdZej
d�ZdZdZdZ	de	zezezZ
dZdZd	�Z
d
�Zd�Zd�Zdd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�StatsObjz@Contains various statistics, provide string conversion functions� )
�SourceFiles�SourceFileSize�NewFiles�NewFileSize�DeletedFiles�ChangedFiles�ChangedFileSize�ChangedDeltaSize�DeltaEntries�RawDeltaSize)�Errors�TotalDestinationSizeChange)�	StartTime�EndTime�ElapsedTime)�Filename)
)rF)rT)rF)rT)rF)rF)rT)rT)rF)rT))l�TB)i@�GB)i�MB)i�KBc�D�|jD]}d|j|<�y)zSet attributes to NoneN)�
stat_attrs�__dict__��self�attrs  r�__init__zStatsObj.__init__Ts#���O�O�	'�D�"&�D�M�M�$��	'r
c� �|j|S)zGet a statistic�r()r*�	attributes  r�get_statzStatsObj.get_statYs���}�}�Y�'�'r
c�"�||j|<y)zSet attribute to given valueNr.)r*r+�values   r�set_statzStatsObj.set_stat]s��#��
�
�d�r
c�2�|j|xxdz
cc<y)zAdd 1 to value of attribute�Nr.r)s  r�increment_statzStatsObj.increment_statas���
�
�d��q� �r
c�J�|jD�cgc]}t|j|����}}|sd}nTtjj
|�}|r6|jjdt|��}d}|ddk(rd}||d}dj|g|z�Scc}w)	z8Return one line abbreviated version of full stats string�.z\\x20r5r�u����r)	�stat_file_attrs�strr0�os�path�join�space_regex�sub�repr)r*�index�use_repr�a�
file_attrs�filename�ns       r�get_stats_linezStatsObj.get_stats_linees���59�5I�5I�J��c�$�-�-��*�+�J�
�J���H��w�w�|�|�U�+�H�� �+�+�/�/�	�4��>�J�����A�;�#�%��A�#�A�b�>���x�x��
��
�
�	
��Ks�!B c����fd�}�ddk(r�dd��jd�}t|�t|j�kr|�t|j|t|j�d�D]#\}}	t	|�}|j|��%|S#t
$r&	t
|�}n#t
$r
|�YnwxYwY�DwxYw)zSet statistics from given linec�"��td��d����Nz
Bad line '�'�r��lines�r�errorz+StatsObj.set_stats_from_line.<locals>.error~s��� �:�d�V�1�!5�6�6r
r;�
Nr)�split�lenr<�zip�int�
ValueError�floatr3)r*rQrR�	linepartsr+�
val_string�vals `     r�set_stats_from_linezStatsObj.set_stats_from_line{s����	7���8�t�����9�D��J�J�s�O�	��y�>�C�� 4� 4�5�5��G� #�D�$8�$8�)�S��I]�I]�E^�D^�D`�:a� b�	%��D�*�
��*�o��
�M�M�$��$�	%����
�
���
�+�C��!���G���
�s6�B"�"	C�,B8�7C�8C�C�
C�C�Cc�f�|j��|j��|j���S)z.Return extended string printing out statistics)�get_timestats_string�get_filestats_string�get_miscstats_string�r*s r�get_stats_stringzStatsObj.get_stats_string�s3���+�+�-�.�t�/H�/H�/J�.K�D�Le�Le�Lg�Kh�i�ir
c�h�g}|j�=|jd|jtj|j�fz�|j�=|jd|jtj|j�fz�|j
s|j�v|j�j|j
�|j|jz
|_|jd|j
d�dtj|j
��d��dj|�S)z5Return portion of statistics string dealing with timezStartTime %.2f (%s)
zEndTime %.2f (%s)
zElapsedTime z.2f� (�)
�)r�appendr�timetoprettyrr �inttoprettyr@)r*�timelists  rr_zStatsObj.get_timestats_string�s�����>�>�%��O�O�'��N�N��)�)�$�.�.�9���
��<�<�#��O�O�%��L�L��)�)�$�,�,�7���
�����N�N�&�4�<�<�+C����'�#'�<�<�$�.�.�#@�� ��O�O�l�4�+;�+;�C�*@��8�CW�CW�X\�Xh�Xh�Ci�Bj�jm�n�o��w�w�x� � r
c�X���fd�}djt|�j��S)z9Return portion of statistics string about files and bytesc�~��|\}}�j|�}|�y|r|�d|�d�j|��d�S|�d|�d�S)z%Return zero or one line of the stringrgrrerfrS)r0�get_byte_summary_string)�stat_file_pairr+�in_bytesr\r*s    �r�filelinez/StatsObj.get_filestats_string.<locals>.fileline�s]���+�N�D�(��-�-��%�C��{�����q���R��(D�(D�S�(I�'J�#�N�N���q���R�(�(r
rg)r@�map�stat_file_pairs)r*rqs` rr`zStatsObj.get_filestats_string�s&���		)��w�w�s�8�T�%9�%9�:�;�;r
c��d}|j}|�|d|�d|j|��d�z
}|j�|dt|j��d�z
}|S)z<Return portion of extended stat string about misc attributesrgzTotalDestinationSizeChange rerfzErrors rS)rrnrrW)r*�misc_string�tdscs   rrazStatsObj.get_miscstats_string�sm�����.�.�����8���b��A]�A]�^b�Ac�@d�dg�h�h�K��;�;�"��W�S����%5�$6�b�9�9�K��r
c��|dkrd}|}nd}|jD]:\}}||k\s�t|�|z}|dk\rd}n
|dk\rd}nd}|�|d|�d	��d
|��cSt|�}|dk(r|�d�S|�t|��d�S)
z9Turn byte count into human readable string like "7.23GB" r�-rg�d�
r5r:r8�frz1 bytez bytes)�byte_abbrev_listrY�roundrW)r*�
byte_count�sign�abbrev_bytes�
abbrev_string�abbrev_count�	precisions       rrnz StatsObj.get_byte_summary_string�s�����>��D�$��J��D�+/�+@�+@�
	M�'�L�-��\�)�$�Z�0�<�?���3�&� !�I�!�R�'� !�I� !�I����Q�y�k��N�;�1�]�O�L�L�
	M��:�&�
���?��V�6�?�"��V�C�
�O�,�F�3�3r
c	���ddd�d�}|jD�cic]}||j|��}}dD]"}|�d�}tj||�||<�$|r�i}|jd}|j
|d<tj|d	<|jj|d
<tj|d
�|d<t|j�|d<|td
�|d<|td�|d<||dddd��g|d<|jD] }	|dj||	ddd����"||d<tj|tj d��Scc}w)a
        Return enriched statistics in JSON format
        @type col_stat: dup_collections.CollectionsStatus
        @param col_stat: allow to gather information about the whole
            backup chain

        @rtype: String
        @return: JSON formated string
        FzN/A)�is_function�defaultc���	|}|D]}	t||�}�|r|�S|S#t$r|cYcSwxYw#t$r$}tjd|���|cYd}~Sd}~wwxYw)a
            retruns "N/A" if value can't de determined.
            @type parent: object
            @param parent: oject where vale should received from. Oject must exists
            @type *attributes: list of str
            @param *attribures: path down to the attribute that should be read
            @type is_function: boolean
            @param is_function: run last attribute as function instead of reading the value direct
            @param default: overwrite return value if value can't be determined
            zCan't read expected attribute: N)�getattr�AttributeError�	Exceptionr�Error)�parentr�r��
attributes�	attr_path�attibute�es       r�fail_save_readz/StatsObj.get_stats_json.<locals>.fail_save_read�s��

�"�	� *�'�H�'�$+�I�x�$@�	�'�
�$�;�&�$�$��*�'�&��'���
��	�	�;�A�3�?�@����
�s6�6�#�
6�6�3�6�3�6�	A#�A�A#�A#)rr�_strr5�action�skipped_inc�
time_full_bkp�time_full_bkp_str�	no_of_inc�
target_url�target�source_path�source�fullset�local_jsonstat_path�get_filenameT)r��local_json_stat�backup_meta�)�cls�indent)r'r(r�timetostring�matched_chain_pairr�rr�r��timerU�incset_listrh�json�dumpsr�BytesEncoder)
r*�col_statr��key�py_obj�t�t_strr��backup_chain�incs
          r�get_stats_jsonzStatsObj.get_stats_json�s���=B�5�	�46:�_�_�E�c�#�t�}�}�S�)�)�E��E�)�	=�A��c��J�E�$�1�1�&��)�<�F�5�M�	=���K�#�6�6�q�9�L�$,�O�O�K��!�)/�);�);�K�
�&�+7�+?�+?�+D�+D�K��(�/7�/D�/D�[�Q`�Ea�/b�K�+�,�'*�<�+C�+C�'D�K��$�$2�6�<�$H�K��!�$2�6�=�$I�K��!�� ��)�"� $��.�K�)�*�$�/�/�
���-�.�5�5�"�3�(=�~�[_�`��
�%0�F�=�!��z�z�&�d�&7�&7��B�B��;Fs�E"c�Z�d|�d�}dt|�z}|�d|j��|�d�S)z0Like get_stats_string, but add header and footerz--------------[ z ]--------------rxrS)rUrc)r*�title�header�footers    r�get_stats_logstringzStatsObj.get_stats_logstring's@��#�E�7�*:�;���s�6�{�"�����D�1�1�3�4�V�H�B�?�?r
c��d�}|jd�D]�}|s�|j�}t|�dkr||�|dd\}}||jvr||�		t|�}t|�}||k(r|j
||�n|j
||���|S#t$rd}Y�FwxYw#t$r||�Y��wxYw)z>Initialize attributes from string, return self for conveniencec� �td|�d���rMrOrPs rrRz-StatsObj.set_stats_from_string.<locals>.error0s�� �:�d�V�1�!5�6�6r
rSr:N)rTrUr'rWrXrYr3)	r*�srRrQ�
line_partsr+�value_string�val1�val2s	         r�set_stats_from_stringzStatsObj.set_stats_from_string-s���	7��G�G�D�M�	�D�������J��:���"��d��!+�B�Q���D�,��4�?�?�*��d��
� ��|�,�D��\�*���4�<��M�M�$��-��M�M�$��-��%	�*���"� ��D� ���
��d��
�s0�!B%�,5B6�%B3�0B6�2B3�3B6�6C
�	C
c��|jd�}|j|j��|j�rJ�y)z%Write statistics string to given path�wN)�open�writerc�close)r*r?�fins   r�write_stats_to_pathzStatsObj.write_stats_to_pathJs4���i�i��n���	�	�$�'�'�)�*��9�9�;���;r
c��|jd�}|j|j��|j�rJ�|S)z5Set statistics from path, return self for convenience�r)r�r��readr�)r*r?�fps   r�read_stats_from_pathzStatsObj.read_stats_from_pathPs6��
�Y�Y�s�^���"�"�2�7�7�9�-��8�8�:��~��r
c��t|t�sJ�|jD]'}|j|�|j|�k7s�'yy)z,Return true if s has same statistics as selfNr5)�
isinstancerr<r0�r*r�r+s   r�stats_equalzStatsObj.stats_equalWsI���!�X�&�&�&��(�(�	�D��}�}�T�"�a�j�j��&6�6��	�r
c
��|jD]}|j|d��|D]|}|jD]k}|j|��|j|d��'|j|���9|j||j|�|j|�z��m�~d|_d|_|jD]J}|j|���|j||j|�tt
|��z��L|S)z9Set self's attributes to average of those in statobj_listrN)r'r3r0rrrYrU)r*�statobj_listr+�statobjs    r�set_to_averagezStatsObj.set_to_average_s����O�O�	#�D��M�M�$��"�	#�#�	V�G����
V���#�#�D�)�1��M�M�$��-��]�]�4�(�4��M�M�$��(8�(8��(>����t�AT�(T�U�	
V�	V��������O�O�	T�D��}�}�T�"�.��
�
�d�D�M�M�$�$7�%��L�@Q�:R�$R�S�	T��r
c�~�t�}|jD]#}|j||j|���%|S)z2Return new StatsObj object with same stats as self)rr'r3r0r�s   r�get_statsobj_copyzStatsObj.get_statsobj_copyss8���J���O�O�	2�D�
�J�J�t�T�]�]�4�0�1�	2��r
N)r5) r	r
r�__doc__�re�compilerAr<�stat_misc_attrs�stat_time_attrsr'rsr|r,r0r3r6rJr]rcr_r`rarnr�r�r�r�r�r�r�r�rr
rrr's���J��"�*�*�S�/�K��O�?�O�=�O���0�?�B�_�T�J��O���'�
(�$�!�
�,�,j�!�6<� �4�2BC�H@��:����(r
rc�@�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�StatsDeltaProcessz0Keep track of statistics during DirDelta processc���tj|�tjD]}d|j|<�d|_tj
�|_g|_y)z4StatsDeltaProcess initializer - zero file attributesrN)rr,r<r(rr�r�
files_changedr)s  rr,zStatsDeltaProcess.__init__~sO�����$���,�,�	$�D�"#�D�M�M�$��	$������������r
c���|j�}|xjdz
c_|xjdz
c_|xj|z
c_|xjdz
c_|j|d�y)z(Add stats of new file path to statisticsr5snewN)�getsizerrrr�add_delta_entries_file�r*r?�filesizes   r�add_new_filezStatsDeltaProcess.add_new_file�s^���<�<�>�����A����
�
���
����H�$�����Q����#�#�D�&�1r
c���|j�}|xjdz
c_|xjdz
c_|xj|z
c_|xjdz
c_|j|d�y)z4Add stats of file that has changed since last backupr5schangedN)r�rrrrr�r�s   r�add_changed_filez"StatsDeltaProcess.add_changed_file�sa���<�<�>�����A������Q�������(�����Q����#�#�D�*�5r
c�|�|xjdz
c_|xjdz
c_|j|d�y)z/Add stats of file no longer in source directoryr5sdeletedN)rrr�)r*r?s  r�add_deleted_filez"StatsDeltaProcess.add_deleted_file�s4�����Q������Q����#�#�D�*�5r
c�x�|j�}|xjdz
c_|xj|z
c_y)z7Add stats of file that hasn't changed since last backupr5N)r�rrr�s   r�add_unchanged_filez$StatsDeltaProcess.add_unchanged_file�s/���<�<�>�����A������x�'�r
c�6�tj�|_y)z#End collection of data, set EndTimeN)r�rrbs rr�zStatsDeltaProcess.close�s���y�y�{��r
c��tjr=|j�r,|jj|j	�|f�yyy�N)rr��isregrh�get_relative_path)r*r?�action_types   rr�z(StatsDeltaProcess.add_delta_entries_file�s=�����D�J�J�L����%�%�t�'=�'=�'?��&M�N�%1�r
c��|jSr�)r�rbs r�get_delta_entries_filez(StatsDeltaProcess.get_delta_entries_file�s���!�!�!r
N)r	r
rr�r,r�r�r�r�r�r�r�rr
rr�r�{s.��:� �2�6�6�(�#�O�"r
r�)r�r�r>r�r��	duplicityrrrrr�r�objectrr�rr
r�<module>r�sI��,-��	�	������	�Y�	�Q�v�Q�h
5"��5"r

Zerion Mini Shell 1.0