Yohohohohohooho | Sanrei Aya
Sanrei Aya


Server : LiteSpeed
System : Linux barito.iixcp.rumahweb.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : elvh3918 ( 1528)
PHP Version : 8.2.31
Disable Function : mail
Directory :  /lib/python3.9/site-packages/redis/commands/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3.9/site-packages/redis/commands/__pycache__/parser.cpython-39.opt-1.pyc
a

��bw�@s.ddlmZmZddlmZGdd�d�ZdS)�)�
RedisError�
ResponseError��str_if_bytesc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�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'.
    cCsi|_|�|�dS�N)�commands�
initialize)�selfZredis_connection�r�9/usr/lib/python3.9/site-packages/redis/commands/parser.py�__init__szCommandsParser.__init__cCsZ|�d�}g}|D] }tdd�|D��r|�|�q|D]}|�|�||��<q8||_dS)NZCOMMANDcss|]}|��VqdSr)�isupper)�.0�xrrr�	<genexpr>�z,CommandsParser.initialize.<locals>.<genexpr>)�execute_command�any�append�pop�lowerr)r
�rrZuppercase_commands�cmdrrrr	s
zCommandsParser.initializecKs�i}t|d�}||d<t|d�|d<dd�|dD�|d<|d	|d
<|d|d<|d
|d<t|�dkr�|d|d<|d|d<|d|d<|S)Nr�name�ZaritycSsg|]}t|��qSrr)r�flagrrr�
<listcomp>!rz3CommandsParser.parse_subcommand.<locals>.<listcomp>��flags��
first_key_pos��last_key_pos��
step_count�Ztips�Zkey_specifications�	�subcommands)r�int�len)r
�command�optionsZcmd_dict�cmd_namerrr�parse_subcommandszCommandsParser.parse_subcommandcs�t��dkrdS�d��}||jvr||��}|d}||jvrV|t�dd���n&|�|�||jvr|t|���d���|j�|�}d|dvr�|j	|g��R�}n�d|dvs�|d	dkr�|j
��}n�|d
dk�rT|ddk�rT|ddk�rTd
}d|v�rJ|�d�d����}|dD]&}	t|	d�|k�r"|�|	�}d}�q"|�sTdS|d}
|
dk�rvt��t
|
�}
tt|d|
d|d
��}�fdd�|D�}|S)ap
        Get the keys from the passed command.

        NOTE: Due to a bug in redis<7.0, this function 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 function with EVAL or EVALSHA.
        rNrrz( command doesn't exist in Redis commandsZmovablekeysrZpubsubrr%r!r#Fr)�|Tcsg|]}�|�qSrr)r�pos��argsrrrkrz+CommandsParser.get_keys.<locals>.<listcomp>)r+rr�split�listr	r�upper�get�_get_moveable_keys�_get_pubsub_keysrr/�abs�range)r
�
redis_connr3r.Zcmd_name_splitr,�keysZ	is_subcmdZsubcmd_nameZsubcmdr#Zkeys_posrr2r�get_keys.sR



�
�
�
�


�zCommandsParser.get_keysc
Gs�g}|d}||��}|t|dd��}z|jdg|�R�}WnNty�}z6|��}d|vsjd|vrxWYd}~dS|�WYd}~n
d}~00|S)aA
        NOTE: Due to a bug in redis<7.0, this function 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 function with EVAL or EVALSHA.
        rrNzCOMMAND GETKEYSzInvalid argumentsz The command has no key arguments)r4r5rr�__str__)r
r<r3�piecesr.r=�e�messagerrrr8os	��z!CommandsParser._get_moveable_keyscGs�t|�dkrdSdd�|D�}|d��}d}|dkrX|d��}|dvr�|dd�}n,|d	vrrt|dd��}n|d
kr�|dg}|S)z�
        Get the keys from pubsub command.
        Although PubSub commands have predetermined key locations, they are not
        supported in the 'COMMAND's output, so the key positions are hardcoded
        in this method
        rNcSsg|]}t|��qSrr)r�argrrrr�rz3CommandsParser._get_pubsub_keys.<locals>.<listcomp>rZPUBSUBr)ZCHANNELSZNUMSUB)Z	SUBSCRIBEZ
PSUBSCRIBEZUNSUBSCRIBEZPUNSUBSCRIBEZPUBLISH)r+r6r5)r
r3r,r=Zpubsub_typerrrr9�s
zCommandsParser._get_pubsub_keysN)
�__name__�
__module__�__qualname__�__doc__r
r	r/r>r8r9rrrrrs
ArN)Zredis.exceptionsrrZredis.utilsrrrrrr�<module>s

Yohohohohohooho | Sanrei Aya