o
    Š¨ÊhÆ  ã                   @   s   d dl mZ G dd„ dƒZdS )é   )Ú	DataErrorc                   @   s.   e Zd ZdZdZdd„ Zdd„ Zddd	„Zd
S )ÚEncoderz=Encode strings to bytes-like and decode bytes-like to strings©ÚencodingÚencoding_errorsÚdecode_responsesc                 C   s   || _ || _|| _d S )Nr   )Úselfr   r   r   © r	   úI/var/www/html/env/lib/python3.10/site-packages/redis/_parsers/encoders.pyÚ__init__	   s   
zEncoder.__init__c                 C   s‚   t |ttfƒr	|S t |tƒrtdƒ‚t |ttfƒr t|ƒ ¡ }nt |t	ƒs2t
|ƒj}td|› d�ƒ‚t |t	ƒr?| | j| j¡}|S )z=Return a bytestring or bytes-like representation of the valuezNInvalid input of type: 'bool'. Convert to a bytes, string, int or float first.zInvalid input of type: 'z2'. Convert to a bytes, string, int or float first.)Ú
isinstanceÚbytesÚ
memoryviewÚboolr   ÚintÚfloatÚreprÚencodeÚstrÚtypeÚ__name__r   r   )r   ÚvalueÚtypenamer	   r	   r
   r      s    
ÿ


ÿ
zEncoder.encodeFc                 C   s:   | j s|rt|tƒr| ¡ }t|tƒr| | j| j¡}|S )z:Return a unicode string from the bytes-like representation)r   r   r   Útobytesr   Údecoder   r   )r   r   Úforcer	   r	   r
   r   %   s   


zEncoder.decodeN)F)r   Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r   r	   r	   r	   r
   r      s    r   N)Ú
exceptionsr   r   r	   r	   r	   r
   Ú<module>   s    