示例#1
0
 def curried(code, output, error):
     tree = ast.parse(code)
     defs = ast.find(
         tree,
         lambda x: x["_astname"] == "FunctionDef" and x["name"] == func)
     if len(defs) > 0:
         return True
     else:
         return "There is no definition for the function <tt><b>" + func + "</b></tt> in your code"
示例#2
0
 def curried(code, output, error):
     tree = ast.parse(code)
     defs = ast.find(
         tree,
         lambda x: x["_astname"] == "FunctionDef" and x["name"] == func)
     if len(defs) > 0:
         nArgs = len(defs[0]['args']['args'])
         if nArgs == arity:
             return True
         else:
             return "The function <tt><b>" + func + "</b></tt> should take <b>" + str(
                 arity) + "</b> arguments not <b>" + str(nArgs) + "</b>"
     else:
         return "There is no definition for the function <tt><b>" + func + "</b></tt> in your code"
示例#3
0
 def hasSyntaxNode(code, output, error):
     tree = ast.parse(code)
     return len(ast.find(tree, lambda x: x["_astname"] == node)) > 0
示例#4
0
 def checkImport(code, output, error):
     tree = ast.parse(code)
     result = ast.find(
         tree, lambda x: x['_astname'] == 'alias' and x['name'] == mod)
     return len(result) > 0
示例#5
0
 def curried(code, output, error):
     tree = ast.parse(code)
     r = ast.find(tree, test)
     return len(r) > 0