o
    >h                     @   s   d dl Z d dlZd dlZd dlmZmZ d dlZd dlmZm	Z	 dedee	df dee	 fdd	Z
d
d Zdd Zdd Zdd ZdddZdd Zdd ZdS )    N)ListTuple)KeysTKeyTkeysargs.returnc                 C   sV   zt |  t| ttfr| g} nt| } W n ty!   | g} Y nw |r)| | | S N)iter
isinstancebytesstrlist	TypeErrorextend)r   r    r   v/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/redis/commands/helpers.pylist_or_args
   s   

r   c                 C   s*   t | tr| ddn| }|dkrdS |S )zAReturn the decoded binary string, or a string, depending on type.utf-8replacenullN)r   r   decode)xrr   r   r   	nativestr   s   r   c                 C   s   | du r| S dd | D S )z9Given a list of binaries, return the stringified version.Nc                 S   s   g | ]}t |qS r   )r   ).0objr   r   r   
<listcomp>'   s    zdelist.<locals>.<listcomp>r   )r   r   r   r   delist#   s   r   c                 C   s   g }h d}| du r|S | D ]\}|du r| d qzt|}W n ty.   | d Y qw t|tr@| |v r@| | qz	| t| W q tyj   z	| t| W n tyg   | | Y nw Y qw |S )z,Optimistically parse the response to a list.>   	-infinitynaninfinityN)	appendr   r   r   r   lowerint
ValueErrorfloat)responseresspecial_valuesitemitem_strr   r   r   parse_to_list*   s6   

r,   c              
   C   s   i }t dt| dD ]n}t| | tr@|d t| |  zt| |d  tr5|d t| |d   W q
 ty?   Y q
w t| |d  trUt| |d  g|d< q
zt| |d  || | < W q
 tt	fyx   | |d  || | < Y q
w |S )Nr      zChild iterators   )
rangelenr   r   r"   parse_list_to_dict
IndexErrorr&   r   r%   )r'   r(   ir   r   r   r1   K   s&   r1   
   c                 C   s   d dd t| D S )z3
    Returns a random N character long string.
     c                 s   s    | ]	}t tjV  qd S r	   )randomchoicestringascii_lowercase)r   r   r   r   r   	<genexpr>c   s    
z random_string.<locals>.<genexpr>)joinr/   )lengthr   r   r   random_string_   s   
r=   c                 C   sB   t  | }|  D ]}t|tr|| ||d< || q	|S )z3Decode the keys of the given dictionary with utf-8.r   )copyr   r   r   r   pop)r   newobjkr   r   r   decode_dict_keysh   s   


rB   c                 C   sH   t | tjst | tjjr| jjdS t | tjjr"| j	jdS d S )Nprotocol)
r   redisRedisasyncioconnection_poolconnection_kwargsgetclusterAbstractRedisClusternodes_manager)clientr   r   r   get_protocol_versionr   s
   rN   )r4   )r>   r6   r8   typingr   r   rD   redis.typingr   r   r   r   r   r,   r1   r=   rB   rN   r   r   r   r   <module>   s    "!
	
