本文整理汇总了Python中Object.Object.findObject方法的典型用法代码示例。如果您正苦于以下问题:Python Object.findObject方法的具体用法?Python Object.findObject怎么用?Python Object.findObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Object.Object
的用法示例。
在下文中一共展示了Object.findObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: modifyModel
# 需要导入模块: from Object import Object [as 别名]
# 或者: from Object.Object import findObject [as 别名]
def modifyModel(field, newvalue):
dest = field.split(".")
nl = 0
key = None
# The first element is always the nature of the object
if dest[nl] == "object":
key = Object.findObject(dest[nl + 1])
nl = nl + 2
elif dest[nl] == "relation":
key = Object.findRelation(dest[nl + 1])
nl = nl + 2
elif dest[nl] == "library":
if dest[nl + 1] == "object":
key = Object.findLibObject(dest[nl + 2])
elif dest[nl + 1] == "relations":
key = Object.findLibRelation(dest[nl + 2])
else:
print ("There is no " + dest[nl + 1] + " field in the library!")
return
nl = nl + 3
else:
print ("The first field name is not recognized!")
return
# If we want to change the parent, we will change the string "extends"
if dest[nl] == "extends":
key = key.parent
key.parent = newvalue
nl += 1
# If we want to change properties, we will change one of its properties
elif dest[nl] == "properties":
key = key.properties
key[dest[nl + 1]] = newvalue
nl = nl + 2
# If we want to change 'relations', we will change the name of the relation
elif dest[nl] == "relations":
key = key.relations
key.remove(dest[nl + 1])
key.append(newvalue)
# If we want to change 'objects', we will change the name of the object
elif dest[nl] == "objects":
key = key.objects
key.remove(dest[nl + 1])
key.append(newvalue)
else:
print ("The field name is not recognized !")