
    Pf                        d dl Z d dlZd dlmZ d dlmZ d dlmZmZm	Z	m
Z
 	 d dlZej                            d           Z eed          Zn# e$ r dZdZY nw xY w	 d dlZdZn# e$ r dZY nw xY w	 d dlZdZn# e$ r dZY nw xY wej        d	k    rd d
lmZ nd dlZd Zed             Zde
eef         defdZd Zde	eef         deeef         fdZ d Z!d Z"ddZ#ddZ$d Z%d Z&dede'defdZ(dS )     N)contextmanagerwraps)AnyDictMappingUnionz0.pack_commandFT)      )metadatac                 *    ddl m}  |j        | fi |S )z
    Returns an active Redis client generated from the given database URL.

    Will attempt to extract the database id from the path url fragment, if
    none is provided.
    r   )Redis)redis.clientr   from_url)urlkwargsr   s      =/var/www/html/env/lib/python3.11/site-packages/redis/utils.pyr   r   %   s0     #"""""5>#(((((    c              #   b   K   |                                  }|V  |                                 d S N)pipelineexecute)	redis_objps     r   r   r   1   s1      A
GGGIIKKKKKr   valuereturnc                 ^    t          | t                    r|                     dd          n| S )Nzutf-8replace)errors)
isinstancebytesdecoder   s    r   str_if_bytesr%   8   s/    3=eU3K3KVWY///QVr   c                 :    t          t          |                     S r   )strr%   r$   s    r   safe_strr(   >   s    |E""###r   dictsc                  >    i }| D ]}|                     |           |S )za
    Merge all provided dicts into 1 dict.
    *dicts : `dict`
        dictionaries to merge
    )update)r)   mergedds      r   
dict_merger.   B   s2     F  aMr   c                 8    t                               | |          S r   )dictfromkeys)key_listcallbacks     r   list_keys_to_dictr4   P   s    ==8,,,r   c                     t                      }|                                D ]}|D ]}|                    |           t          |          S )z
    Merge all items in `res` into a list.

    This command is used when sending a command to multiple nodes
    and the result from each node should be merged into a single list.

    res : 'dict'
    )setvaluesaddlist)commandresresultvr   s        r   merge_resultr>   T   s[     UUFZZ\\   	 	EJJu	 <<r       c                     dd l }d|  d}|r	|d| dz  }|r	|d| dz  }|                    |t          |           d S )Nr   zCall to deprecated .z ()z -- Deprecated since version )category
stacklevel)warningswarnDeprecationWarning)namereasonversionrE   rF   msgs         r   warn_deprecatedrM   f   sr    OOO
'
'
'
'C ~F~~~ :9w9999MM# 2zMJJJJJr   c                       fd}|S )z5
    Decorator to mark a function as deprecated.
    c                 D     t                      fd            }|S )Nc                  H    t          pj        d            | i |S )Nr   )rE   )rM   __name__)argsr   funcrI   rJ   rK   s     r   wrapperz7deprecated_function.<locals>.decorator.<locals>.wrapperw   s6    D1DM67qQQQQ4((((r   r   )rS   rT   rI   rJ   rK   s   ` r   	decoratorz&deprecated_function.<locals>.decoratorv   sC    	t	) 	) 	) 	) 	) 	) 	) 
	) r    )rJ   rK   rI   rU   s   ``` r   deprecated_functionrW   q   s0    
       r   c                  R   dt           j        j        j                                        vr|t          j        d          } |                     t           j                   t          j                    }|                    t           j                   | 	                    |           dS dS )zo
    Set up a logger that log info logs to stdout.
    (This is used by the default push response handler)
    push_responseN)
loggingrootmanager
loggerDictkeys	getLoggersetLevelINFOStreamHandler
addHandler)loggerhandlers     r   _set_info_loggerrf      s    
 gl2=BBDDDD"?33%%%'))&&&'""""" EDr   c                  `    	 t          j        d          } n# t           j        $ r d} Y nw xY w| S )Nredisz99.99.99)r   rK   PackageNotFoundError)libvers    r   get_lib_versionrk      sE    !'**(   Ms    ++
host_error	exceptionc                     |j         sd|  dS t          |j                   dk    rd|j         d          d|  dS d|j         d          d|  d|j         d          dS )NzError connecting to rB      zError r   z connecting to z. )rR   len)rl   rm   s     r   format_error_messagerq      s    > 
3j3333	Y^			!	!G	q)GG*GGGG$Y^A& $ $z $ $~a $ $ $	
r   )r?   r?   r@   )r?   r?   N))rZ   sys
contextlibr   	functoolsr   typingr   r   r   r	   hiredis__version__
startswithHIREDIS_AVAILABLEhasattrHIREDIS_PACK_AVAILABLEImportErrorsslSSL_AVAILABLEcryptographyCRYPTOGRAPHY_AVAILABLEversion_info	importlibr   importlib_metadatar   r   r'   r"   r%   r(   r.   r4   r>   rM   rW   rf   rk   BaseExceptionrq   rV   r   r   <module>r      s    



 % % % % % %       , , , , , , , , , , , ,#NNN $/::4@@@$WWn== # # #"#JJJMM   MMM#! # # #"# v"""""""))))	) 	) 	)   c5j) c    $ $ $wsCx( T#s(^    - - -  $K K K K    
# 
# 
#  	
S 	
] 	
s 	
 	
 	
 	
 	
 	
s5   +A 	AAA% %A/.A/3A: :BB