a
    W_T                     @   s   d Z ddlmZ ddlmZmZmZmZ ddlmZ	mZ
mZ dZdZdZeZeeegZeeee	iZeeee
iZeZeefee
ffZd	d
 Zdd Zdd ZdS )a2  Consts and function to handle target format.
ALL_SUPPORTED_FORMATS - list of supported formats
get_decompress_function - returns stream decompress function for a current
    format (specified or autodetected)
get_compress_function - returns compress function for a current format
    (specifed or default)
    )absolute_import   )stream_compressstream_decompresscheck_formatUncompressError)r   r   r   Zframinghadoop_snappyautoc                 C   s>   d}t D ](\}}|| |d\}}|s&q||f  S tddS )zTries to guess a compression format for the given input file by it's
    header.
    :return: tuple of decompression method and a chunk that was taken from the
        input for format detection.
    N)finchunkzCan't detect archive format)_DECOMPRESS_FORMAT_FUNCSr   )r
   r   Zcheck_methoddecompress_funcok r   4lib/python3.9/site-packages/snappy/snappy_formats.pyguess_format_by_header<   s    r   c                 C   s(   | t krt|\}}||fS t|  d fS N)FORMAT_AUTOr   _DECOMPRESS_METHODS)specified_formatr
   r   Z
read_chunkr   r   r   get_decompress_functionK   s    r   c                 C   s   | t krtt S t|  S r   )r   _COMPRESS_METHODS_DEFAULT_COMPRESS_FORMAT)r   r   r   r   get_compress_functionR   s    r   N)__doc__Z
__future__r   Zsnappyr   r   r   r   r   Zhadoop_stream_compressZhadoop_stream_decompressZhadoop_check_formatZFRAMING_FORMATZHADOOP_FORMATr   ZDEFAULT_FORMATZALL_SUPPORTED_FORMATSr   r   r   r   r   r   r   r   r   r   r   <module>   s*   

