当前位置: 首页>>代码示例>>Python>>正文


Python Object.val_type方法代码示例

本文整理汇总了Python中Object.Object.val_type方法的典型用法代码示例。如果您正苦于以下问题:Python Object.val_type方法的具体用法?Python Object.val_type怎么用?Python Object.val_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Object.Object的用法示例。


在下文中一共展示了Object.val_type方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: val_root

# 需要导入模块: from Object import Object [as 别名]
# 或者: from Object.Object import val_type [as 别名]
def val_root(tarname, target, isroot, list_obj, list_rel, rootobj, rootrel):
    err_str = ""
    war_str = ""
    # Type checking
    Type = Object.val_type(tarname, target)
    if Type[1]:
        err_str += Type[0]
    else:
        if "nature" not in target.keys() or not target["nature"]:
            err_str += "Error 01: the field [nature] is not defined in the object " + tarname + "!\n"
        elif target["nature"] != "object":
            err_str += "Error 05:the nature of object " + tarname + " is not correct!\n"
        if "extends" in target.keys() and target["extends"]:
            if target["extends"] not in list_obj and "Error 02" not in list_obj:
                err_str += "Error 03: the object " + target["extends"]
                err_str += "extended in the root file is not defined !\n"
            if "objects" in target.keys():
                war_str += 'Warning 03: "objects" in object ' + tarname
                war_str += " will be overriden by these of object " + target["extends"]
                war_str += " as " + tarname + "extends" + target["extends"] + "\n"
        if "objects" in target.keys() and target["objects"]:
            for key in target["objects"].keys():
                # with below, we can check "Error 07" at the different levels
                if key in list_obj:
                    err_str += "Error 07:Redundant definition of object " + key + "!\n"
                else:
                    list_obj.append(key)
                    rootobj.append(key)
                valstr = val_root(key, target["objects"][key], False, list_obj, list_rel, rootobj, rootrel)
                err_str += valstr[0]
                war_str += valstr[1]
        if isroot and "relations" in target.keys() and target["relations"]:
            for key in target["relations"].keys():
                rootrel.append(key)
                # Type checking
                Type1 = Object.val_type(tarname + "[relations][" + key + "]", target["relations"][key])
                if Type1[1]:
                    err_str += Type1[0]
                else:
                    if "nature" not in target["relations"][key]:
                        err_str += "Error 01: the field [nature] is not defined in root[relations]" + key + "]\n"
                    elif target["relations"][key]["nature"] != "relation":
                        err_str += "Error 05:the nature of" + tarname
                        err_str += "[relations][" + key + "] is not correct!\n"
                    if "from" not in target["relations"][key] or target["relations"][key]["from"] == []:
                        err_str += "Error 01: the field [from] is not defined in "
                        err_str += tarname + "[relations][" + key + "]\n"
                    else:
                        for fr in target["relations"][key]["from"]:
                            if fr not in list_obj:
                                err_str += "Error 03: the object " + fr + " in the field "
                                err_str += tarname + "[relations][" + key + "][from] is not defined !\n"
                    if "to" not in target["relations"][key] or target["relations"][key]["to"] == []:
                        err_str += "Error 01: the field [to] is not defined in "
                        err_str += tarname + "[relations][" + key + "]\n"
                    else:
                        for fr in target["relations"][key]["to"]:
                            if fr not in list_obj:
                                err_str += "Error 03: the object " + fr + " in the field "
                                err_str += tarname + "[relations][" + key + "][to] is not defined!\n"
                    if "extends" in target["relations"][key] and target["relations"][key]["extends"]:
                        if target["relations"][key]["extends"] not in list_rel and "Error 02" not in list_obj:
                            err_str += "Error 04: the relation " + target["relations"][key]["extends"]
                            err_str += " is not defined !\n"
                    elif "directional" not in target["relations"][key]:
                        err_str += "Error 01: the field [directional] is not defined in "
                        err_str += tarname + "[relations][" + key + "]\n"
        if "library" in target.keys() and target["library"] and not isroot:
            war_str += "Warning 02:Detect of a library member in " + tarname
            war_str += ",but " + tarname + " is not the root object\n"
    return err_str, war_str
开发者ID:GiorgosPa,项目名称:Rauzy-language,代码行数:73,代码来源:Rauzy.py


注:本文中的Object.Object.val_type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。