HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/gzip_util.cpython-310.pyc
o

�N�gn�@sbdZddlZddlZddlZGdd�dej�Zddd�Zdd	d
�Zddd�Zd
d�Z	ddd�Z
dS)zp
    salt.utils.gzip
    ~~~~~~~~~~~~~~~
    Helper module for handling gzip consistently between 2.7+ and 2.6-
�Nc@s&eZdZd	dd�Zdd�Zdd�ZdS)
�GzipFileN�	cCstj�|||||�dS)N)�gzipr�__init__)�self�filename�mode�
compresslevel�fileobj�r�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/gzip_util.pyrszGzipFile.__init__cCs|S)z+Context management protocol.  Returns self.r)rrrr�	__enter__szGzipFile.__enter__cGs|��dS)z+Context management protocol.  Calls close()N)�close)r�argsrrr�__exit__szGzipFile.__exit__)NNrN)�__name__�
__module__�__qualname__rr
rrrrrr
s
r�rbrcCs&ttjd�r
t�|||�St|||�S)Nr
)�hasattrrr�open)rrr	rrrrsrcCs.ttjd�rtjd|||d�Std|||d�S)Nr
�)rrr
r	)rrr)r
rr	rrr�open_fileobj"s��rcCs^t��}t|d|��}t|t�s|�t�}|�|�Wd�n1s$wY|��}|S)z@
    Returns the data compressed at gzip level compression.
    �wbN)	�io�BytesIOr�
isinstance�bytes�encodeZ__salt_system_encoding__�write�getvalue)�datar	�buf�ogz�
compressedrrr�compress,s

�r%cCsDt�|�}t|d��}|��}|Wd�S1swYdS)Nr)rrr�read)r!r"ZigzZuncrrr�
uncompress9s

$�r'�ccs�zt|�}||krt�Wntytd��wz^||kret��}t|d|��,}z
|�|�|��}WntyLtj	j
�|d�}|�|�|��}YnwWd�n1sWwY|��V||ksWz|�
�WdStywYdSwz|�
�Wwty�Yww)a�
    Generator that reads chunk_size bytes at a time from a file/filehandle and
    yields the compressed result of each read.

    .. note::
        Each chunk is compressed separately. They cannot be stitched together
        to form a compressed file. This function is designed to break up a file
        into compressed chunks for transport and decompression/reassembly on a
        remote host.
    zchunk_size must be an integerrrN)�int�
ValueErrorrrrrr&�AttributeError�salt�utils�filesZfopenr r)Zfh_r	Z
chunk_sizeZ
bytes_readr"r#rrr�
compress_file@sD������
�����r/)rr)r)rr()�__doc__rrZsalt.utils.filesr,rrrr%r'r/rrrr�<module>s