
    ph_=                         S SK r S SKJrJr  S SKJrJrJrJrJ	r	  S SK
Jr  S SKJr  SSKJr  SSKJr  SS	KJr   " S
 S5      rg)    N)JSONDecodeErrorloads)DictListOptionalTupleUnion)	DataError)deprecated_function   )JsonType)decode_dict_keys)Pathc                      \ rS rSrSr\R                  " 5       4S\S\\   S\	S\
\\      4S jjr  S>S\S\S	\S
\\   S\\   S\
\\      4S jjrS\S\S\S\	S\
\\      4
S jr\R                  " 5       4S\S\\   S\
\\      4S jjr\R                  " 5       S4S\S\\   S\\   S\
\\      4S jjrS\S\S
\S\S\
\\      4
S jr\R                  " 5       4S\S\\   S\
\   4S jjr\R                  " 5       4S\S\\   S\
4S jjr\R                  " 5       4S\S\\   S\
\\
\         4S jjr\R                  " 5       4S\S\\   S\
\\      4S jjrS\S\S\S\4S jr\" SSS9S\S\S\S\4S j5       r\R                  " 5       4S\S\\   S\4S jjr\R                  " 5       4S\S\\   S\4S jjr\rS S!.S\S"\\   S\\
\	      4S# jjrS$\
\   S\S\
\	   4S% jr   S?S\S\S&\	S'\\   S(\\   S)\\   S\\   4S* jjrS+\
\ \\\	4      S\\   4S, jr! S@S\S\S&\	S)\\   S\\   4
S- jjr"   S?S\S\S.\S'\\   S(\\   S)\\   S\\   4S/ jjr#   S?S0\S1\S'\\   S(\\   S)\\   S\$\\4   4S2 jjr%SAS\S\\   S\
\\      4S3 jjr&\R                  " 5       4S\S\\   S\'\\
\\      4   4S4 jjr(\R                  " 5       4S\S5\S\\   S\'\\
\\      4   4S6 jjr)S\R                  " 5       4S7\S\\   S\\   S\'\\
\   4   4S8 jjr*\" SS9S9S: 5       r+\" SS9S9S; 5       r,\" SS9S9S< 5       r-S=r.g)BJSONCommands   zjson commands.namepathargsreturnc                     U[        U5      /nU H#  nUR                  U R                  U5      5        M%     U R                  " S/UQ76 $ )zAppend the objects ``args`` to the array under the
``path` in key ``name``.

For more information see `JSON.ARRAPPEND <https://redis.io/commands/json.arrappend>`_..
zJSON.ARRAPPENDstrappend_encodeexecute_command)selfr   r   r   piecesos         V/home/james-whalen/.local/lib/python3.13/site-packages/redis/commands/json/commands.py	arrappendJSONCommands.arrappend   sG     D	"AMM$,,q/* ##$4>v>>    Nscalarstartstopc                     U[        U5      U R                  U5      /nUb%  UR                  U5        Ub  UR                  U5        U R                  " S/UQ7SU/06$ )a
  
Return the index of ``scalar`` in the JSON array under ``path`` at key
``name``.

The search can be limited using the optional inclusive ``start``
and exclusive ``stop`` indices.

