Merge branch 'computable_inputs' into computable_inputs_python

This commit is contained in:
Jedrzej Nowak 2015-12-07 15:17:03 +01:00
commit 698e9f069f
2 changed files with 9 additions and 8 deletions

View File

@ -33,10 +33,13 @@ class LuaProcessor(ComputableInputProcessor):
self.lua = LuaRuntime()
self.lua.execute(_LUA_HELPERS)
def check_funct(self, funct):
def check_funct(self, funct, computable_type):
# dummy insert function start / end
if not funct.startswith('function') \
and not funct.endswith('end'):
if computable_type == ComputablePassedTypes.full.name:
make_arr = 'local res = make_arr(data)'
funct = "%s\n%s" % (make_arr, funct)
return 'function (data, resource_name) %s end' % funct
return funct
@ -50,6 +53,6 @@ class LuaProcessor(ComputableInputProcessor):
else:
lua_data = data
funct = self.check_funct(funct)
funct = self.check_funct(funct, computable_type)
funct_lua = self.lua.eval(funct)
return funct_lua(lua_data, resource_name)

View File

@ -166,8 +166,7 @@ def test_lua_join_different_values(rk):
'inputs': {'input': None}})
lua_funct = """
local l = make_arr(data)
return l["r1"]["input1"] .. "@" .. l["r2"]["input2"]"""
return res["r1"]["input1"] .. "@" .. res["r2"]["input2"]"""
r3.meta_inputs['input']['computable'] = {"func": lua_funct,
'lang': 'lua',
@ -204,8 +203,7 @@ def test_lua_join_replace_in_lua(rk):
'inputs': {'input': None}})
lua_funct = """
local l = make_arr(data)
return l["r1"]["input1"] .. "@" .. l["r2"]["input2"]
return res["r1"]["input1"] .. "@" .. res["r2"]["input2"]
"""
r3.meta_inputs['input']['computable'] = {"func": lua_funct,
@ -244,8 +242,8 @@ def test_lua_join_self_computable(rk):
'input2': 'foo',
'input3': None}})
lua_funct = """local l = make_arr(data)
return resource_name .. l["r1"]["input2"] .. l["r1"]["input1"]
lua_funct = """
return resource_name .. res["r1"]["input2"] .. res["r1"]["input1"]
"""
r1.meta_inputs['input3']['computable'] = {'func': lua_funct,