Skip to content

Commit 92b604d

Browse files
committed
Merge branch 'master' into feature/cleanup
2 parents 7eadc11 + 3572db5 commit 92b604d

6 files changed

Lines changed: 100 additions & 97 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
uses: loopwerk/tag-changelog@v1
4747
with:
4848
token: ${{ secrets.GITHUB_TOKEN }}
49+
config_file: .github/tag-changelog-config.js
4950

5051
- name: PyPI Deployment
5152
uses: casperdcl/deploy-pypi@v2

MAINTAINERS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ There are several individuals in the community who have taken an active role in
1010
Where and How do we communicate
1111
===============================
1212

13-
The dpath maintainers communcate in 3 primary ways:
13+
The dpath maintainers communicate in 3 primary ways:
1414

1515
1. Email, directly to each other.
1616
2. Github via issue and pull request comments

README.rst

Lines changed: 87 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ Suppose we have a dictionary like this:
4949
x = {
5050
"a": {
5151
"b": {
52-
"3": 2,
53-
"43": 30,
54-
"c": [],
55-
"d": ['red', 'buggy', 'bumpers'],
52+
"3": 2,
53+
"43": 30,
54+
"c": [],
55+
"d": ['red', 'buggy', 'bumpers'],
5656
}
5757
}
5858
}
@@ -96,26 +96,26 @@ elements in ``x['a']['b']`` where the key is equal to the glob ``'[cd]'``. Okay.
9696
.. code-block:: pycon
9797
9898
>>> result = dpath.util.search(x, "a/b/[cd]")
99-
>>> print json.dumps(result, indent=4, sort_keys=True)
99+
>>> print(json.dumps(result, indent=4, sort_keys=True))
100100
{
101-
"a": {
102-
"b": {
103-
"c": [],
104-
"d": [
105-
"red",
106-
"buggy",
107-
"bumpers"
108-
]
101+
"a": {
102+
"b": {
103+
"c": [],
104+
"d": [
105+
"red",
106+
"buggy",
107+
"bumpers"
108+
]
109+
}
109110
}
110111
}
111-
}
112112
113113
... Wow that was easy. What if I want to iterate over the results, and
114114
not get a merged view?
115115

116116
.. code-block:: pycon
117117
118-
>>> for x in dpath.util.search(x, "a/b/[cd]", yielded=True): print x
118+
>>> for x in dpath.util.search(x, "a/b/[cd]", yielded=True): print(x)
119119
...
120120
('a/b/c', [])
121121
('a/b/d', ['red', 'buggy', 'bumpers'])
@@ -154,7 +154,7 @@ value 'Waffles'.
154154
155155
>>> dpath.util.set(x, 'a/b/[cd]', 'Waffles')
156156
2
157-
>>> print json.dumps(x, indent=4, sort_keys=True)
157+
>>> print(json.dumps(x, indent=4, sort_keys=True))
158158
{
159159
"a": {
160160
"b": {
@@ -188,7 +188,7 @@ necessary to get to the terminus.
188188
keys
189189
190190
>>> dpath.util.new(x, 'a/b/e/f/g', "Roffle")
191-
>>> print json.dumps(x, indent=4, sort_keys=True)
191+
>>> print(json.dumps(x, indent=4, sort_keys=True))
192192
{
193193
"a": {
194194
"b": {
@@ -213,7 +213,7 @@ object with None entries in order to make it big enough:
213213
214214
>>> dpath.util.new(x, 'a/b/e/f/h', [])
215215
>>> dpath.util.new(x, 'a/b/e/f/h/13', 'Wow this is a big array, it sure is lonely in here by myself')
216-
>>> print json.dumps(x, indent=4, sort_keys=True)
216+
>>> print(json.dumps(x, indent=4, sort_keys=True))
217217
{
218218
"a": {
219219
"b": {
@@ -290,59 +290,59 @@ does.
290290
replaces the destination in this situation.
291291
292292
>>> y = {'a': {'b': { 'e': {'f': {'h': [None, 0, 1, None, 13, 14]}}}, 'c': 'RoffleWaffles'}}
293-
>>> print json.dumps(y, indent=4, sort_keys=True)
293+
>>> print(json.dumps(y, indent=4, sort_keys=True))
294294
{
295-
"a": {
296-
"b": {
297-
"e": {
298-
"f": {
299-
"h": [
300-
null,
301-
0,
302-
1,
303-
null,
304-
13,
305-
14
306-
]
307-
}
295+
"a": {
296+
"b": {
297+
"e": {
298+
"f": {
299+
"h": [
300+
null,
301+
0,
302+
1,
303+
null,
304+
13,
305+
14
306+
]
307+
}
308+
}
309+
},
310+
"c": "RoffleWaffles"
308311
}
309-
},
310-
"c": "RoffleWaffles"
311-
}
312312
}
313313
>>> dpath.util.merge(x, y)
314-
>>> print json.dumps(x, indent=4, sort_keys=True)
314+
>>> print(json.dumps(x, indent=4, sort_keys=True))
315315
{
316-
"a": {
317-
"b": {
318-
"3": 2,
319-
"43": 30,
320-
"c": "Waffles",
321-
"d": "Waffles",
322-
"e": {
323-
"f": {
324-
"g": "Roffle",
325-
"h": [
326-
null,
327-
0,
328-
1,
329-
null,
330-
13,
331-
14,
332-
null,
333-
null,
334-
null,
335-
null,
336-
null,
337-
null,
338-
null,
339-
"Wow this is a big array, it sure is lonely in here by myself"
340-
]
341-
}
316+
"a": {
317+
"b": {
318+
"3": 2,
319+
"43": 30,
320+
"c": "Waffles",
321+
"d": "Waffles",
322+
"e": {
323+
"f": {
324+
"g": "Roffle",
325+
"h": [
326+
null,
327+
0,
328+
1,
329+
null,
330+
13,
331+
14,
332+
null,
333+
null,
334+
null,
335+
null,
336+
null,
337+
null,
338+
null,
339+
"Wow this is a big array, it sure is lonely in here by myself"
340+
]
341+
}
342+
}
343+
},
344+
"c": "RoffleWaffles"
342345
}
343-
},
344-
"c": "RoffleWaffles"
345-
}
346346
}
347347
348348
Now that's handy. You shouldn't try to use this as a replacement for the
@@ -369,41 +369,41 @@ them:
369369

370370
.. code-block:: pycon
371371
372-
>>> print json.dumps(x, indent=4, sort_keys=True)
372+
>>> print(json.dumps(x, indent=4, sort_keys=True))
373373
{
374-
"a": {
375-
"b": {
376-
"3": 2,
377-
"43": 30,
378-
"c": "Waffles",
379-
"d": "Waffles",
380-
"e": {
381-
"f": {
382-
"g": "Roffle"
374+
"a": {
375+
"b": {
376+
"3": 2,
377+
"43": 30,
378+
"c": "Waffles",
379+
"d": "Waffles",
380+
"e": {
381+
"f": {
382+
"g": "Roffle"
383+
}
384+
}
383385
}
384386
}
385-
}
386-
}
387387
}
388388
>>> def afilter(x):
389389
... if "ffle" in str(x):
390390
... return True
391391
... return False
392392
...
393393
>>> result = dpath.util.search(x, '**', afilter=afilter)
394-
>>> print json.dumps(result, indent=4, sort_keys=True)
394+
>>> print(json.dumps(result, indent=4, sort_keys=True))
395395
{
396-
"a": {
397-
"b": {
398-
"c": "Waffles",
399-
"d": "Waffles",
400-
"e": {
401-
"f": {
402-
"g": "Roffle"
396+
"a": {
397+
"b": {
398+
"c": "Waffles",
399+
"d": "Waffles",
400+
"e": {
401+
"f": {
402+
"g": "Roffle"
403+
}
404+
}
403405
}
404406
}
405-
}
406-
}
407407
}
408408
409409
Obviously filtering functions can perform more advanced tests (regular

dpath/options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
ALLOW_EMPTY_STRING_KEYS = False
2+
CONVERT_INT_LIKE_SEGMENTS = True

dpath/util.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@ def _split_path(path: str, separator: str) -> Union[List[PathSegment], PathSegme
6060
else:
6161
split_segments = path.lstrip(separator).split(separator)
6262

63-
# Attempt to convert integer segments into actual integers.
64-
final = []
65-
for segment in split_segments:
66-
try:
67-
final.append(int(segment))
68-
except:
69-
final.append(segment)
70-
split_segments = final
63+
if options.CONVERT_INT_LIKE_SEGMENTS:
64+
# Attempt to convert integer segments into actual integers.
65+
final = []
66+
for segment in split_segments:
67+
try:
68+
final.append(int(segment))
69+
except:
70+
final.append(segment)
71+
split_segments = final
7172

7273
return split_segments
7374

dpath/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = "2.0.4"
1+
VERSION = "2.0.6"

0 commit comments

Comments
 (0)