def is_situation3_call(node_call, list_import, list_white,
                       list_var_decl_in_method, list_method_decl_in_method, listVarInClass, list_method_in_class, list_builtin, list_class):
    import ast
    objName = ""
    apiName = ""
    if isinstance(node_call.func, ast.Name):
        # print("zz1")
        objName = ""
        apiName = node_call.func.id
        # print("methodCall1:" + objName + "\t" + apiName)
    elif isinstance(node_call.func, ast.Attribute):
        # print("zz2")
        func = node_call.func
        if hasattr(func, "value"):
            if isinstance(func.value, ast.Str):
                objName = "Str"
                apiName = func.attr
                # print("methodCall2:" + objName + "\t" + apiName)
            elif isinstance(func.value, ast.Name):
                objName = func.value.id
                apiName = func.attr
                # print("methodCall3:" + objName + "\t" + apiName)
            elif isinstance(func.value, ast.Call):
                for nodetemp in ast.walk(func.value):
                    if isinstance(nodetemp, ast.Name):
                        objName = str(nodetemp.id)
                apiName = func.attr
                # print("kkk1:" + objName+"\t"+apiName)
            elif isinstance(func.value, ast.Attribute):
                for nodetemp in ast.walk(func.value):
                    if isinstance(nodetemp, ast.Name):
                        objName = str(nodetemp.id)
                apiName = func.attr
                # print("kkk2:" + objName+"\t"+apiName)
            elif isinstance(func.value, ast.Subscript):
                for nodetemp in ast.walk(func.value):
                    if isinstance(nodetemp, ast.Name):
                        objName = str(nodetemp.id)
                apiName = func.attr
            else:
                errorMesage = "func attr unknow"
                # print("else1")
                return errorMesage, False
    else:
        errorMesage = "nodecall attr unknow"
        # print("else2")
        return errorMesage, False
    #print("ttt:" + objName + "\t" + apiName)
    # if apiName in listMethodDecl:
    #     return False
    # if objName == "self":
    #     print("selfError")
    #     return False
    if objName == "":
        if apiName in list_class:
            errorMesage = "other class in same file:" + apiName
            return errorMesage, False
        if apiName not in list_builtin or apiName not in list_method_decl_in_method or apiName not in list_method_in_class:
            #print(list_import)
            for ll in list_import:
                if str(ll).endswith(apiName):
                    topLib = ll.split(".")[0]
                    if topLib not in list_white:
                        errorMesage = "api not in first or third Lib:" + apiName
                        return errorMesage, False
    elif objName=="self":
        return "ok3",True
        # if apiName not in listMethodDeclInMethod and apiName not in list_method_in_class:
        #     errorMesage = "api not define in this class:self." + apiName
        #     return errorMesage,False
    else:
        for ll in list_import:
            if str(ll).endswith(objName):
                topLib = ll.split(".")[0]
                if topLib not in list_white:
                    errorMesage = "obj api not in first or third Lib:" + topLib+"\t"+objName + "\t" + apiName
                    return errorMesage, False

    # if objName not in listWhite:
    #     return False
    # for l in listWhite:
    #     if str(l).endswith(objName):
    #         if str(l).startswith(".") or str(l) in listPackageInProject:
    #             return False
    errorMesage = "ok3"
    return errorMesage,True







def situation3(func_def, list_import, list_white, list_var_class, list_method_class, list_builtin, list_class):
    import ast
    def get_pre_define_method_in_method(func_def):
        listtot = []
        for node in ast.walk(func_def):
            if isinstance(node, ast.FunctionDef):
                listtot.append(str(node.name))
        return listtot

    def get_pre_define_in_method(funcDef):
        listtot = []
        for arg in funcDef.args.args:
            listtot.append(arg.arg)
        for node in ast.walk(funcDef):
            if isinstance(node, ast.Assign):
                for name in node.targets:
                    if isinstance(name, ast.Name):
                        listtot.append(name.id)
        return listtot

    list_pre_define = get_pre_define_in_method(func_def)
    list_pre_define_method = get_pre_define_method_in_method(func_def)
    for node in ast.walk(func_def):
        if isinstance(node, ast.Call):
            #print("zzzzzz")
            error_message, isT = is_situation3_call(node, list_import, list_white, list_pre_define, list_pre_define_method, list_var_class, list_method_class, list_builtin, list_class)
            #print(isT)
            if not isT:
                return error_message, False

    #print("zzzzzz")
    error_message="ok3"
    return error_message, True