o
    h                     @   s@   d dl Z d dlZddlmZ dd Zdd Zdd	 Zd
d ZdS )    N   	nativestrc                    s    fdd}|S )zUReplace serialized JSON values with objects in a
    bulk array response (list).
    c                    s*   t | D ]\}}|d ur || |< q| S )N)	enumerate)bindexitemd ^/var/www/html/optinet_system/venv/lib/python3.10/site-packages/redis/commands/json/decoders.py_f   s
   zbulk_of_jsons.<locals>._fr   )r
   r   r   r	   r   bulk_of_jsons   s   r   c                 C   sB   t  | }|  D ]}t|tr|| ||d< || q	|S )z3Decode the keys of the given dictionary with utf-8.zutf-8)copykeys
isinstancebytesdecodepop)objnewobjkr   r   r   decode_dict_keys   s   


r   c                 C   sL   d}t || }|g krt|d S d}t || }|g kr$t|d S | S )z
    Attempt to parse string to native integer formats.
    One can't simply call int/float in a try/catch because there is a
    semantic difference between (for example) 15.0 and 15.
    z	^\d+.\d+$r   z^\d+$)refindallfloatint)r   floatregmatchintregr   r   r   unstring   s   r    c                 C   sD   t | trdd | D S t | trtt| S t | tr t| S | S )zf
    Given a non-deserializable object, make a best effort to
    return a useful set of results.
    c                 S   s   g | ]}t |qS r   r   ).0r   r   r   r   
<listcomp>7   s    zdecode_list.<locals>.<listcomp>)r   listr   r    r   str)r   r   r   r   decode_list1   s   


r%   )r   r   helpersr   r   r   r    r%   r   r   r   r   <module>   s    
