本文整理汇总了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