changeset 25:28dc252c2300

Go back to the original slice semantics
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Fri, 16 Aug 2013 11:53:48 +0200
parents 64328843ba3b
children f0858a46b6b9
files jpath.py
diffstat 1 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/jpath.py	Fri Aug 16 10:46:38 2013 +0200
+++ b/jpath.py	Fri Aug 16 11:53:48 2013 +0200
@@ -193,9 +193,7 @@
         self.step = int(slice_step) if slice_step is not None else None
 
     def parse(self, tokens, data):
-        for item in data[self.start:self.end:self.step]:
-            for value in Token.apply(list(tokens), item):
-                yield value
+        return Token.apply(tokens, data[self.start:self.end:self.step])
 
 
 @Tokenizer.token
@@ -382,13 +380,13 @@
     >>> get_all('a..b', {'a': {'b': 3, 'c': {'b': 4}}})
     [3, 4]
     >>> get_all('[1:]', [1, 2, 3])
-    [2, 3]
+    [[2, 3]]
     >>> get_all('[:-1]', [1, 2, 3])
-    [1, 2]
+    [[1, 2]]
     >>> get_all('[::2]', [1, 2, 3, 4])
-    [1, 3]
+    [[1, 3]]
     >>> get_all('[::2][0]', [[1, 2], [3, 4], [5, 6]])
-    [1, 5]
+    [[1, 2]]
     >>> get_all('(x=1).y', [{'x':1, 'y':2}, {'x':0, 'y':3}, {'x':1, 'y':4}])
     [2, 4]
     >>> get_all('(x>0).y', [{'x':1, 'y':2}, {'x':0, 'y':3}, {'x':1, 'y':4}])