
    fi                     X   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e
j                            d          d                    dk    Zes ed          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	 d dlZd	Zn# e$ r dZY nw xY w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,de	e!ef         dedededef
dZ"dgg ddfd e!d!e!dedefd"Z#d# Z$d$ Z%d%ed&e&defd'Z'd(ed)edefd*Z(d+ Z)dS ).    N)contextmanagerwraps)AnyDictMappingUnion.   z"hiredis package should be >= 3.0.0FT)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/Pagina-Ingenieria-Requisitos/venv/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   -   s1      A
GGGIIKKKKKr   valuereturnc                 ^    t          | t                    r|                     dd          n| S )Nutf-8replace)errors)
isinstancebytesdecoder   s    r   str_if_bytesr%   4   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.   >   s2     F  aMr   c                 8    t                               | |          S r   )dictfromkeys)key_listcallbacks     r   list_keys_to_dictr4   L   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>   P   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 r
    () -- Deprecated since version category
stacklevelwarningswarnDeprecationWarning)namereasonversionrG   rI   msgs         r   warn_deprecatedrP   b   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   rG   )rP   __name__)argsr   funcrL   rM   rN   s     r   wrapperz7deprecated_function.<locals>.decorator.<locals>.wrappers   s6    D1DM67qQQQQ4((((r   r   )rW   rX   rL   rM   rN   s   ` r   	decoratorz&deprecated_function.<locals>.decoratorr   sC    	t	) 	) 	) 	) 	) 	) 	) 
	) r    )rM   rN   rL   rY   s   ``` r   deprecated_functionr[   m   s0    
       r   arg_namefunction_namerM   rN   rG   c                     dd l }d| d|  d}|r	|d| dz  }|r	|d| dz  }|                    |t          |	           d S )
Nr   z	Call to 'z6' function with deprecated usage of input argument/s 'z'.rB   rC   rD   r
   rE   rH   )r\   r]   rM   rN   rG   rI   rO   s          r   warn_deprecated_arg_usager_   }   s     OOO	4M 	4 	4'/	4 	4 	4   ~F~~~ :9w9999MM# 2zMJJJJJr   *args_to_warnallowed_argsc                       fd}|S )z
    Decorator to mark specified args of a function as deprecated.
    If '*' is in args_to_warn, all arguments will be marked as deprecated.
    c                 F     t                      fd            }|S )Nc                     j         j        d j         j                 }t          t	          ||                     }|                    |           |                    dd            D ]}|                    |d            D ]q}|dk    rLt          |          dk    r9t          t          |
                                          j        	
d           T||v rt          |j        	
d           r | i |S )Nselfr`   r   r   rT   )__code__co_varnamesco_argcountr0   zipr+   poplenr_   r9   keysrU   )rV   r   	arg_namesprovided_argsallowed_argargrb   ra   rW   rM   rN   s         r   rX   z3deprecated_args.<locals>.decorator.<locals>.wrapper   s<    12MDM4M2MNI Y!5!566M  (((fd++++ 5 5!!+t4444#  #::#m"4"4q"8"8-]//1122#$     M))-T]FG    4((((r   r   )rW   rX   rb   ra   rM   rN   s   ` r   rY   z"deprecated_args.<locals>.decorator   sH    	t	) 	) 	) 	) 	) 	) 	) 	) 
	)6 r   rZ   )ra   rb   rM   rN   rY   s   ```` r   deprecated_argsrr      s6           > 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
loggerDictrm   	getLoggersetLevelINFOStreamHandler
addHandler)loggerhandlers     r   _set_info_loggerr      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   rN   PackageNotFoundError)libvers    r   get_lib_versionr      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 r
      zError r   z connecting to z. )rV   rl   )r   r   s     r   format_error_messager      s    > 
3j3333	Y^			!	!G	q)GG*GGGG$Y^A& $ $z $ $~a $ $ $	
r   version1version2c                    t          t          t          |                     d                              }t          t          t          |                    d                              }t	          |          t	          |          k    rGt	          |          t	          |          z
  }t          |          D ]}|                    d           nft	          |          t	          |          k     rFt	          |          t	          |          z
  }t          |          D ]}|                    d           t          |          D ]/\  }}||         ||         k    r dS ||         ||         k     r dS 0dS )z
    Compare two versions.

    :return: -1 if version1 > version2
             0 if both versions are equal
             1 if version1 < version2
    r
   r   r   )r9   mapintsplitrl   rangeappend	enumerate)r   r   num_versions1num_versions2diff_ivers           r   compare_versionsr      sp    S(.."5"56677MS(.."5"56677M
=C....=!!C$6$66t 	$ 	$A  ####	$	]		c-00	0	0=!!C$6$66t 	$ 	$A  ####M**  3mA...221a 00011 1 1r   c                     t          | t                    r|                     d          S t          | t                    r| S t	          d          )Nr   z$Key must be either a string or bytes)r!   r"   r#   r'   	TypeError)keys    r   ensure_stringr      sN    #u @zz'"""	C		 @
>???r   )r?   r?   r@   )r?   r?   N)*ru   
contextlibr   	functoolsr   typingr   r   r   r	   hiredisr   __version__r   HIREDIS_AVAILABLEImportErrorsslSSL_AVAILABLEcryptographyCRYPTOGRAPHY_AVAILABLE	importlibr   r   r   r'   r"   r%   r(   r.   r4   r>   rP   r[   r9   r_   rr   r   r   BaseExceptionr   r   r   rZ   r   r   <module>r      s    % % % % % %       , , , , , , , , , , , ,NNN G/55c::1=>>!C @k>???@   JJJMM   MMM#! # # #"#      	) 	) 	)   c5j) c    $ $ $wsCx( T#s(^    - - -  $K K K K   & K KD#IKK K 	K
 K K K K* 	* *** * 	* * * *Z
# 
# 
#  	
S 	
] 	
s 	
 	
 	
 	
s c c    <@ @ @ @ @s5   >A A'&A'+A2 2A<;A< B BB