a
    f’id  ã                   @   sT   zd dl mZ W n ey*   d dlZY n0 d dlZddlmZ G dd„ deƒZdS )é    )ÚigzipNé   )ÚTLObjectc                   @   sL   e Zd ZdZdd„ Zedd„ ƒZdd„ Zedd	„ ƒZe	d
d„ ƒZ
dd„ ZdS )Ú
GzipPackedi¡Ïr0c                 C   s
   || _ d S ©N©Údata)Úselfr   © r
   úP/home/ec2-user/.local/lib/python3.9/site-packages/telethon/tl/core/gzippacked.pyÚ__init__   s    zGzipPacked.__init__c                 C   s<   | r4t |ƒdkr4tt|ƒƒ}t |ƒt |ƒk r0|S |S |S dS )a  Calls bytes(request), and based on a certain threshold,
           optionally gzips the resulting data. If the gzipped data is
           smaller than the original byte array, this is returned instead.

           Note that this only applies to content related requests.
        i   N)ÚlenÚbytesr   )Zcontent_relatedr   Zgzippedr
   r
   r   Úgzip_if_smaller   s    zGzipPacked.gzip_if_smallerc                 C   s    t  dtj¡t t | j¡¡ S )Nz<I)	ÚstructÚpackr   ÚCONSTRUCTOR_IDr   Zserialize_bytesÚgzipÚcompressr   ©r	   r
   r
   r   Ú	__bytes__   s    ÿzGzipPacked.__bytes__c                 C   s(   | j dd}|tjksJ ‚t |  ¡ ¡S )NF)Úsigned)Zread_intr   r   r   Ú
decompressÚtgread_bytes)ÚreaderÚconstructorr
   r
   r   Úread"   s    zGzipPacked.readc                 C   s   t t | ¡ ¡ƒS r   )r   r   r   r   )Úclsr   r
   r
   r   Úfrom_reader(   s    zGzipPacked.from_readerc                 C   s   d| j dœS )Nr   )Ú_r   r   r   r
   r
   r   Úto_dict,   s    þzGzipPacked.to_dictN)Ú__name__Ú
__module__Ú__qualname__r   r   Ústaticmethodr   r   r   Úclassmethodr   r    r
   r
   r
   r   r   
   s   


r   )Zisalr   r   ÚImportErrorr   Ú r   r   r
   r
   r
   r   Ú<module>   s   