parent functions removed, root function finalized
This commit is contained in:
parent
0f5d814669
commit
df29ef019a
@ -13,6 +13,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"name" : "Env",
|
"name" : "Env",
|
||||||
|
"helper":{
|
||||||
|
"num" : 2
|
||||||
|
},
|
||||||
"services" :
|
"services" :
|
||||||
[{
|
[{
|
||||||
"ServiceName" : "service1",
|
"ServiceName" : "service1",
|
||||||
|
@ -17,6 +17,7 @@ import random
|
|||||||
import types
|
import types
|
||||||
import itertools
|
import itertools
|
||||||
from yaql.context import EvalArg, ContextAware
|
from yaql.context import EvalArg, ContextAware
|
||||||
|
from yaql.utils import limit
|
||||||
|
|
||||||
|
|
||||||
def join(self, others, join_predicate, composer):
|
def join(self, others, join_predicate, composer):
|
||||||
@ -60,7 +61,7 @@ def take_while(self, predicate):
|
|||||||
|
|
||||||
@EvalArg('self', types.GeneratorType)
|
@EvalArg('self', types.GeneratorType)
|
||||||
def _list(self):
|
def _list(self):
|
||||||
return list(self)
|
return limit(self)
|
||||||
|
|
||||||
|
|
||||||
@ContextAware()
|
@ContextAware()
|
||||||
@ -96,7 +97,7 @@ def _as(self, context, *tuples):
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
@ContextAware()
|
@ContextAware()
|
||||||
def root(context, func):
|
def root(context):
|
||||||
def get_not_null_data(context):
|
def get_not_null_data(context):
|
||||||
if context.parent_context:
|
if context.parent_context:
|
||||||
data = get_not_null_data(context.parent_context)
|
data = get_not_null_data(context.parent_context)
|
||||||
@ -104,8 +105,7 @@ def root(context, func):
|
|||||||
return data
|
return data
|
||||||
return context.data
|
return context.data
|
||||||
first_data = get_not_null_data(context)
|
first_data = get_not_null_data(context)
|
||||||
context.data = first_data
|
return first_data.get('$')
|
||||||
return func()
|
|
||||||
|
|
||||||
|
|
||||||
def add_to_context(context):
|
def add_to_context(context):
|
||||||
@ -117,7 +117,5 @@ def add_to_context(context):
|
|||||||
context.register_function(rand, 'random')
|
context.register_function(rand, 'random')
|
||||||
context.register_function(_list, 'list')
|
context.register_function(_list, 'list')
|
||||||
context.register_function(take_while, 'takeWhile')
|
context.register_function(take_while, 'takeWhile')
|
||||||
context.register_function(parent, 'parent')
|
|
||||||
context.register_function(direct_parent, 'parent')
|
|
||||||
context.register_function(root, 'root')
|
context.register_function(root, 'root')
|
||||||
context.register_function(_as, 'as')
|
context.register_function(_as, 'as')
|
||||||
|
Loading…
Reference in New Issue
Block a user