Skip to content

Commit 0fb3230

Browse files
committed
Code cleanup
1 parent b93282a commit 0fb3230

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

jsonpath_ng/jsonpath.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import unicode_literals, print_function, absolute_import, division, generators, nested_scopes
22
import logging
33
from itertools import * # noqa
4-
from .exceptions import JSONPathError
54

65
# Get logger name
76
logger = logging.getLogger(__name__)
@@ -739,7 +738,7 @@ def find(self, datum):
739738

740739
# Some iterators do not support slicing but we can still
741740
# at least work for '*'
742-
if self.start == None and self.end == None and self.step == None:
741+
if self.start is None and self.end is None and self.step is None:
743742
return [DatumInContext(datum.value[i], path=Index(i), context=datum) for i in range(0, len(datum.value))]
744743
else:
745744
return [DatumInContext(datum.value[i], path=Index(i), context=datum) for i in range(0, len(datum.value))[self.start:self.end:self.step]]
@@ -762,7 +761,7 @@ def filter(self, fn, data):
762761
return data
763762

764763
def __str__(self):
765-
if self.start == None and self.end == None and self.step == None:
764+
if self.start is None and self.end is None and self.step is None:
766765
return '[*]'
767766
else:
768767
return '[%s%s%s]' % (self.start or '',

jsonpath_ng/lexer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class JsonPathLexer(object):
1616

1717
def __init__(self, debug=False):
1818
self.debug = debug
19-
if self.__doc__ == None:
19+
if self.__doc__ is None:
2020
raise JsonPathLexerError('Docstrings have been removed! By design of PLY, jsonpath-rw requires docstrings. You must not use PYTHONOPTIMIZE=2 or python -OO.')
2121

2222
def tokenize(self, string):
@@ -31,7 +31,8 @@ def tokenize(self, string):
3131

3232
while True:
3333
t = new_lexer.token()
34-
if t is None: break
34+
if t is None:
35+
break
3536
t.col = t.lexpos - new_lexer.latest_newline
3637
yield t
3738

jsonpath_ng/parser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
generators,
66
nested_scopes,
77
)
8+
import logging
89
import sys
910
import os.path
1011

@@ -55,7 +56,8 @@ def parse_token_stream(self, token_iterator, start_symbol='jsonpath'):
5556

5657
parsing_table_module = '_'.join([module_name, start_symbol, 'parsetab'])
5758

58-
# And we regenerate the parse table every time; it doesn't actually take that long!
59+
# And we regenerate the parse table every time;
60+
# it doesn't actually take that long!
5961
new_parser = ply.yacc.yacc(module=self,
6062
debug=self.debug,
6163
tabmodule = parsing_table_module,

0 commit comments

Comments
 (0)