U
    ccv                     @   s   d dl mZ d dlmZmZmZmZ zd dlZdZW n e	k
rL   dZY nX zd dl
Z
dZW n e	k
rv   dZY nX dd Zedd	 Zeeef ed
ddZdd Zeeef eeef dddZdd Zdd ZdS )    )contextmanager)AnyDictMappingUnionNTFc                 K   s   ddl m} |j| f|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)Zredis.clientr   from_url)urlkwargsr    r   E/var/www/html/project/venv/lib/python3.8/site-packages/redis/utils.pyr      s    r   c                 c   s   |   }|V  |  d S N)pipelineexecute)Z	redis_objpr   r   r   r      s    r   )valuereturnc                 C   s   t | tr| jdddS | S )Nzutf-8replace)errors)
isinstancebytesdecoder   r   r   r   str_if_bytes&   s    r   c                 C   s   t t| S r   )strr   r   r   r   r   safe_str,   s    r   )dictsr   c                  G   s   i }| D ]}| | q|S )za
    Merge all provided dicts into 1 dict.
    *dicts : `dict`
        dictionaries to merge
    )update)r   mergeddr   r   r   
dict_merge0   s    r    c                 C   s   t | |S r   )dictfromkeys)Zkey_listcallbackr   r   r   list_keys_to_dict>   s    r$   c                 C   s0   t  }| D ]}|D ]}|| qq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   r   r   r   merge_resultB   s
    	r-   )
contextlibr   typingr   r   r   r   ZhiredisZHIREDIS_AVAILABLEImportErrorZcryptographyZCRYPTOGRAPHY_AVAILABLEr   r   r   r   r   r   r    r$   r-   r   r   r   r   <module>   s&   


 