Skip to content

Commit cd55cf0

Browse files
committed
removed tab
1 parent 63cbc3e commit cd55cf0

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

jsonpath_rw/jsonpath.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def id_pseudopath(self):
9696
"""
9797
try:
9898
pseudopath = Fields(unicode(self.value[auto_id_field]))
99-
except (TypeError, AttributeError, KeyError): # This may not be all the interesting exceptions
99+
except (TypeError, AttributeError, KeyError): # This may not be all the interesting exceptions
100100
pseudopath = self.path
101101

102102
if self.context:
@@ -393,7 +393,7 @@ def get_field_datum(self, datum, field):
393393
return AutoIdForDatum(datum)
394394
else:
395395
try:
396-
field_value = datum.value[field] # Do NOT use `val.get(field)` since that confuses None as a value and None due to `get`
396+
field_value = datum.value[field] # Do NOT use `val.get(field)` since that confuses None as a value and None due to `get`
397397
return DatumInContext(value=field_value, path=Fields(field), context=datum)
398398
except (TypeError, KeyError, AttributeError):
399399
return None
@@ -409,14 +409,14 @@ def reified_fields(self, datum):
409409
return ()
410410

411411
def find(self, datum):
412-
datum = DatumInContext.wrap(datum)
412+
datum = DatumInContext.wrap(datum)
413413

414414
return [field_datum
415415
for field_datum in [self.get_field_datum(datum, field) for field in self.reified_fields(datum)]
416416
if field_datum is not None]
417417

418418
def __str__(self):
419-
return unicode(self).encode('utf-8')
419+
return unicode(self).encode('utf-8')
420420

421421
def __unicode__(self):
422422
return ','.join(map(unicode, self.fields))
@@ -502,9 +502,9 @@ def __str__(self):
502502
if self.start == None and self.end == None and self.step == None:
503503
return '[*]'
504504
else:
505-
return '[%s%s%s]' % (self.start or '',
506-
':%d'%self.end if self.end else '',
507-
':%d'%self.step if self.step else '')
505+
return '[%s%s%s]' % (self.start or '',
506+
':%d' % self.end if self.end else '',
507+
':%d' % self.step if self.step else '')
508508

509509
def __repr__(self):
510510
return '%s(start=%r,end=%r,step=%r)' % (self.__class__.__name__, self.start, self.end, self.step)

tests/test_jsonpath.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import unicode_literals, print_function, absolute_import, division, generators, nested_scopes
22
import unittest
33

4-
from jsonpath_rw import jsonpath # For setting the global auto_id_field flag
4+
from jsonpath_rw import jsonpath # For setting the global auto_id_field flag
55

66
from jsonpath_rw.parser import parse
77
from jsonpath_rw.jsonpath import *
@@ -37,11 +37,11 @@ def test_DatumInContext_init(self):
3737
def test_DatumInContext_in_context(self):
3838

3939
assert (DatumInContext(3).in_context(path=Fields('foo'), context=DatumInContext('whatever'))
40-
==
40+
==
4141
DatumInContext(3, path=Fields('foo'), context=DatumInContext('whatever')))
4242

4343
assert (DatumInContext(3).in_context(path=Fields('foo'), context='whatever').in_context(path=Fields('baz'), context='whatever')
44-
==
44+
==
4545
DatumInContext(3).in_context(path=Fields('foo'), context=DatumInContext('whatever').in_context(path=Fields('baz'), context='whatever')))
4646

4747
# def test_AutoIdForDatum_pseudopath(self):
@@ -141,10 +141,10 @@ def test_slice_value(self):
141141

142142
# Funky slice hacks
143143
self.check_cases([
144-
('[*]', 1, [1]), # This is a funky hack
145-
('[0:]', 1, [1]), # This is a funky hack
146-
('[*]', {'foo':1}, [{'foo': 1}]), # This is a funky hack
147-
('[*].foo', {'foo':1}, [1]), # This is a funky hack
144+
('[*]', 1, [1]), # This is a funky hack
145+
('[0:]', 1, [1]), # This is a funky hack
146+
('[*]', {'foo':1}, [{'foo': 1}]), # This is a funky hack
147+
('[*].foo', {'foo':1}, [1]), # This is a funky hack
148148
])
149149

150150
def test_child_value(self):
@@ -154,8 +154,8 @@ def test_child_value(self):
154154

155155
def test_descendants_value(self):
156156
self.check_cases([
157-
('foo..baz', {'foo': {'baz': 1, 'bing': {'baz': 2}}}, [1, 2] ),
158-
('foo..baz', {'foo': [{'baz': 1}, {'baz': 2}]}, [1, 2] ),
157+
('foo..baz', {'foo': {'baz': 1, 'bing': {'baz': 2}}}, [1, 2]),
158+
('foo..baz', {'foo': [{'baz': 1}, {'baz': 2}]}, [1, 2]),
159159
])
160160

161161
def test_parent_value(self):
@@ -165,7 +165,7 @@ def test_parent_value(self):
165165
def test_hyphen_key(self):
166166
self.check_cases([('foo.bar-baz', {'foo': {'bar-baz': 3}}, [3]),
167167
('foo.[bar-baz,blah-blah]', {'foo': {'bar-baz': 3, 'blah-blah':5}},
168-
[3,5])])
168+
[3, 5])])
169169
self.assertRaises(JsonPathLexerError, self.check_cases,
170170
[('foo.-baz', {'foo': {'-baz': 8}}, [8])])
171171

@@ -229,7 +229,7 @@ def test_child_paths(self):
229229
('foo.baz.bizzle', {'foo': {'baz': {'bizzle': 5}}}, ['foo.baz.bizzle'])])
230230

231231
def test_descendants_paths(self):
232-
self.check_paths([('foo..baz', {'foo': {'baz': 1, 'bing': {'baz': 2}}}, ['foo.baz', 'foo.bing.baz'] )])
232+
self.check_paths([('foo..baz', {'foo': {'baz': 1, 'bing': {'baz': 2}}}, ['foo.baz', 'foo.bing.baz'])])
233233

234234

235235
#
@@ -240,23 +240,23 @@ def test_fields_auto_id(self):
240240
self.check_cases([ ('foo.id', {'foo': 'baz'}, ['foo']),
241241
('foo.id', {'foo': {'id': 'baz'}}, ['baz']),
242242
('foo,baz.id', {'foo': 1, 'baz': 2}, ['foo', 'baz']),
243-
('*.id',
243+
('*.id',
244244
{'foo':{'id': 1},
245245
'baz': 2},
246246
set(['1', 'baz'])) ])
247247

248248
def test_root_auto_id(self):
249249
jsonpath.auto_id_field = 'id'
250250
self.check_cases([
251-
('$.id', {'foo': 'baz'}, ['$']), # This is a wonky case that is not that interesting
252-
('foo.$.id', {'foo': 'baz', 'id': 'bizzle'}, ['bizzle']),
251+
('$.id', {'foo': 'baz'}, ['$']), # This is a wonky case that is not that interesting
252+
('foo.$.id', {'foo': 'baz', 'id': 'bizzle'}, ['bizzle']),
253253
('foo.$.baz.id', {'foo': 4, 'baz': 3}, ['baz']),
254254
])
255255

256256
def test_this_auto_id(self):
257257
jsonpath.auto_id_field = 'id'
258258
self.check_cases([
259-
('id', {'foo': 'baz'}, ['`this`']), # This is, again, a wonky case that is not that interesting
259+
('id', {'foo': 'baz'}, ['`this`']), # This is, again, a wonky case that is not that interesting
260260
('foo.`this`.id', {'foo': 'baz'}, ['foo']),
261261
('foo.`this`.baz.id', {'foo': {'baz': 3}}, ['foo.baz']),
262262
])
@@ -281,12 +281,12 @@ def test_child_auto_id(self):
281281

282282
def test_descendants_auto_id(self):
283283
jsonpath.auto_id_field = "id"
284-
self.check_cases([('foo..baz.id',
284+
self.check_cases([('foo..baz.id',
285285
{'foo': {
286-
'baz': 1,
286+
'baz': 1,
287287
'bing': {
288288
'baz': 2
289289
}
290290
} },
291-
['foo.baz',
292-
'foo.bing.baz'] )])
291+
['foo.baz',
292+
'foo.bing.baz'])])

0 commit comments

Comments
 (0)