Skip to content

Commit b93282a

Browse files
committed
Remove dependency on six
1 parent c60baa4 commit b93282a

File tree

6 files changed

+6
-11
lines changed

6 files changed

+6
-11
lines changed

jsonpath_ng/ext/filter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import operator
1515
import re
16-
from six import moves
1716

1817
from .. import JSONPath, DatumInContext, Index
1918

@@ -49,7 +48,7 @@ def find(self, datum):
4948
return []
5049

5150
return [DatumInContext(datum.value[i], path=Index(i), context=datum)
52-
for i in moves.range(0, len(datum.value))
51+
for i in range(0, len(datum.value))
5352
if (len(self.expressions) ==
5453
len(list(filter(lambda x: x.find(datum.value[i]),
5554
self.expressions))))]

jsonpath_ng/jsonpath.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from __future__ import unicode_literals, print_function, absolute_import, division, generators, nested_scopes
22
import logging
3-
import six
4-
from six.moves import xrange
53
from itertools import * # noqa
64
from .exceptions import JSONPathError
75

@@ -736,13 +734,13 @@ def find(self, datum):
736734
return []
737735
# Here's the hack. If it is a dictionary or some kind of constant,
738736
# put it in a single-element list
739-
if (isinstance(datum.value, dict) or isinstance(datum.value, six.integer_types) or isinstance(datum.value, six.string_types)):
737+
if (isinstance(datum.value, dict) or isinstance(datum.value, int) or isinstance(datum.value, str)):
740738
return self.find(DatumInContext([datum.value], path=datum.path, context=datum.context))
741739

742740
# Some iterators do not support slicing but we can still
743741
# at least work for '*'
744742
if self.start == None and self.end == None and self.step == None:
745-
return [DatumInContext(datum.value[i], path=Index(i), context=datum) for i in xrange(0, len(datum.value))]
743+
return [DatumInContext(datum.value[i], path=Index(i), context=datum) for i in range(0, len(datum.value))]
746744
else:
747745
return [DatumInContext(datum.value[i], path=Index(i), context=datum) for i in range(0, len(datum.value))[self.start:self.end:self.step]]
748746

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
ply
2-
six
32
setuptools>=18.5

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
test_suite='tests',
2525
install_requires=[
26-
'ply', 'six'
26+
'ply'
2727
],
2828
classifiers=[
2929
'Development Status :: 5 - Production/Stable',

tests/test_jsonpath.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def test_index_value(self):
136136

137137
def test_slice_value(self):
138138
self.check_cases([('[*]', [1, 2, 3], [1, 2, 3]),
139-
('[*]', xrange(1, 4), [1, 2, 3]),
139+
('[*]', range(1, 4), [1, 2, 3]),
140140
('[1:]', [1, 2, 3, 4], [2, 3, 4]),
141141
('[:2]', [1, 2, 3, 4], [1, 2])])
142142

tests/test_jsonpath_rw_ext.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
from jsonpath_ng import jsonpath # For setting the global auto_id_field flag
2323
from oslotest import base
24-
from six import moves
2524

2625
from jsonpath_ng.ext import parser
2726

@@ -416,7 +415,7 @@ def test_index_value(self):
416415

417416
def test_slice_value(self):
418417
self.check_cases([('[*]', [1, 2, 3], [1, 2, 3]),
419-
('[*]', moves.range(1, 4), [1, 2, 3]),
418+
('[*]', range(1, 4), [1, 2, 3]),
420419
('[1:]', [1, 2, 3, 4], [2, 3, 4]),
421420
('[:2]', [1, 2, 3, 4], [1, 2])])
422421

0 commit comments

Comments
 (0)