
     h                     `    d dl mZmZmZmZmZmZ d dlmZm	Z	 erd dl
mZ  G d d          ZdS )    )TYPE_CHECKINGAnyDictOptionalTupleUnion)
RedisErrorResponseError)ClusterNodec                       e Zd ZdZdZddZdded         ddfdZd	edee	e
d
f                  fdZd	edee	e
d
f                  fdZdS )CommandsParsera%  
    Parses Redis commands to get command keys.

    COMMAND output is used to determine key locations.
    Commands that do not have a predefined key location are flagged with 'movablekeys',
    and these commands' keys are determined by the command 'COMMAND GETKEYS'.

    NOTE: Due to a bug in redis<7.0, this does not work properly
    for EVAL or EVALSHA when the `numkeys` arg is 0.
     - issue: https://github.com/redis/redis/issues/9493
     - fix: https://github.com/redis/redis/pull/9733

    So, don't use this with EVAL or EVALSHA.
    )commandsnodereturnNc                     i | _         d S N)r   )selfs    P/var/www/html/Sam_Eipo/venv/lib/python3.11/site-packages/redis/asyncio/parser.py__init__zCommandsParser.__init__   s    ?A    r   r   c                 l  K   |r|| _         | j                             d           d {V }|                                D ]P\  }}d|d         v rd||<   |d         dk    r|d         dk    rd||<   3|d         dk    r|d         dk    rd||<   Qd	 |                                D             | _        d S )
NCOMMANDmovablekeysflagsfirst_key_posr   last_key_pos   c                 >    i | ]\  }}|                                 |S  )upper).0cmdcommands      r   
<dictcomp>z-CommandsParser.initialize.<locals>.<dictcomp>*   s&    SSS,#wgSSSr   )r   execute_commanditemsr   )r   r   r   r#   r$   s        r   
initializezCommandsParser.initialize   s       	DI229========$NN,, 	" 	"LC 000 ")Q..7>3Ja3O3O !)Q..7>3Ja3O3O !SS(..BRBRSSSr   args.c                 v  K   t          |          dk     rd S 	 | j        |d                  }n# t          $ r |d                                         t	          |dd                    z   }|d                                         }|| j        vr5|                                  d {V  || j        vrt          | d          | j        |         }Y nw xY w|dk    r	|d         fS |dk    rd S |dk    r | j        |  d {V S |d         }|dk     rt          |          |z   }||d         |dz   |d                  S )	N   r   r   z( command doesn't exist in Redis commandsr   r   r   
step_count)	lenr   KeyErrorsplitlistr!   r(   r	   _get_moveable_keys)r   r)   r$   cmd_namer   s        r   get_keyszCommandsParser.get_keys/   s     t99q==4	.mDG,GG 	. 	. 	. 7==??T$qrr(^^3DAw}}Ht},, oo'''''''''4=00$#MMM   mH-GGG	.  a<<G:a<<4b==00$77777777~.!t99|3LGO,|a/?',BWWXXs   - B!CCc                    K   	  | j         j        dg|R   d {V }n6# t          $ r)}|                                }d|v sd|v rY d }~d S |d }~ww xY w|S )NzCOMMAND GETKEYSzInvalid argumentsz The command has no key arguments)r   r&   r
   __str__)r   r)   keysemessages        r   r1   z!CommandsParser._get_moveable_keysR   s      
	223DLtLLLLLLLLLDD 	 	 	iikkG#w..5@@ttttt	 s    
AA
AA)r   Nr   )__name__
__module____qualname____doc__	__slots__r   r   r(   r   r   strr3   r1   r    r   r   r   r   	   s          %IB B B BT TXm%< T T T T T"!YC !YHU38_,E !Y !Y !Y !YFc huS#X6O      r   r   N)typingr   r   r   r   r   r   redis.exceptionsr	   r
   redis.asyncio.clusterr   r   r    r   r   <module>rB      s    C C C C C C C C C C C C C C C C 6 6 6 6 6 6 6 6 2111111U U U U U U U U U Ur   