Information System : Linux apprendre2 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
Disable Function : NONE
ó
ŒKUc @ sg d d l m Z y d d l m Z m Z Wn' e k
rS d d l m Z m Z n Xd Z d Z d Z d Z
y* d d l m Z d d l
m Z e Z Wn' e k
r¿ d d l m Z e Z n Xd d l
m Z d d
l Z d d
l Z e j d ƒ Z d e f d
„ ƒ YZ d e f d „ ƒ YZ e ƒ Z e d „ Z e d „ Z d e f d „ ƒ YZ d „ Z! d
S( iÿÿÿÿ( t unicode_literals( t Mappingt Sequenceu Stefan Kögl u 1.9u2 https://github.com/stefankoegl/python-json-pointeru Modified BSD License( t unquote( t izip( t teeNu 0|[1-9][0-9]*$t JsonPointerExceptionc B s e Z RS( ( t __name__t
__module__( ( ( s/ /usr/lib/python2.7/site-packages/jsonpointer.pyR B s t EndOfListc B s e Z d Z d „ Z d „ Z RS( u+ Result of accessing element "-" of a list c C s
| | _ d S( N( t list_( t selfR
( ( s/ /usr/lib/python2.7/site-packages/jsonpointer.pyt __init__I s c C s% d j d | j j d t | j ƒ ƒ S( Nu {cls}({lst})t clst lst( t formatt __class__R t reprR
( R ( ( s/ /usr/lib/python2.7/site-packages/jsonpointer.pyt __repr__M s ( R R t __doc__R R ( ( ( s/ /usr/lib/python2.7/site-packages/jsonpointer.pyR F s c C s t | ƒ } | j | | ƒ S( un
Resolves pointer against doc and returns the referenced object
>>> obj = {"foo": {"anArray": [ {"prop": 44}], "another prop": {"baz": "A string" }}}
>>> resolve_pointer(obj, '') == obj
True
>>> resolve_pointer(obj, '/foo') == obj['foo']
True
>>> resolve_pointer(obj, '/foo/another%20prop') == obj['foo']['another prop']
True
>>> resolve_pointer(obj, '/foo/another%20prop/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
( t JsonPointert resolve( t doct pointert default( ( s/ /usr/lib/python2.7/site-packages/jsonpointer.pyt resolve_pointerU s c C s t | ƒ } | j | | | ƒ S( uV
Resolves 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%20another%20prop', 'added prop') == {'foo': {'another prop': {'baz': 'A string'}, 'yet another prop': 'added prop', 'anArray': [{'prop': 55}]}}
True
( R t set( R R t valuet inplace( ( s/ /usr/lib/python2.7/site-packages/jsonpointer.pyt set_pointerr s R c B s’ e Z d Z d „ Z d „ Z e d „ Z e Z e d „ Z d „ Z
d „ Z d „ Z d „ Z
e d „ ƒ Z d
„ Z d „ Z e d „ ƒ Z RS(
u= A JSON Pointer that can reference parts of an JSON document c C s™ | j d ƒ } | j d ƒ d k r3 t d ƒ ‚ n t t | ƒ } g | D] } | j d d ƒ ^ qI } g | D] } | j d d ƒ ^ qn } | | _ d S( Nu /i u u location must starts with /u ~1u ~0u ~( t splitt popR t mapR t replacet parts( R R R" t part( ( s/ /usr/lib/python2.7/site-packages/jsonpointer.pyR Œ s %%c C sZ | j s | d f Sx' | j d D] } | j | | ƒ } q! W| | j | | j d ƒ f S( u@ Resolves ptr until the last step, returns (sub-doc, last-step) iÿÿÿÿN( R" t Nonet walkt get_part( R R R# ( ( s/ /usr/lib/python2.7/site-packages/jsonpointer.pyt to_last— s
c C sX xQ | j D]F } y | j | | ƒ } Wq
t k
rO | t k rH ‚ qP | Sq
Xq
W| S( uB Resolves the pointer against doc and returns the referenced object( R" R% R t _nothing( R R R R# ( ( s/ /usr/lib/python2.7/site-packages/jsonpointer.pyR £ s
c C si t | j ƒ d k r. | r* t d ƒ ‚ n | S| sF t j | ƒ } n | j | ƒ \ } } | | | <| S( uH Resolve the pointer against the doc and replace the target with value. i u cannot set root in place( t lenR" R t copyt deepcopyR' ( R R R R t parentR# ( ( s/ /usr/lib/python2.7/site-packages/jsonpointer.pyR µ s
c C s” t | t ƒ r | St | t ƒ rg | d k r2 | St j t | ƒ ƒ s] t d | f ƒ ‚ n t | ƒ St | d ƒ rz | St d t | ƒ ƒ ‚ d S( u+ Returns the next step in the correct type u -u '%s' is not a valid list indexu __getitem__uQ Document '%s' does not support indexing, must be dict/list or support __getitem__N(
t
isinstanceR R t RE_ARRAY_INDEXt matcht strR t intt hasattrt type( R R R# ( ( s/ /usr/lib/python2.7/site-packages/jsonpointer.pyR&