ó
    Ñ]j7)  ã                   ó¼   • S r SrSrSrSrSSKrSSKrSSKJrJ	r	  SSK
JrJr  \" 5       rSS	 jr\4S
 jrS r " S S\5      r " S S5      r " S S5      rS rS rg)z6Identify specific nodes in a JSON document (RFC 6901) u    Stefan KÃ¶gl <stefan@skoegl.net>z3.1.1z2https://github.com/stefankoegl/python-json-pointerzModified BSD Licenseé    N)ÚMappingÚSequence)ÚteeÚchainc                 ó<   • [        U5      nUR                  XU5      $ )a’  Resolves a pointer against doc and sets the value of the target within doc.

With inplace set to true, doc is modified as long as pointer is not the
root.

>>> obj = {'foo': {'anArray': [ {'prop': 44}], 'another prop': {'baz': 'A string' }}}

>>> set_pointer(obj, '/foo/anArray/0/prop', 55) ==     {'foo': {'another prop': {'baz': 'A string'}, 'anArray': [{'prop': 55}]}}
True

>>> set_pointer(obj, '/foo/yet another prop', 'added prop') ==     {'foo': {'another prop': {'baz': 'A string'}, 'yet another prop': 'added prop', 'anArray': [{'prop': 55}]}}
True

>>> obj = {'foo': {}}
>>> set_pointer(obj, '/foo/a%20b', 'x') ==     {'foo': {'a%20b': 'x' }}
True
)ÚJsonPointerÚset)ÚdocÚpointerÚvalueÚinplaces       ÚH/home/mande/repo/quber/.venv/lib/python3.13/site-packages/jsonpointer.pyÚset_pointerr   /   s   € ô, ˜'Ó"€GØ�;‰;�s 7Ó+Ð+ó    c                 ó:   • [        U5      nUR                  X5      $ )a  Resolves pointer against doc and returns the referenced object

>>> obj = {'foo': {'anArray': [ {'prop': 44}], 'another prop': {'baz': 'A string' }}, 'a%20b': 1, 'c d': 2}

>>> resolve_pointer(obj, '') == obj
True

>>> resolve_pointer(obj, '/foo') == obj['foo']
True

>>> resolve_pointer(obj, '/foo/another prop') == obj['foo']['another prop']
True

>>> resolve_pointer(obj, '/foo/another prop/baz') == obj['foo']['another prop']['baz']
True

>>> resolve_pointer(obj, '/foo/anArray/0') == obj['foo']['anArray'][0]
True

>>> resolve_pointer(obj, '/some/path', None) == None
True

>>> resolve_pointer(obj, '/a b', None) == None
True

>>> resolve_pointer(obj, '/a%20b') == 1
True

>>> resolve_pointer(obj, '/c d') == 2
True

>>> resolve_pointer(obj, '/c%20d', None) == None
True
)r   Úresolve)r
   r   Údefaults      r   Úresolve_pointerr   I   s   € ôH ˜'Ó"€GØ�?‰?˜3Ó(Ð(r   c                 óD   • [        U 5      u  pU H  n  O   [        X5      $ )zÐTransforms a list to a list of tuples of adjacent items

s -> (s0,s1), (s1,s2), (s2, s3), ...

>>> list(pairwise([]))
[]

>>> list(pairwise([1]))
[]

>>> list(pairwise([1, 2, 3, 4]))
[(1, 2), (2, 3), (3, 4)]
)r   Úzip)ÚiterableÚaÚbÚ_s       r   Úpairwiser   q   s&   € ô ˆx‹=�D€AÛˆÙñ äˆq‹9Ðr   c                   ó   • \ rS rSrSrg)ÚJsonPointerExceptioné…   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   r   r   r   r   …   s   † Úr   r   c                   ó$   • \ rS rSrSrS rS rSrg)Ú	EndOfListé‰   z)Result of accessing element "-" of a listc                 ó   • Xl         g ©N©Úlist_)Úselfr+   s     r   Ú__init__ÚEndOfList.__init__Œ   s   € Ø�
r   c                 óp   • SR                  U R                  R                  [        U R                  5      S9$ )Nz{cls}({lst}))ÚclsÚlst)ÚformatÚ	__class__r    Úreprr+   ©r,   s    r   Ú__repr__ÚEndOfList.__repr__�   s2   € Ø×$Ñ$¨¯©×)@Ñ)@Ü)-¨d¯j©jÓ)9ð %ð ;ð 	;r   r*   N)r    r!   r"   r#   Ú__doc__r-   r6   r$   r   r   r   r&   r&   ‰   s   † Ù3òõ;r   r&   c                   óò   • \ rS rSrSr\R                  " S5      r\R                  " S5      rS r	S r
\4S jr\rSS jr\S	 5       rS
 rS rS rS rS rS r\S 5       rS rS rS rS r\S 5       rSrg)r   é”   z:A JSON Pointer that can reference parts of a JSON documentz0|[1-9][0-9]*$z(~[^01]|~$)c                 óF  • U R                   R                  U5      nU(       a(  [        SR                  UR	                  5       5      5      eUR                  S5      nUR                  S5      S:w  a  [        S5      eU Vs/ s H  n[        U5      PM     nnX0l        g s  snf )NzFound invalid escape {}Ú/r   Ú zLocation must start with /)	Ú_RE_INVALID_ESCAPEÚsearchr   r2   ÚgroupÚsplitÚpopÚunescapeÚparts)r,   r   Úinvalid_escaperD   Úparts        r   r-   ÚJsonPointer.__init__œ   s’   € ð ×0Ñ0×7Ñ7¸Ó@ˆÞÜ&Ð'@×'GÑ'GØ×$Ñ$Ó&ó((ó )ð )ð —‘˜cÓ"ˆØ�9‰9�Q‹<˜2ÓÜ&Ð'CÓDÐDá,1Ó2ªE D”˜$–©EˆÐ2Ø�
ùò 3s   Â Bc                 óÂ   • U R                   (       d  US4$ U R                   SS  H  nU R                  X5      nM     U[        R                  XR                   S   5      4$ )z>Resolves ptr until the last step, returns (sub-doc, last-step)Néÿÿÿÿ)rD   Úwalkr   Úget_part©r,   r
   rF   s      r   Úto_lastÚJsonPointer.to_last«   sW   € ð �z�zØ˜�9Ðà—J‘J˜s “OˆDØ—)‘)˜CÓ&ŠCñ $ð ”K×(Ñ(¨¯j©j¸©nÓ=Ð=Ð=r   c                 óŒ   • U R                    H  n U R                  X5      nM     U$ ! [         a    U[        L a  e Us s  $ f = f)zBResolves the pointer against doc and returns the referenced object)rD   rJ   r   Ú_nothing)r,   r
   r   rF   s       r   r   ÚJsonPointer.resolve¶   sM   € ð —J”JˆDð#Ø—i‘i Ó*’ñ ð ˆ
øô (ó #ØœhÒ&Øà"”Nð	#ús   ‘(¨AÁAc                 ó$  • [        U R                  5      S:X  a  U(       a  [        S5      eU$ U(       d  [        R                  " U5      nU R                  U5      u  pE[        U[        5      (       a  US:X  a  UR                  U5        U$ X$U'   U$ )zFResolve the pointer against the doc and replace the target with value.r   zCannot set root in placeÚ-)	ÚlenrD   r   ÚcopyÚdeepcopyrM   Ú
isinstancer   Úappend)r,   r
   r   r   ÚparentrF   s         r   r	   ÚJsonPointer.setÇ   s}   € ô ˆt�z‰z‹?˜aÓÞÜ*Ð+EÓFÐFØˆLæÜ—-’- Ó$ˆCàŸ™ cÓ*‰ˆä�fœh×'Ñ'¨D°C«KØ�M‰M˜%Ô ð ˆ
