コード例 #1
0
ファイル: testUsdBugs.py プロジェクト: zloop1982/USD
    def test_153956(self):
        from pixar import Sdf

        # Create a crate-backed .usd file and populate it with an
        # attribute connection. These files do not store specs for
        # targets/connections, so there will be an entry in the
        # connectionChildren list but no corresponding spec.
        layer = Sdf.Layer.CreateAnonymous(".usd")
        primSpec = Sdf.CreatePrimInLayer(layer, "/Test")
        attrSpec = Sdf.AttributeSpec(primSpec, "attr",
                                     Sdf.ValueTypeNames.Float)

        # -- Adding item to prependedItems list..."
        attrSpec.connectionPathList.prependedItems.append(
            "/Test.prependedItem")

        # Transfer the contents of the crate-backed .usd file into an
        # memory-backed .usda file. These file *do* store specs for
        # targets/connections.
        newLayer = Sdf.Layer.CreateAnonymous(".usda")
        newLayer.TransferContent(layer)

        primSpec = newLayer.GetPrimAtPath("/Test")
        attrSpec = primSpec.properties["attr"]

        # Adding an item to the explicitItems list changes to listOp to
        # explicit mode, but does not clear any existing connectionChildren.
        attrSpec.connectionPathList.explicitItems.append("/Test.explicitItem")

        # Prior to the fix, this caused a failed verify b/c an entry exists in
        # the connectionChildren list for which there is no corresponding spec.
        primSpec.name = "Test2"
コード例 #2
0
ファイル: testUsdBugs.py プロジェクト: zloop1982/USD
 def test_USD_5196(self):
     from pxr import Usd, Sdf, Vt, Tf
     import os, random
     # Test that usdc files corrupted by truncation (such that the table of
     # contents is past the end of the file) are detected and fail to open
     # with an error.
     with Tf.NamedTemporaryFile(suffix=".usdc") as f:
         layer = Sdf.Layer.CreateNew(f.name)
         foo = Sdf.CreatePrimInLayer(layer, '/foo')
         attr = Sdf.AttributeSpec(foo, 'attr', Sdf.ValueTypeNames.IntArray)
         ints = range(1024**2)
         random.shuffle(ints)
         attr.default = Vt.IntArray(ints)
         layer.Save()
         del layer
         # Now truncate layer to corrupt it.
         fobj = open(f.name, "rw+")
         size = os.path.getsize(f.name)
         fobj.truncate(size / 2)
         fobj.close()
         # Attempting to open the file should raise an exception.
         with self.assertRaises(Tf.ErrorException):
             layer = Sdf.Layer.FindOrOpen(f.name)