diff options
author | Kenn Knowles <kenn.knowles@gmail.com> | 2013-05-29 11:17:05 -0400 |
---|---|---|
committer | Kenn Knowles <kenn.knowles@gmail.com> | 2013-05-29 11:17:05 -0400 |
commit | c46d04f4099fbbf55bf4194932cdc09d5a50827b (patch) | |
tree | cff7a9f5a08faad2993a545471a262462c3f47e2 | |
parent | 9a05daf81960092af081383d60269f2df221c8d3 (diff) | |
download | jsonpath-rw-c46d04f4099fbbf55bf4194932cdc09d5a50827b.tar.gz |
Raise an informative error when docstrings have been stripped
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | jsonpath_rw/lexer.py | 2 | ||||
-rw-r--r-- | jsonpath_rw/parser.py | 7 |
3 files changed, 10 insertions, 0 deletions
@@ -1,4 +1,5 @@ *.pyc +*.pyo *~ # Emacs diff --git a/jsonpath_rw/lexer.py b/jsonpath_rw/lexer.py index 35a4305..40ae898 100644 --- a/jsonpath_rw/lexer.py +++ b/jsonpath_rw/lexer.py @@ -13,6 +13,8 @@ class JsonPathLexer(object): def __init__(self, debug=False): self.debug = debug + if self.__doc__ == None: + raise Exception('Docstrings have been removed! By design of PLY, jsonpath-rw requires docstrings. You must not use PYTHONOPTIMIZE=2 or python -OO.') def tokenize(self, string): ''' diff --git a/jsonpath_rw/parser.py b/jsonpath_rw/parser.py index 85d05d9..21bd5d3 100644 --- a/jsonpath_rw/parser.py +++ b/jsonpath_rw/parser.py @@ -14,9 +14,16 @@ def parse(string): return JsonPathParser().parse(string) class JsonPathParser(object): + ''' + An LALR-parser for JsonPath + ''' + tokens = JsonPathLexer.tokens def __init__(self, debug=False, lexer_class=None): + if self.__doc__ == None: + raise Exception('Docstrings have been removed! By design of PLY, jsonpath-rw requires docstrings. You must not use PYTHONOPTIMIZE=2 or python -OO.') + self.debug = debug self.lexer_class = lexer_class or JsonPathLexer # Crufty but works around statefulness in PLY |