
    h                        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                  j                  d       Z ee
d      Z	 d dlZdZ	 d dlZdZd d	lm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#y# e$ r dZdZY aw xY w# e$ r dZY gw xY w# e$ r dZY mw xY w)    N)contextmanagerwraps)AnyDictMappingUnionz0.pack_commandFT)metadatac                 4    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      V/var/www/html/retail-simulation-api/retail/lib/python3.12/site-packages/redis/utils.pyr   r   !   s     #5>>#(((    c              #   T   K   | j                         }| |j                          y wN)pipelineexecute)	redis_objps     r   r   r   -   s"     A
GIIKs   &(valuereturnc                 L    t        | t              r| j                  dd      S | S )Nzutf-8replace)errors)
isinstancebytesdecoder   s    r   str_if_bytesr#   4   s(    3=eU3KWY/QVr   c                 *    t        t        |             S r   )strr#   r"   s    r   safe_strr&   :   s    |E"##r   dictsc                  :    i }| D ]  }|j                  |        |S )za
    Merge all provided dicts into 1 dict.
    *dicts : `dict`
        dictionaries to merge
    )update)r'   mergedds      r   
dict_merger,   >   s&     Fa  Mr   c                 .    t         j                  | |      S r   )dictfromkeys)key_listcallbacks     r   list_keys_to_dictr2   L   s    ==8,,r   c                     t               }|j                         D ]  }|D ]  }|j                  |         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<   P   s=     UFZZ\EJJu   <r   c                 t    dd l }d|  d}|r	|d| dz  }|r	|d| dz  }|j                  |t        |       y )Nr   zCall to deprecated .z ()z -- Deprecated since version )category
stacklevel)warningswarnDeprecationWarning)namereasonversionrA   rB   msgs         r   warn_deprecatedrI   b   sR    vQ
'CF81~.wiq99MM# 2zMJr   c                       fd}|S )z5
    Decorator to mark a function as deprecated.
    c                 6     t                fd       }|S )Nc                  N    t        xs j                  d        | i |S )N   )rA   )rI   __name__)argsr   funcrE   rF   rG   s     r   wrapperz7deprecated_function.<locals>.decorator.<locals>.wrappers   s*    D1DMM67qQ(((r   r   )rP   rQ   rE   rF   rG   s   ` r   	decoratorz&deprecated_function.<locals>.decoratorr   s     	t	) 
	) r    )rF   rG   rE   rR   s   ``` r   deprecated_functionrT   m   s    
 r   c                  ^   dt         j                  j                  j                  j	                         vryt        j
                  d      } | j                  t         j                         t        j                         }|j                  t         j                         | j                  |       yy)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_loggerrc   }   sy    
 gll22==BBDD""?3%'')&'" Er   c                  j    	 t        j                  d      } | S # t         j                  $ r d} Y | S w xY w)Nredisz99.99.99)r   rG   PackageNotFoundError)libvers    r   get_lib_versionrh      s?    !!'* M (( Ms    22) ri      )ri   ri   N)$rW   
contextlibr   	functoolsr   typingr   r   r   r	   hiredis__version__
startswithHIREDIS_AVAILABLEhasattrHIREDIS_PACK_AVAILABLEImportErrorsslSSL_AVAILABLEcryptographyCRYPTOGRAPHY_AVAILABLE	importlibr   r   r   r%   r    r#   r&   r,   r2   r<   rI   rT   rc   rh   rS   r   r   <module>rz      s+    %  , ,# $//::4@@$Wn=
M#! 	)  c5j) c $wsCx( T#s(^ -$K 
#}  #"#  M  #"#s5   )B B, B9 	B)(B),B65B69CC