For more information see `JSON.ARRINDEX <https://redis.io/commands/json.arrindex>`_.
zJSON.ARRINDEXkeys)r   r   r   r   )r   r   r   r$   r%   r&   r   s          r    arrindexJSONCommands.arrindex   s^    " D	4<<#78MM% d###OJfJD6JJr#   indexc                     U[        U5      U/nU H#  nUR                  U R                  U5      5        M%     U R                  " S/UQ76 $ )zInsert the objects ``args`` to the array at index ``index``
under the ``path` in key ``name``.

For more information see `JSON.ARRINSERT <https://redis.io/commands/json.arrinsert>`_.
zJSON.ARRINSERTr   )r   r   r   r+   r   r   r   s          r    	arrinsertJSONCommands.arrinsert6   sI     D	5)AMM$,,q/* ##$4>v>>r#   c                 :    U R                  SU[        U5      U/S9$ )zReturn the length of the array JSON value under ``path``
at key``name``.

For more information see `JSON.ARRLEN <https://redis.io/commands/json.arrlen>`_.
zJSON.ARRLENr(   r   r   r   r   r   s      r    arrlenJSONCommands.arrlenC   $     ##M4T$#PPr#   c                 <    U R                  SU[        U5      U5      $ )zPop the element at ``index`` in the array JSON value under
``path`` at key ``name``.

For more information see `JSON.ARRPOP <https://redis.io/commands/json.arrpop>`_.
zJSON.ARRPOPr1   )r   r   r   r+   s       r    arrpopJSONCommands.arrpopM   s     ##M4TEJJr#   c                 <    U R                  SU[        U5      X45      $ )zTrim the array JSON value under ``path`` at key ``name`` to the
inclusive range given by ``start`` and ``stop``.

For more information see `JSON.ARRTRIM <https://redis.io/commands/json.arrtrim>`_.
zJSON.ARRTRIMr1   )r   r   r   r%   r&   s        r    arrtrimJSONCommands.arrtrimZ   s     ##ND#d)UQQr#   c                 :    U R                  SU[        U5      U/S9$ )zGet the type of the JSON value under ``path`` from key ``name``.

For more information see `JSON.TYPE <https://redis.io/commands/json.type>`_.
z	JSON.TYPEr0   r1   r2   s      r    typeJSONCommands.typed   $    
 ##Ks4yv#NNr#   c                 :    U R                  SU[        U5      U/S9$ )zReturn the JSON value under ``path`` at key ``name``.

For more information see `JSON.RESP <https://redis.io/commands/json.resp>`_.
z	JSON.RESPr0   r1   r2   s      r    respJSONCommands.respk   r@   r#   c                 :    U R                  SU[        U5      U/S9$ )zReturn the key names in the dictionary JSON value under ``path`` at
key ``name``.

For more information see `JSON.OBJKEYS <https://redis.io/commands/json.objkeys>`_.
zJSON.OBJKEYSr0   r1   r2   s      r    objkeysJSONCommands.objkeysr   s$     ##ND#d)4&#QQr#   c                 :    U R                  SU[        U5      U/S9$ )zReturn the length of the dictionary JSON value under ``path`` at key
``name``.

For more information see `JSON.OBJLEN <https://redis.io/commands/json.objlen>`_.
zJSON.OBJLENr0   r1   r2   s      r    objlenJSONCommands.objlen|   r5   r#   numberc                 Z    U R                  SU[        U5      U R                  U5      5      $ )zIncrement the numeric (integer or floating point) JSON value under
``path`` at key ``name`` by the provided ``number``.

For more information see `JSON.NUMINCRBY <https://redis.io/commands/json.numincrby>`_.
zJSON.NUMINCRBYr   r   r   r   r   r   rJ   s       r    	numincrbyJSONCommands.numincrby   s-     ##dCIt||F/C
 	
r#   z4.0.0z deprecated since redisjson 1.0.0)versionreasonc                 Z    U R                  SU[        U5      U R                  U5      5      $ )zMultiply the numeric (integer or floating point) JSON value under
``path`` at key ``name`` with the provided ``number``.

For more information see `JSON.NUMMULTBY <https://redis.io/commands/json.nummultby>`_.
zJSON.NUMMULTBYrL   rM   s       r    	nummultbyJSONCommands.nummultby   s-     ##dCIt||F/C
 	
r#   c                 :    U R                  SU[        U5      5      $ )zEmpty arrays and objects (to have zero slots/keys without deleting the
array/object).

Return the count of cleared paths (ignoring non-array and non-objects
paths).

For more information see `JSON.CLEAR <https://redis.io/commands/json.clear>`_.
z
JSON.CLEARr1   r2   s      r    clearJSONCommands.clear   s     ##L$D	BBr#   keyc                 :    U R                  SU[        U5      5      $ )zDelete the JSON value stored at key ``key`` under ``path``.

For more information see `JSON.DEL <https://redis.io/commands/json.del>`_.
zJSON.DELr1   )r   rX   r   s      r    deleteJSONCommands.delete   s    
 ##JSY??r#   F)	no_escaper\   c                6   U/nU(       a  UR                  S5        [        U5      S:X  a%  UR                  [        R                  " 5       5        O#U H  nUR                  [	        U5      5        M      U R
                  " S/UQ7SU/06$ ! [         a     gf = f)a  
Get the object stored as a JSON value at key ``name``.

``args`` is zero or more paths, and defaults to root path
```no_escape`` is a boolean flag to add no_escape option to get
non-ascii characters

For more information see `JSON.GET <https://redis.io/commands/json.get>`_.
noescaper   zJSON.GETr(   N)r   lenr   	root_pathr   r   	TypeError)r   r   r\   r   r   ps         r    getJSONCommands.get   s     MM*%t9>MM$..*+ c!f% 
	''
IVI4&II 		s   4B 
BBr(   c                 n    / nX1-  nUR                  [        U5      5        U R                  " S/UQ7SU06$ )z
Get the objects stored as a JSON values under ``path``. ``keys``
is a list of one or more keys.

For more information see `JSON.MGET <https://redis.io/commands/json.mget>`_.
z	JSON.MGETr(   r   r   r   )r   r(   r   r   s       r    mgetJSONCommands.mget   s;     c$i ##KD&DtDDr#   objnxxxdecode_keysc                    U(       a  [        U5      nU[        U5      U R                  U5      /nU(       a  U(       a  [        S5      eU(       a  UR	                  S5        OU(       a  UR	                  S5        U R
                  " S/UQ76 $ )a  
Set the JSON value at key ``name`` under the ``path`` to ``obj``.

``nx`` if set to True, set ``value`` only if it does not exist.
``xx`` if set to True, set ``value`` only if it exists.
``decode_keys`` If set to True, the keys of ``obj`` will be decoded
with utf-8.

For the purpose of using this within a pipeline, this command is also
aliased to JSON.SET.

For more information see `JSON.SET <https://redis.io/commands/json.set>`_.
zNnx and xx are mutually exclusive: use one, the other or neither - but not bothNXXXzJSON.SET)r   r   r   	Exceptionr   r   )r   r   r   ri   rj   rk   rl   r   s           r    setJSONCommands.set   sy    , "3'CD	4<<#45 "2  MM$MM$##J888r#   tripletsc           	          / nU H8  nUR                  US   [        US   5      U R                  US   5      /5        M:     U R                  " S/UQ76 $ )aH  
Set the JSON value at key ``name`` under the ``path`` to ``obj``
for one or more keys.

``triplets`` is a list of one or more triplets of key, path, value.

For the purpose of using this within a pipeline, this command is also
aliased to JSON.MSET.

For more information see `JSON.MSET <https://redis.io/commands/json.mset>`_.
r   r      z	JSON.MSET)extendr   r   r   )r   rs   r   triplets       r    msetJSONCommands.mset  sU     GMM71:s71:WQZ8PQR  ##K9&99r#   c                     U(       a  [        U5      nU[        U5      U R                  U5      /nU R                  " S/UQ76 $ )a1  
Merges a given JSON value into matching paths. Consequently, JSON values
at matching paths are updated, deleted, or expanded with new children

``decode_keys`` If set to True, the keys of ``obj`` will be decoded
with utf-8.

For more information see `JSON.MERGE <https://redis.io/commands/json.merge>`_.
z
JSON.MERGE)r   r   r   r   )r   r   r   ri   rl   r   s         r    mergeJSONCommands.merge  s@      "3'CD	4<<#45##L:6::r#   	file_namec           	          [        U5       n[        UR                  5       5      nSSS5        U R                  XWXEUS9$ ! , (       d  f       N = f)a0  
Set the JSON value at key ``name`` under the ``path`` to the content
of the json file ``file_name``.

``nx`` if set to True, set ``value`` only if it does not exist.
``xx`` if set to True, set ``value`` only if it exists.
``decode_keys`` If set to True, the keys of ``obj`` will be decoded
with utf-8.

Nrj   rk   rl   )openr   readrq   )	r   r   r   r}   rj   rk   rl   fpfile_contents	            r    set_fileJSONCommands.set_file)  sC    ( )_ +L  xxLRKxXX _s   A  
A	json_pathroot_folderc                    0 n[         R                  " U5       H[  u  pxn	U	 HO  n
[         R                  R                  Xz5      n UR	                  S5      S   nU R                  UUUUUUS9  SXk'   MQ     M]     U$ ! [         a    SXk'    Mj  f = f)a=  
Iterate over ``root_folder`` and set each JSON file to a value
under ``json_path`` with the file name as the key.

``nx`` if set to True, set ``value`` only if it does not exist.
``xx`` if set to True, set ``value`` only if it exists.
``decode_keys`` If set to True, the keys of ``obj`` will be decoded
with utf-8.

.r   r   TF)oswalkr   joinrsplitr   r   )r   r   r   rj   rk   rl   set_files_resultrootdirsfilesfile	file_pathr}   s                r    set_pathJSONCommands.set_pathB  s    $ !#!5DGGLL4	8 ) 0 0 5a 8IMM!!!$/ "  37$/  "6"   ' 827$/8s   ,A::BBc                 p    U/nUb  UR                  [        U5      5        U R                  " S/UQ7SU/06$ )zReturn the length of the string JSON value under ``path`` at key
``name``.

For more information see `JSON.STRLEN <https://redis.io/commands/json.strlen>`_.
zJSON.STRLENr(   rf   )r   r   r   r   s       r    strlenJSONCommands.strlenh  s>     MM#d)$##MHFH$HHr#   c                 :    U R                  SU[        U5      5      $ )zToggle boolean value under ``path`` at key ``name``.
returning the new value.

For more information see `JSON.TOGGLE <https://redis.io/commands/json.toggle>`_.
zJSON.TOGGLEr1   r2   s      r    toggleJSONCommands.toggles  s     ##M4TCCr#   valuec                 b    U[        U5      U R                  U5      /nU R                  " S/UQ76 $ )a#  Append to the string JSON value. If two options are specified after
the key name, the path is determined to be the first. If a single
option is passed, then the root_path (i.e Path.root_path()) is used.

For more information see `JSON.STRAPPEND <https://redis.io/commands/json.strappend>`_.
zJSON.STRAPPEND)r   r   r   )r   r   r   r   r   s        r    	strappendJSONCommands.strappend}  s4     D	4<<#67##$4>v>>r#   
subcommandc                     SS/nX;  a  [        S[        U5      5      eU/nUS:X  a9  Uc  [        S5      eUR                  U5        UR                  [        U5      5        U R                  " S/UQ76 $ )zReturn the memory usage in bytes of a value under ``path`` from
key ``name``.

For more information see `JSON.DEBUG <https://redis.io/commands/json.debug>`_.
MEMORYHELPzThe only valid subcommands are zNo key specifiedz
JSON.DEBUG)r
   r   r   r   )r   r   rX   r   valid_subcommandsr   s         r    debugJSONCommands.debug  s{     &v..=sCT?UVV!{ 233MM#MM#d)$##L:6::r#   z/redisjson-py supported this, call get directly.c                 &    U R                   " U0 UD6$ N)rc   r   r   kwargss      r    jsongetJSONCommands.jsonget       xx(((r#   c                 &    U R                   " U0 UD6$ r   )rg   r   s      r    jsonmgetJSONCommands.jsonmget  s     yy$)&))r#   c                 &    U R                   " U0 UD6$ r   )rq   r   s      r    jsonsetJSONCommands.jsonset  r   r#    )NN)FFF)Fr   )/__name__
__module____qualname____firstlineno____doc__r   r`   r   r   r   r   intr!   r)   r-   r3   r8   r;   r>   rB   rE   rH   rN   r   rS   rV   rZ   forgetboolrc   rg   rq   r   rx   r{   r   r   r   r   r	   r   r   r   r   r   r   __static_attributes__r   r#   r    r   r      s    04~~/???'}?HP?	hsm	?$  $"KK K 	K
 }K smK 
hsm	K2??"?+.?7??	hsm	? 04~~/?QQ'}Q	hsm	Q #nn.!	KK smK }	K
 
hsm	KRR"R+.R69R	hsm	R 59NN4D O OHSM Oc O 59NN4D O OHSM O O 04~~/?RR'}R	htCy!	"R 04~~/?QQ'}Q	hsm	Q
c 
 
c 
c 
 1ST
c 
 
c 
c 
 U
 6:^^5E 	C# 	CXc] 	C# 	C 6:^^5E @# @Xc] @# @ F =B+3D>	$x.	!<
Ec 
E# 
E$x. 
E" #"&+%9%9 %9 	%9
 TN%9 TN%9 d^%9 
#%9N:T%S((:";< :# :, ',;; ; 	;
 d^; 
#;8 #"&+YY Y 	Y
 TNY TNY d^Y 
#Y: #"&+$ $  $  TN	$ 
 TN$  d^$  
c4i$ L	I3 	Ihsm 	ItHSM?R 	I 04~~/?DD'}D	tT(3-((	)D <@>>;K
?
? #
?+3C=
?	sD#''	(
? ""nn.	;; c]; sm	;
 
sDI~	;,  Q))  Q**  Q))r#   r   )r   jsonr   r   typingr   r   r   r   r	   redis.exceptionsr
   redis.utilsr   _utilr   decodersr   r   r   r   r   r#   r    <module>r      s,    	 ' 5 5 & +  & b) b)r#   