本文整理汇总了Python中Object.Object.flatten方法的典型用法代码示例。如果您正苦于以下问题:Python Object.flatten方法的具体用法?Python Object.flatten怎么用?Python Object.flatten使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Object.Object
的用法示例。
在下文中一共展示了Object.flatten方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse
# 需要导入模块: from Object import Object [as 别名]
# 或者: from Object.Object import flatten [as 别名]
def parse(fl):
Object.folder = ""
Object.model = False
Relation.model = False
model = None
# open and then read the file
err_str = ""
war_str = ""
list_obj = []
list_rel = []
with open(fl) as f:
# with object_pairs_hook method, we can check "Error 07" at the same level
target = json.loads(f.read())
if "library" in target.keys():
lib = ""
folders = fl.split("/")
for i in range(0, len(folders) - 1):
lib += folders[i] + "/"
lib += target["library"]
# To handle all the errors and warnings in "library" json file
valstr = Object.readLibrary(lib)
err_str += valstr[0]
war_str += valstr[1]
list_obj = valstr[2]
list_rel = valstr[3]
# To handle all the errors and warnings in "root" json file
rootobj = []
rootrel = []
valstr2 = val_root(fl, target, True, list_obj, list_rel, rootobj, rootrel)
err_str += valstr2[0]
war_str += valstr2[1]
if err_str:
print err_str
else:
Object.model = True
Relation.model = True
model = Object(fl.split(".")[0], target)
Object.flatten(rootobj, rootrel)
if war_str:
print war_str
# TO return the constructed model
return model