
    cL                         d dl mZ ddlmZmZ 	 e n# e$ r eZY nw xY w G d de          Z	 G d de          Z
d Zd	 Zd
 Zd ZeZd ZdS )    )absolute_import   )ffilibc                       e Zd ZdS )UncompressErrorN__name__
__module____qualname__     2lib/python3.11/site-packages/snappy/snappy_cffi.pyr   r              Dr   r   c                       e Zd ZdS )SnappyBufferSmallErrorNr	   r   r   r   r   r      r   r   r   c                 ~    d }d }t          j        |           }t          j        dt          |                     }||fS )Nsize_t)r   from_buffercastlen)data	_out_data	_out_sizes      r   preparer      s=    II%%I3t99--Iy!!r   c                    t          | t                    r|                     d          } t          |           \  }}t	          j        |          }t          j        d|          }t          j        d|          }t	          j        ||||          }|t          j	        k    rt                      t          j        t          j        d|          |d                   }|d d          S )Nutf-8char[]size_t*char*r   )
isinstanceunicodeencoder   r   snappy_max_compressed_lengthr   newsnappy_compress	SNAPPY_OKr   bufferr   )r   _input_data_input_sizemax_compressedr   r   rcvalues           r   compressr.      s    $   ${{7##&t}}K5kBBN.11I	>22I		[+y)	L	LB	S] '$&&&Jsx33Yq\BBE8Or   c                 .   t          |           \  }}t          j        dd          }t          j        ||          }|t          j        k    st                      t          j        |||          }|t          j        k    st                      t          j        d|d                   }t          j        ||||          }|t          j        k    rt                      t          j	        t          j
        d|          |d                   }|d d          S )Nr   r   r   r    )r   r   r%   r   !snappy_validate_compressed_bufferr'   r   snappy_uncompressed_lengthsnappy_uncompressr(   r   )r   r   r   resultr,   _uncompressed_databufs          r   
uncompressr6   2   s    "4==IyWY""F		.y)	D	DB  		'	&/&,
. 
.B   6!955		y)5G	P	PB	S]  :chw(:;;VAYGGCqqq6Mr   c                     t          | t                    r|                     d          } t          |           \  }}t	          j        ||          }|t          j        k    S )Nr   )r!   r"   r#   r   r   r0   r'   )r   r   r   r,   s       r   isValidCompressedr8   O   sT    $   ${{7##!$--Iy		.y)	D	DBr   c                     t          j        |           }t          j        dt          |                     }t	          t          j        ||                    S )Nint)r   r   r   r   r:   r   _crc32c)r   c_datasizes      r   r;   r;   [   sB    _T""F8E3t99%%Ds{64(()))r   N)
__future__r   _snappy_cffir   r   r"   	NameErrorstr	Exceptionr   r   r   r.   r6   r8   
decompressr;   r   r   r   <module>rD      s   & & & & & & " " " " " " " "GG   GGG	 	 	 	 	i 	 	 		 	 	 	 	Y 	 	 	" " "  *  :   
* * * * *s    