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/testsuite/__pycache__/chunker_pytest.cpython-39.opt-1.pyc
a

HZ�h.�@s8ddlmZddlZddlZddlZddlmZddlmZmZm	Z	m
Z
ddlTdZdeded	fdeded
fdeded	fded
ed
fgZ
deded
fdeded	fdeded
fded
ed	fgZdeded	fgZdeded
fgZd"dd�Zd#dd�Zdd�Zejje�dd�ej�dde
fdefdefdefg�dd���Zejje�dd�ej�dde
dd
fde
dd	fde
ed
fde
ed	fdedd
fdedd	fdeed
fdeed	fdedd
fdedd	fdeed
fdeed	fdedd
fdedd	fdeed
fdeed	fg�dd���Zd d!�ZdS)$�)�BytesION�)�cf�)�Chunker�ChunkerFixed�	sparsemap�
has_seek_hole)�*�TF���cCs�t|d��r}d}|r*|�d|�||7}|D]4\}}}|rL|�d|�n|�|tj�||7}q.|�|�Wd�n1s�0YdS)N�wbr�H�X)�open�write�seek�os�SEEK_CUR�truncate)�fnamer�header_size�fd�total�offset�size�is_data�r�C/usr/lib64/python3.9/site-packages/borg/testsuite/chunker_pytest.py�make_sparsefile%s
(r!cCs\g}d}|r"|�d|�||7}|D]0\}}}|rD|�d|�n
|�|�||7}q&|S)Nrrr)�append)rr�resultrrrrrrr �make_content5s

r$c
Cs�tsdSt����}tj�|d�}t|dtdfttdfg�t|d��^}z |�	dtj
�}|�	dtj�}Wn,ty�YWd�Wd�dS0Wd�n1s�0Y|dko�|tkWd�S1s�0YdS)NFZtest_sparserT�rb)
r	�tempfileZTemporaryDirectoryr�path�joinr!�BSrr�	SEEK_HOLE�	SEEK_DATA�OSError)�tmpdir�fn�fZoffset_holeZoffset_datarrr �fs_supports_sparseDs
>r0z fs does not support sparse files)�reasonzfname, sparse_mapZsparse1Zsparse2Z
onlysparseZ	notsparsecCs*dd�}dd�}t||�}t||�dS)Nc	Ss<tj|tjd�}ztt|d��Wt�|�St�|�0dS)N)�flags)�fh)rr�O_RDONLY�listr�close)rr3rrr �get_sparsemap_fh]s
�z(test_sparsemap.<locals>.get_sparsemap_fhcSs<t|d��}tt|d��Wd�S1s.0YdS)Nr%)r)rr5r)rrrrr �get_sparsemap_fddsz(test_sparsemap.<locals>.get_sparsemap_fd)�strr!)r-r�
sparse_mapr7r8r.rrr �test_sparsemapTs
	
r;z&fname, sparse_map, header_size, sparsecCs@dd�}t||�}t|||d�||||d�t||d�kdS)NcSsJtd||d�}t|d��}t|�|��Wd�S1s<0YdS)Nr)r�sparser%)rrr�chunkify)rr<r�chunkerrrrr �
get_chunks�sz(test_chunkify_sparse.<locals>.get_chunks)r)r<r)r9r!r$)r-rr:rr<r?r.rrr �test_chunkify_sparsensr@cs�t�d�}d\��}td��|d�}t|�}t|�|��}|d=dd�|D�}t|�}t|�}t|�}t	�fdd	�|D��}	t	�fd
d	�|D��}
t
d|�d|�d
|�d|	�d|
��
�dS)Ni)�
��ri����cSsg|]}t|��qSr)�len)�.0�chunkrrr �
<listcomp>��z7test_buzhash_chunksize_distribution.<locals>.<listcomp>c3s|]}t|d�k�VqdS�rN��int�rFr)�min_exprr �	<genexpr>�rIz6test_buzhash_chunksize_distribution.<locals>.<genexpr>c3s|]}t|d�k�VqdSrJrKrM)�max_exprr rO�rIzcount: z min: z max: z min count: z max count: )r�urandomrrrr=rE�min�max�sum�print)�data�maskr>r/�chunksZchunk_sizesZchunks_countZmin_chunksize_observedZmax_chunksize_observedZ	min_countZ	max_countr)rPrNr �#test_buzhash_chunksize_distribution�s$

��	rY)r)r)�iorrr&Zpytestr>rrrrr	Z	constantsr)Zmap_sparse1Zmap_sparse2Z
map_notsparseZmap_onlysparser!r$r0ZmarkZskipifZparametrizer;r@rYrrrr �<module>sf�	�

�















