§
    cŠtj7)  ã                   óÒ   — d Z dZdZdZdZddlZddlZddlmZm	Z	 ddl
mZmZ  e¦   «         Zdd
„Zefd„Zd„ Z G d„ de¦  «        Z G d„ d¦  «        Z G d„ d¦  «        Zd„ Zd„ ZdS )z7 Identify 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ÚchainTc                 óN   — t          |¦  «        }|                     | ||¦  «        S )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       úI/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/jsonpointer.pyÚset_pointerr   /   s'   € õ, ˜'Ñ"Ô"€GØ�;Š;�s˜E 7Ñ+Ô+Ð+ó    c                 óL   — t          |¦  «        }|                     | |¦  «        S )aa   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                 óP   — t          | ¦  «        \  }}|D ]} t          ||¦  «        S )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   s3   € õ ˆx‰=Œ=�D€A€qØð ð ˆØÝˆq�!‰9Œ9Ðr   c                   ó   — e Zd ZdS )ÚJsonPointerExceptionN)Ú__name__Ú
__module__Ú__qualname__© r   r   r   r   …   s   € € € € € Ø€Dr   r   c                   ó   — e Zd ZdZd„ Zd„ ZdS )Ú	EndOfListz)Result of accessing element "-" of a listc                 ó   — || _         d S ©N)Úlist_)Úselfr&   s     r   Ú__init__zEndOfList.__init__Œ   s   € ØˆŒ
ˆ
ˆ
r   c                 óh   — d                      | j        j        t          | j        ¦  «        ¬¦  «        S )Nz{cls}({lst}))ÚclsÚlst)ÚformatÚ	__class__r   Úreprr&   ©r'   s    r   Ú__repr__zEndOfList.__repr__�   s3   € Ø×$Ò$¨¬Ô)@Ý)-¨d¬jÑ)9Ô)9ð %ñ ;ô ;ð 	;r   N)r   r   r    Ú__doc__r(   r0   r!   r   r   r#   r#   ‰   s8   € € € € € Ø3Ð3ðð ð ð;ð ;ð ;ð ;ð ;r   r#   c                   óò   — e Zd ZdZ ej        d¦  «        Z ej        d¦  «        Zd„ Zd„ Z	e
fd„ZeZdd„Zed	„ ¦   «         Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zed„ ¦   «         Zd„ Zd„ Zd„ Zd„ Zed„ ¦   «         ZdS )r   z:A JSON Pointer that can reference parts of a JSON documentz0|[1-9][0-9]*$z(~[^01]|~$)c                 óF  — | j                              |¦  «        }|r4t          d                     |                     ¦   «         ¦  «        ¦  «        ‚|                     d¦  «        }|                     d¦  «        dk    rt          d¦  «        ‚d„ |D ¦   «         }|| _        d S )NzFound invalid escape {}ú/r   Ú zLocation must start with /c                 ó,   — g | ]}t          |¦  «        ‘ŒS r!   )Úunescape©Ú.0Úparts     r   ú
<listcomp>z(JsonPointer.__init__.<locals>.<listcomp>¨   s   € Ð2Ð2Ð2 D•˜$‘”Ð2Ð2Ð2r   )Ú_RE_INVALID_ESCAPEÚsearchr   r,   ÚgroupÚsplitÚpopÚparts)r'   r   Úinvalid_escaperA   s       r   r(   zJsonPointer.__init__œ   s«   € ð Ô0×7Ò7¸Ñ@Ô@ˆØð 	)Ý&Ð'@×'GÒ'GØ×$Ò$Ñ&Ô&ñ((ô ((ñ )ô )ð )ð —’˜cÑ"Ô"ˆØ�9Š9�Q‰<Œ<˜2ÒÐÝ&Ð'CÑDÔDÐDà2Ð2¨EÐ2Ñ2Ô2ˆØˆŒ
ˆ
ˆ
r   c                 ó¸   — | j         s|dfS | j         dd…         D ]}|                      ||¦  «        }Œ|t                               || j         d         ¦  «        fS )z>Resolves ptr until the last step, returns (sub-doc, last-step)Néÿÿÿÿ)rA   Úwalkr   Úget_part©r'   r
   r:   s      r   Úto_lastzJsonPointer.to_last«   sg   € ð Œzð 	Ø˜�9Ðà”J˜s ˜s”Oð 	'ð 	'ˆDØ—)’)˜C Ñ&Ô&ˆCˆCà•K×(Ò(¨¨d¬j¸¬nÑ=Ô=Ð=Ð=r   c                 ó„   — | j         D ]7}	 |                      ||¦  «        }Œ# t          $ r |t          u r‚ |cY c S w xY w|S )zBResolves the pointer against doc and returns the referenced object)rA   rE   r   Ú_nothing)r'   r
   r   r:   s       r   r   zJsonPointer.resolve¶   sl   € ð ”Jð 	#ð 	#ˆDð#Ø—i’i  TÑ*Ô*��øÝ'ð #ð #ð #Ø�hÐ&Ð&Øà"�N�N�N�N�Nð	#øøøð ˆ
s   ‹"¢=¼=Tc                 ó$  — t          | j        ¦  «        dk    r|rt          d¦  «        ‚|S |st          j        |¦  «        }|                      |¦  «        \  }}t          |t          ¦  «        r|dk    r|                     |¦  «         n|||<   |S )zFResolve the pointer against the doc and replace the target with value.r   zCannot set root in placeú-)	ÚlenrA   r   ÚcopyÚdeepcopyrH   Ú
isinstancer   Úappend)r'   r
   r   r   Úparentr:   s         r   r	   zJsonPointer.setÇ   s�   € õ ˆtŒz‰?Œ?˜aÒÐØð GÝ*Ð+EÑFÔFÐFØˆLàð 	%Ý”- Ñ$Ô$ˆCàŸš cÑ*Ô*‰ˆ�å�f�hÑ'Ô'ð 	!¨D°CªK¨KØ�MŠM˜%Ñ Ô Ð Ð à ˆF�4‰Làˆ
r   c                 óf  — t          |t          ¦  «        r|S t          |t          ¦  «        rU|dk    r|S t          j                             t          |¦  «        ¦  «        st          d|z  ¦  «        ‚t          |¦  «        S t          |d¦  «        r|S t          dt          |¦  «        z  ¦  «        ‚)z)Returns the next step in the correct typerL   z"'%s' is not a valid sequence indexÚ__getitem__zXDocument '%s' does not support indexing, must be mapping/sequence or support __getitem__)rP   r   r   r   Ú_RE_ARRAY_INDEXÚ	fullmatchÚstrr   ÚintÚhasattrÚtype)r*   r
   r:   s      r   rF   zJsonPointer.get_partÛ   sÇ   € õ �c�7Ñ#Ô#ð 	fØˆKå˜�XÑ&Ô&ð 	fà�sŠ{ˆ{Ø�åÔ.×8Ò8½¸T¹¼ÑCÔCð XÝ*Ð+OÐRVÑ+VÑWÔWÐWå�t‘9”9Ðå�S˜-Ñ(Ô(ð 	fð ˆKõ 'ð (YÝ[_Ð`cÑ[dÔ[dñ(eñ fô fð fr   c                 ó   — | j         S )zYReturns the list of the parts. For example, JsonPointer('/a/b').get_parts() == ['a', 'b'])rA   r/   s    r   Ú	get_partszJsonPointer.get_partsõ   s   € ð ŒzÐr   c                 óŒ  — t                                ||¦  «        }t          |d¦  «        sJ dt          |¦  «        ›�¦   «         ‚t	          |t
          ¦  «        r?|dk    rt          |¦  «        S 	 ||         S # t          $ r t          d|›d�¦  «        ‚w xY w	 ||         S # t          $ r t          d|›d|›�¦  «        ‚w xY w)z7 Walks one step in doc and returns the referenced part rT   zinvalid document type rL   zindex 'z' is out of boundszmember 'z' not found in )
r   rF   rY   rZ   rP   r   r#   Ú
IndexErrorr   ÚKeyErrorrG   s      r   rE   zJsonPointer.walkú   sÿ   € õ ×#Ò# C¨Ñ.Ô.ˆå�s˜MÑ*Ô*ÐUÐUÐUÍ$ÈsÉ)Ì)È)Ð,UÑUÔUÐ*å�c�8Ñ$Ô$ð 	TØ�sŠ{ˆ{Ý  ‘~”~Ð%ðTØ˜4”yÐ øåð Tð Tð TÝ*Ð*ÈDÈDÈDÐ+RÑSÔSÐSðTøøøð	TØ�t”9Ðøåð 	Tð 	Tð 	TÝ&Ð&ÈÈÈÈcÈcÐ'RÑSÔSÐSð	Tøøøs   Á1A9 Á9BÂB# Â# Cc                 óV   — | j         dt          |j         ¦  «        …         |j         k    S )ú- Returns True if self contains the given ptr N)rA   rM   )r'   Úptrs     r   ÚcontainszJsonPointer.contains  s"   € àŒz˜/�3˜sœy™>œ>˜/Ô*¨c¬iÒ7Ð7r   c                 ó,   — |                       |¦  «        S )ra   )rc   )r'   Úitems     r   Ú__contains__zJsonPointer.__contains__  s   € à�}Š}˜TÑ"Ô"Ð"r   c                 ó  — t          |t          ¦  «        r|j        }n,t          |t          ¦  «        rt          |¦  «        j        }n|}	 t                               t          | j        |¦  «        ¦  «        S #  t          d¦  «        ‚xY w)zD Returns a new JsonPointer with the given suffix append to this ptr zInvalid suffix)rP   r   rA   rW   Ú
from_partsr   r   )r'   ÚsuffixÚsuffix_partss      r   ÚjoinzJsonPointer.join  sƒ   € å�f�kÑ*Ô*ð 	"Ø!œ<ˆLˆLÝ˜¥Ñ$Ô$ð 	"Ý& vÑ.Ô.Ô4ˆLˆLà!ˆLð	9Ý×)Ò)­%°´
¸LÑ*IÔ*IÑJÔJÐJøð	9Ý&Ð'7Ñ8Ô8Ð8øøøs   Á,A8 Á8B	c                 ó,   — |                       |¦  «        S r%   ©rk   )r'   ri   s     r   Ú__truediv__zJsonPointer.__truediv__'  s   € Ø�yŠy˜Ñ Ô Ð r   c                 ób   — d„ | j         D ¦   «         }d                     d„ |D ¦   «         ¦  «        S )zwReturns the string representation of the pointer

        >>> ptr = JsonPointer('/~0/0/~1').path == '/~0/0/~1'
        c                 ó,   — g | ]}t          |¦  «        ‘ŒS r!   )Úescaper8   s     r   r;   z$JsonPointer.path.<locals>.<listcomp>0  s   € Ð5Ð5Ð5 $•˜‘”Ð5Ð5Ð5r   r5   c              3   ó    K  — | ]	}d |z   V — Œ
dS ©r4   Nr!   r8   s     r   ú	<genexpr>z#JsonPointer.path.<locals>.<genexpr>1  s&   è è € Ð4Ð4 d�s˜T‘zÐ4Ð4Ð4Ð4Ð4Ð4r   )rA   rk   )r'   rA   s     r   ÚpathzJsonPointer.path*  s:   € ð 6Ð5¨$¬*Ð5Ñ5Ô5ˆØ�wŠwÐ4Ð4¨eÐ4Ñ4Ô4Ñ4Ô4Ð4r   c                 óP   — t          |t          ¦  «        sdS | j        |j        k    S )a  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)rP   r   rA   )r'   Úothers     r   Ú__eq__zJsonPointer.__eq__3  s*   € õ ˜%¥Ñ-Ô-ð 	Ø�5àŒz˜Uœ[Ò(Ð(r   c                 óD   — t          t          | j        ¦  «        ¦  «        S r%   )ÚhashÚtuplerA   r/   s    r   Ú__hash__zJsonPointer.__hash__@  s   € Ý•E˜$œ*Ñ%Ô%Ñ&Ô&Ð&r   c                 ó   — | j         S r%   )ru   r/   s    r   Ú__str__zJsonPointer.__str__C  s
   € ØŒyÐr   c                 ó`   — t          | ¦  «        j        dz   t          | j        ¦  «        z   dz   S )Nú(ú))rZ   r   r.   ru   r/   s    r   r0   zJsonPointer.__repr__F  s(   € Ý�D‰zŒzÔ" SÑ(­4°´	©?¬?Ñ:¸SÑ@Ð@r   c                 ón   — d„ |D ¦   «         } | d                      d„ |D ¦   «         ¦  «        ¦  «        }|S )zœConstructs a JsonPointer from a list of (unescaped) paths

        >>> JsonPointer.from_parts(['a', '~', '/', 0]).path == '/a/~0/~1/0'
        True
        c                 óF   — g | ]}t          t          |¦  «        ¦  «        ‘ŒS r!   )rq   rW   r8   s     r   r;   z*JsonPointer.from_parts.<locals>.<listcomp>P  s&   € Ð5Ð5Ð5 t•�˜D™	œ	Ñ"Ô"Ð5Ð5Ð5r   r5   c              3   ó    K  — | ]	}d |z   V — Œ
dS rs   r!   r8   s     r   rt   z)JsonPointer.from_parts.<locals>.<genexpr>Q  s&   è è € Ð7Ð7¨˜# ™*Ð7Ð7Ð7Ð7Ð7Ð7r   rm   )r*   rA   rb   s      r   rh   zJsonPointer.from_partsI  sF   € ð 6Ð5¨uÐ5Ñ5Ô5ˆØˆc�"—'’'Ð7Ð7°Ð7Ñ7Ô7Ñ7Ô7Ñ8Ô8ˆØˆ
r   N©T)r   r   r    r1   ÚreÚcompilerU   r<   r(   rH   rJ   r   Úgetr	   ÚclassmethodrF   r\   rE   rc   rf   rk   rn   Úpropertyru   rx   r|   r~   r0   rh   r!   r   r   r   r   ”   s‚  € € € € € ØDÐDð !�b”jÐ!1Ñ2Ô2€OØ#˜œ MÑ2Ô2Ððð ð ð	>ð 	>ð 	>ð $,ð ð ð ð ð €Cðð ð ð ð( ðfð fñ „[ðfð2ð ð ð
Tð Tð Tð08ð 8ð 8ð#ð #ð #ð9ð 9ð 9ð!ð !ð !ð ð5ð 5ñ „Xð5ð)ð )ð )ð'ð 'ð 'ðð ð ðAð Að Að ðð ñ „[ðð ð r   r   c                 óV   — |                       dd¦  «                              dd¦  «        S )Nú~ú~0r4   ú~1©Úreplace©Úss    r   rq   rq   U  s&   € Ø�9Š9�S˜$ÑÔ×'Ò'¨¨TÑ2Ô2Ð2r   c                 óV   — |                       dd¦  «                              dd¦  «        S )NrŽ   r4   r�   rŒ   r�   r‘   s    r   r7   r7   Y  s&   € Ø�9Š9�T˜3ÑÔ×'Ò'¨¨cÑ2Ô2Ð2r   r…   )r1   Ú
__author__Ú__version__Ú__website__Ú__license__rN   r†   Úcollections.abcr   r   Ú	itertoolsr   r   ÚobjectrJ   r   r   r   Ú	Exceptionr   r#   r   rq   r7   r!   r   r   ú<module>rœ      sX  ðð> >Ð =ð 0€
Ø€ØB€Ø$€à €€€Ø 	€	€	€	Ø -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ø  Ð  Ð  Ð  Ð  Ð  Ð  Ð  àˆ6‰8Œ8€ð,ð ,ð ,ð ,ð4 +3ð %)ð %)ð %)ð %)ðPð ð ð(	ð 	ð 	ð 	ð 	˜9ñ 	ô 	ð 	ð;ð ;ð ;ð ;ð ;ñ ;ô ;ð ;ð~ð ~ð ~ð ~ð ~ñ ~ô ~ð ~ðB3ð 3ð 3ð3ð 3ð 3ð 3ð 3r   