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


Python MT.newProject方法代码示例

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


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

示例1: testNewProject

# 需要导入模块: import MT [as 别名]
# 或者: from MT import newProject [as 别名]
def testNewProject():
    node = MT.createNode("Math.Add")
    node1 = MT.createNode("Values.Float Value")
    node2 = MT.createNode("Values.Int Value")

    MT.project.root.addNode(node)
    MT.project.root.addNode(node1)
    MT.project.root.addNode(node2)

    MT.newProject()

    return len(MT.project.root) == 0
开发者ID:frigge,项目名称:MindTree,代码行数:14,代码来源:project_tests.py

示例2: all

# 需要导入模块: import MT [as 别名]
# 或者: from MT import newProject [as 别名]
def all():
    print("testing all tests ...")

    tests = [t for t in dir(__import__(__name__)) if t.startswith("test")]
    numberOfTests = len(tests)
    failedTests = []
    exceptions = []

    for t in tests:
        MT.newProject()
        print("\n_____________________________________")
        print("running test: %s\n" % t)
        success = False
        try:
            success = eval(t).__call__()
        except:
            exceptions.append(sys.exc_info())
        if success:
            print("%s passed" % t)
        else:
            failedTests.append(t)
            print("%s failed" % t)
        print("_____________________________________\n")

    if len(failedTests) > 0:
        print("%d out of %d tests failed" % (len(failedTests), numberOfTests))
        print("\nfailed Tests:\n")
        for t in failedTests:
            print("\t" + t)

        print("Error info:")
        for e in exceptions:
            traceback.print_exception(*e)
    else:
            print("All tests passed")

    return not len(failedTests)
开发者ID:frigge,项目名称:MindTree,代码行数:39,代码来源:__init__.py

示例3: testLoadProject

# 需要导入模块: import MT [as 别名]
# 或者: from MT import newProject [as 别名]
def testLoadProject():
    MT.newProject()
    node = MT.createNode("Math.Add")
    node1 = MT.createNode("Values.Float Value")
    node2 = MT.createNode("Values.Int Value")
    node3 = MT.createNode("General.Container")

    node.insockets[0].connected = node1.outsockets[0]

    node.pos = (0, 0)
    node1.pos = (0, 20)
    node2.pos = (0, 40)
    node3.pos = (0, 60)

    node4 = MT.createNode("Values.String Value")
    node5 = MT.createNode("Values.Vector3D")
    node6 = MT.createNode("Values.Vector2D")
    node7 = MT.createNode("Values.Color Value")
    node8 = MT.createNode("Objects.Transform")
    node9 = MT.createNode("Objects.Lights.Spot Light")

    node4.pos = (0, 0)
    node5.pos = (0, 20)
    node6.pos = (0, 40)
    node7.pos = (0, 60)
    node8.pos = (0, 80)
    node9.pos = (0, 100)

    MT.project.root.addNode(node)
    MT.project.root.addNode(node1)
    MT.project.root.addNode(node2)
    MT.project.root.addNode(node3)

    node3.graph.addNode(node4)
    node3.graph.addNode(node5)
    node3.graph.addNode(node6)
    node3.graph.addNode(node7)
    node3.graph.addNode(node8)
    node3.graph.addNode(node9)

    graphsize = len(node3.graph)

    node9.insockets[6].value = True

    node1.insockets[0].value = 5.7
    node2.insockets[0].value = 14

    now = datetime.datetime.now()
    filename =  "projectTest.mt"
    MT.project.filename = filename
    print("saving project: " + filename)
    MT.project.save()

    print()
    MT.newProject()
    print("open project: " + filename)
    MT.openProject(filename)

    node = MT.project.root[0]
    node1 = MT.project.root[1]
    node2 = MT.project.root[2]
    node3 = MT.project.root[3]

    node4 = MT.project.root[3].graph[2]
    node5 = MT.project.root[3].graph[3]
    node6 = MT.project.root[3].graph[4]
    node7 = MT.project.root[3].graph[5]
    node8 = MT.project.root[3].graph[6]
    node9 = MT.project.root[3].graph[7]
    
    test = TestCase()

    test.equal(len(MT.project.root), 4, "Project size")
    test.contains("Add", node.name)
    test.contains("Float Value", node1.name)
    test.contains("Int Value", node2.name)
    test.contains("Container", node3.name)
    test.equal((0, 0), node.pos)
    test.equal((0, 20), node1.pos)
    test.equal((0, 40), node2.pos)
    test.equal((0, 60), node3.pos)
    test.equal((0, 0), node4.pos)
    test.equal((0, 20), node5.pos)
    test.equal((0, 40), node6.pos)
    test.equal((0, 60), node7.pos)
    test.equal((0, 80), node8.pos)
    test.equal(node.insockets[0].connected, node1.outsockets[0], "add insocket and float value out")
    test.equal(len(node3.graph), graphsize)
    test.contains("String Value", node4.name)
    test.contains("Vector3D", node5.name)
    test.contains("Vector2D", node6.name)
    test.contains("Color Value", node7.name)
    test.contains("Transform", node8.name)
    test.contains("Spot Light", node9.name)
    test.equal(len(node8.insockets), 2, "number of insockets")
    test.equal(node2.insockets[0].value, 14)
    test.floatEqual(node1.insockets[0].value, 5.7, 0.00001)
    test.equal(node9.insockets[5].value, False)
    test.equal(node9.insockets[6].value, True)
    test.equal(node9.insockets[7].value, 512)
#.........这里部分代码省略.........
开发者ID:frigge,项目名称:MindTree,代码行数:103,代码来源:project_tests.py


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