@@ -31,7 +31,7 @@ Using Dpath
3131
3232.. code-block :: python
3333
34- import dpath.util
34+ import dpath
3535
3636 Separators
3737==========
@@ -63,8 +63,8 @@ key '43' in the 'b' hash which is in the 'a' hash". That's easy.
6363
6464.. code-block :: pycon
6565
66- >>> help(dpath.util. get)
67- Help on function get in module dpath.util :
66+ >>> help(dpath.get)
67+ Help on function get in module dpath:
6868
6969 get(obj, glob, separator='/')
7070 Given an object which contains only one possible match for the given glob,
@@ -73,16 +73,16 @@ key '43' in the 'b' hash which is in the 'a' hash". That's easy.
7373 If more than one leaf matches the glob, ValueError is raised. If the glob is
7474 not found, KeyError is raised.
7575
76- >>> dpath.util. get(x, '/a/b/43')
76+ >>> dpath.get(x, '/a/b/43')
7777 30
7878
7979 Or you could say "Give me a new dictionary with the values of all
8080elements in ``x['a']['b'] `` where the key is equal to the glob ``'[cd]' ``. Okay.
8181
8282.. code-block :: pycon
8383
84- >>> help(dpath.util. search)
85- Help on function search in module dpath.util :
84+ >>> help(dpath.search)
85+ Help on function search in module dpath:
8686
8787 search(obj, glob, yielded=False)
8888 Given a path glob, return a dictionary containing all keys
@@ -96,7 +96,7 @@ elements in ``x['a']['b']`` where the key is equal to the glob ``'[cd]'``. Okay.
9696
9797.. code-block :: pycon
9898
99- >>> result = dpath.util. search(x, "a/b/[cd]")
99+ >>> result = dpath.search(x, "a/b/[cd]")
100100 >>> print(json.dumps(result, indent=4, sort_keys=True))
101101 {
102102 "a": {
@@ -116,7 +116,7 @@ not get a merged view?
116116
117117.. code-block :: pycon
118118
119- >>> for x in dpath.util. search(x, "a/b/[cd]", yielded=True): print(x)
119+ >>> for x in dpath.search(x, "a/b/[cd]", yielded=True): print(x)
120120 ...
121121 ('a/b/c', [])
122122 ('a/b/d', ['red', 'buggy', 'bumpers'])
@@ -126,16 +126,16 @@ don't care about the paths they were found at:
126126
127127.. code-block :: pycon
128128
129- >>> help(dpath.util. values)
130- Help on function values in module dpath.util :
129+ >>> help(dpath.values)
130+ Help on function values in module dpath:
131131
132132 values(obj, glob, separator='/', afilter=None, dirs=True)
133133 Given an object and a path glob, return an array of all values which match
134134 the glob. The arguments to this function are identical to those of search(),
135135 and it is primarily a shorthand for a list comprehension over a yielded
136136 search call.
137137
138- >>> dpath.util. values(x, '/a/b/d/*')
138+ >>> dpath.values(x, '/a/b/d/*')
139139 ['red', 'buggy', 'bumpers']
140140
141141 Example: Setting existing keys
@@ -146,14 +146,14 @@ value 'Waffles'.
146146
147147.. code-block :: pycon
148148
149- >>> help(dpath.util. set)
150- Help on function set in module dpath.util :
149+ >>> help(dpath.set)
150+ Help on function set in module dpath:
151151
152152 set(obj, glob, value)
153153 Given a path glob, set all existing elements in the document
154154 to the given value. Returns the number of elements changed.
155155
156- >>> dpath.util. set(x, 'a/b/[cd]', 'Waffles')
156+ >>> dpath.set(x, 'a/b/[cd]', 'Waffles')
157157 2
158158 >>> print(json.dumps(x, indent=4, sort_keys=True))
159159 {
@@ -176,8 +176,8 @@ necessary to get to the terminus.
176176
177177.. code-block :: pycon
178178
179- >>> help(dpath.util. new)
180- Help on function new in module dpath.util :
179+ >>> help(dpath.new)
180+ Help on function new in module dpath:
181181
182182 new(obj, path, value)
183183 Set the element at the terminus of path to value, and create
@@ -188,7 +188,7 @@ necessary to get to the terminus.
188188 characters in it, they will become part of the resulting
189189 keys
190190
191- >>> dpath.util. new(x, 'a/b/e/f/g', "Roffle")
191+ >>> dpath.new(x, 'a/b/e/f/g', "Roffle")
192192 >>> print(json.dumps(x, indent=4, sort_keys=True))
193193 {
194194 "a": {
@@ -212,8 +212,8 @@ object with None entries in order to make it big enough:
212212
213213.. code-block :: pycon
214214
215- >>> dpath.util. new(x, 'a/b/e/f/h', [])
216- >>> dpath.util. new(x, 'a/b/e/f/h/13', 'Wow this is a big array, it sure is lonely in here by myself')
215+ >>> dpath.new(x, 'a/b/e/f/h', [])
216+ >>> dpath.new(x, 'a/b/e/f/h/13', 'Wow this is a big array, it sure is lonely in here by myself')
217217 >>> print(json.dumps(x, indent=4, sort_keys=True))
218218 {
219219 "a": {
@@ -252,11 +252,11 @@ Handy!
252252Example: Deleting Existing Keys
253253===============================
254254
255- To delete keys in an object, use dpath.util. delete, which accepts the same globbing syntax as the other methods.
255+ To delete keys in an object, use dpath.delete, which accepts the same globbing syntax as the other methods.
256256
257257.. code-block :: pycon
258258
259- >>> help(dpath.util. delete)
259+ >>> help(dpath.delete)
260260
261261 delete(obj, glob, separator='/', afilter=None):
262262 Given a path glob, delete all elements that match the glob.
@@ -267,27 +267,26 @@ To delete keys in an object, use dpath.util.delete, which accepts the same globb
267267 Example: Merging
268268================
269269
270- Also, check out dpath.util. merge. The python dict update() method is
270+ Also, check out dpath.merge. The python dict update() method is
271271great and all but doesn't handle merging dictionaries deeply. This one
272272does.
273273
274274.. code-block :: pycon
275275
276- >>> help(dpath.util. merge)
277- Help on function merge in module dpath.util :
276+ >>> help(dpath.merge)
277+ Help on function merge in module dpath:
278278
279279 merge(dst, src, afilter=None, flags=4, _path='')
280280 Merge source into destination. Like dict.update() but performs
281281 deep merging.
282282
283- flags is an OR'ed combination of MERGE_ADDITIVE, MERGE_REPLACE
284- MERGE_TYPESAFE.
285- * MERGE_ADDITIVE : List objects are combined onto one long
283+ flags is an OR'ed combination of MergeType enum members.
284+ * ADDITIVE : List objects are combined onto one long
286285 list (NOT a set). This is the default flag.
287- * MERGE_REPLACE : Instead of combining list objects, when
286+ * REPLACE : Instead of combining list objects, when
288287 2 list objects are at an equal depth of merge, replace
289288 the destination with the source.
290- * MERGE_TYPESAFE : When 2 keys at equal levels are of different
289+ * TYPESAFE : When 2 keys at equal levels are of different
291290 types, raise a TypeError exception. By default, the source
292291 replaces the destination in this situation.
293292
@@ -312,7 +311,7 @@ does.
312311 "c": "RoffleWaffles"
313312 }
314313 }
315- >>> dpath.util. merge(x, y)
314+ >>> dpath.merge(x, y)
316315 >>> print(json.dumps(x, indent=4, sort_keys=True))
317316 {
318317 "a": {
@@ -392,7 +391,7 @@ them:
392391 ... return True
393392 ... return False
394393 ...
395- >>> result = dpath.util. search(x, '**', afilter=afilter)
394+ >>> result = dpath.search(x, '**', afilter=afilter)
396395 >>> print(json.dumps(result, indent=4, sort_keys=True))
397396 {
398397 "a": {
@@ -431,18 +430,18 @@ Separator got you down? Use lists as paths
431430
432431The default behavior in dpath is to assume that the path given is a string, which must be tokenized by splitting at the separator to yield a distinct set of path components against which dictionary keys can be individually glob tested. However, this presents a problem when you want to use paths that have a separator in their name; the tokenizer cannot properly understand what you mean by '/a/b/c' if it is possible for '/' to exist as a valid character in a key name.
433432
434- To get around this, you can sidestep the whole "filesystem path" style, and abandon the separator entirely, by using lists as paths. All of the methods in dpath.util. * support the use of a list instead of a string as a path. So for example:
433+ To get around this, you can sidestep the whole "filesystem path" style, and abandon the separator entirely, by using lists as paths. All of the methods in dpath.* support the use of a list instead of a string as a path. So for example:
435434
436435.. code-block :: python
437436
438437 >> > x = { ' a' : {' b/c' : 0 }}
439- >> > dpath.util. get([' a' , ' b/c' ])
438+ >> > dpath.get([' a' , ' b/c' ])
440439 0
441440
442441 dpath.segments : The Low-Level Backend
443442======================================
444443
445- dpath.util is where you want to spend your time: this library has the friendly
444+ dpath is where you want to spend your time: this library has the friendly
446445functions that will understand simple string globs, afilter functions, etc.
447446
448447dpath.segments is the backend pathing library. It passes around tuples of path
0 commit comments