ð !�4‰Làˆ
r   c                 óJ  • [        U[        5      (       a  U$ [        U[        5      (       aN  US:X  a  U$ [        R                  R                  [        U5      5      (       d  [        SU-  5      e[        U5      $ [        US5      (       a  U$ [        S[        U5      -  5      e)z)Returns the next step in the correct typerS   z"'%s' is not a valid sequence indexÚ__getitem__zXDocument '%s' does not support indexing, must be mapping/sequence or support __getitem__)rW   r   r   r   Ú_RE_ARRAY_INDEXÚ	fullmatchÚstrr   ÚintÚhasattrÚtype)r0   r
   rF   s      r   rK   ÚJsonPointer.get_partÛ   s    € ô �cœ7×#Ñ#ØˆKä˜œX×&Ñ&à�s‹{Ø�ä×.Ñ.×8Ñ8¼¸T»×CÑCÜ*Ð+OÐRVÑ+VÓWÐWä�t“9Ðä�S˜-×(Ñ(ð ˆKô 'ð (YÜ[_Ð`cÓ[dñ(eó fð fr   c                 ó   • U R                   $ )zYReturns the list of the parts. For example, JsonPointer('/a/b').get_parts() == ['a', 'b']©rD   r5   s    r   Ú	get_partsÚJsonPointer.get_partsõ   s   € ð �z‰zÐr   c                 óT  • [         R                  X5      n[        US5      (       d   S[        U5      < 35       e[	        U[
        5      (       a  US:X  a  [        U5      $  X   $  X   $ ! [         a    [        SU< S35      ef = f! [         a    [        SU< SU< 35      ef = f)z6Walks one step in doc and returns the referenced part r\   zinvalid document type rS   zindex 'z' is out of boundszmember 'z' not found in )
r   rK   ra   rb   rW   r   r&   Ú
IndexErrorr   ÚKeyErrorrL   s      r   rJ   ÚJsonPointer.walkú   s°   € ô ×#Ñ# CÓ.ˆä�s˜M×*Ñ*ÑUÌ$ÈsÍ)Ð,UÓUÐ*ä�cœ8×$Ñ$Ø�s‹{Ü  “~Ð%ðTØ‘yÐ ð	TØ‘9Ðøô ó TÝ*ËDÐ+RÓSÐSðTûô ó 	TÝ&ËÊcÐ'RÓSÐSð	Tús   Á"A+ Á'B	 Á+BÂ	B'c                 ó`   • U R                   S[        UR                   5       UR                   :H  $ )ú,Returns True if self contains the given ptr N)rD   rT   )r,   Úptrs     r   ÚcontainsÚJsonPointer.contains  s$   € à�z‰z˜/œ3˜sŸy™y›>Ð*¨c¯i©iÑ7Ð7r   c                 ó$   • U R                  U5      $ )rm   )ro   )r,   Úitems     r   Ú__contains__ÚJsonPointer.__contains__  s   € à�}‰}˜TÓ"Ð"r   c                 ó  • [        U[        5      (       a  UR                  nO-[        U[        5      (       a  [        U5      R                  nOUn [        R	                  [        U R                  U5      5      $ !   [        S5      e= f)zCReturns a new JsonPointer with the given suffix append to this ptr zInvalid suffix)rW   r   rD   r_   Ú
from_partsr   r   )r,   ÚsuffixÚsuffix_partss      r   ÚjoinÚJsonPointer.join  sn   € ä�fœk×*Ñ*Ø!Ÿ<™<‰LÜ˜¤×$Ñ$Ü& vÓ.×4Ñ4‰Là!ˆLð	9Ü×)Ñ)¬%°·
±
¸LÓ*IÓJÐJøð	9Ü&Ð'7Ó8Ð8ús   Á(A: Á:Bc                 ó$   • U R                  U5      $ r)   )ry   )r,   rw   s     r   Ú__truediv__ÚJsonPointer.__truediv__'  s   € Ø�y‰y˜Ó Ð r   c                 ó†   • U R                    Vs/ s H  n[        U5      PM     nnSR                  S U 5       5      $ s  snf )zgReturns the string representation of the pointer

>>> ptr = JsonPointer('/~0/0/~1').path == '/~0/0/~1'
r=   c              3   ó,   #   • U  H
  nS U-   v •  M     g7f©r<   Nr   ©Ú.0rF   s     r   Ú	<genexpr>Ú#JsonPointer.path.<locals>.<genexpr>1  s   é € Ð4ªe d�s˜T–zªeùó   ‚)rD   Úescapery   )r,   rF   rD   s      r   ÚpathÚJsonPointer.path*  s:   € ð +/¯*ª*Ó5ª* $”˜–©*ˆÐ5Ø�w‰wÑ4©eÓ4Ó4Ð4ùò 6s   �>c                 ó`   • [        U[        5      (       d  gU R                  UR                  :H  $ )zæCompares a pointer to another object

Pointers can be compared by comparing their strings (or splitted
strings), because no two different parts can point to the same
structure in an object (eg no different number representations)
F)rW   r   rD   )r,   Úothers     r   Ú__eq__ÚJsonPointer.__eq__3  s'   € ô ˜%¤×-Ñ-Øà�z‰z˜UŸ[™[Ñ(Ð(r   c                 ó>   • [        [        U R                  5      5      $ r)   )ÚhashÚtuplerD   r5   s    r   Ú__hash__ÚJsonPointer.__hash__@  s   € Ü”E˜$Ÿ*™*Ó%Ó&Ð&r   c                 ó   • U R                   $ r)   )r‡   r5   s    r   Ú__str__ÚJsonPointer.__str__C  s   € Ø�y‰yÐr   c                 ód   • [        U 5      R                  S-   [        U R                  5      -   S-   $ )NÚ(Ú))rb   r    r4   r‡   r5   s    r   r6   ÚJsonPointer.__repr__F  s)   € Ü�D‹z×"Ñ" SÑ(¬4°·	±	«?Ñ:¸SÑ@Ð@r   c                 ó”   • U Vs/ s H  n[        [        U5      5      PM     nnU " SR                  S U 5       5      5      nU$ s  snf )z„Constructs a JsonPointer from a list of (unescaped) paths

>>> JsonPointer.from_parts(['a', '~', '/', 0]).path == '/a/~0/~1/0'
True
r=   c              3   ó,   #   • U  H
  nS U-   v •  M     g7fr€   r   r�   s     r   rƒ   Ú)JsonPointer.from_parts.<locals>.<genexpr>Q  s   é € Ð7²¨˜# ž*²ùr…   )r†   r_   ry   )r0   rD   rF   rn   s       r   rv   ÚJsonPointer.from_partsI  sD   € ñ 05Ó5ªu t”œ˜D›	Ö"©uˆÐ5Ù�"—'‘'Ñ7±Ó7Ó7Ó8ˆØˆ
ùò 6s   …Are   N©T)r    r!   r"   r#   r8   ÚreÚcompiler]   r>   r-   rM   rP   r   Úgetr	   ÚclassmethodrK   rf   rJ   ro   rs   ry   r|   Úpropertyr‡   r‹   r�   r“   r6   rv   r$   r   r   r   r   r   ”   s·   † ÙDð —j’jÐ!1Ó2€OØŸš MÓ2Ðòò	>ð $,ô ð €Côð( ñfó ðfò2ò
Tò08ò#ò9ò!ð ñ5ó ð5ò)ò'òòAð ñó ór   r   c                 óF   • U R                  SS5      R                  SS5      $ )NÚ~ú~0r<   ú~1©Úreplace©Úss    r   r†   r†   U  s    € Ø�9‰9�S˜$Ó×'Ñ'¨¨TÓ2Ð2r   c                 óF   • U R                  SS5      R                  SS5      $ )Nr¦   r<   r¥   r¤   r§   r©   s    r   rC   rC   Y  s    € Ø�9‰9�T˜3Ó×'Ñ'¨¨cÓ2Ð2r   r�   )r8   Ú
__author__Ú__version__Ú__website__Ú__license__rU   rž   Úcollections.abcr   r   Ú	itertoolsr   r   ÚobjectrP   r   r   r   Ú	Exceptionr   r&   r   r†   rC   r   r   r   Ú<module>r´      su   ðñ> >ð 0€
Ø€ØB€Ø$€ã Û 	ß -ß  á‹8€ô,ð4 +3ô %)òPô(	˜9ô 	÷;ñ ;÷~ñ ~òB3ó3r   