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


Python Object.findObject方法代码示例

本文整理汇总了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 !")
开发者ID:GiorgosPa,项目名称:Rauzy-language,代码行数:47,代码来源:Rauzy.py


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