usd: Python wrap for Usd.UsdFileFormat.Tokens
authorblevin <blevin@users.noreply.github.com>
Sat, 3 Feb 2024 03:24:50 +0000 (19:24 -0800)
committerpixar-oss <pixar-oss@users.noreply.github.com>
Sat, 3 Feb 2024 03:24:50 +0000 (19:24 -0800)
(Internal change: 2313325)

pxr/usd/usd/testenv/testUsdFileFormats.py
pxr/usd/usd/wrapUsdFileFormat.cpp

index ebac7ffa168ba8a9bbfc060f8b81952f41e71bd5..5a5559bdc399313b41d8e848e6b6e9ade9c84e3a 100644 (file)
@@ -253,5 +253,10 @@ class TestUsdFileFormats(unittest.TestCase):
             Usd.UsdFileFormat.GetUnderlyingFormatForLayer(layer), 
             'usdc')
 
+    def test_Tokens(self):
+        '''Test basic token wrapping'''
+        self.assertEqual(Usd.UsdFileFormat.Tokens.Target, 'usd')
+        self.assertEqual(Usd.UsdFileFormat.Tokens.FormatArg, 'format')
+
 if __name__ == "__main__":
     unittest.main()
index 7421545adc7c0663634e604ad46134c12692a1ee..1cb485aa7186a1d57a6dc1663abc5ce0046b55bb 100644 (file)
 
 #include "pxr/usd/usd/usdFileFormat.h"
 #include "pxr/usd/sdf/layer.h"
+#include "pxr/base/tf/pyStaticTokens.h"
 
 #include <boost/python/bases.hpp>
 #include <boost/python/class.hpp>
+#include <boost/python/scope.hpp>
 
 using namespace boost::python;
 
@@ -37,11 +39,17 @@ void
 wrapUsdFileFormat()
 {
     using This = UsdUsdFileFormat;
-    class_<This, bases<SdfFileFormat>, boost::noncopyable>
+
+    scope s = class_<This, bases<SdfFileFormat>, boost::noncopyable>
         ("UsdFileFormat", no_init)
 
         .def("GetUnderlyingFormatForLayer", 
             &This::GetUnderlyingFormatForLayer)
         .staticmethod("GetUnderlyingFormatForLayer")
         ;
+
+    TF_PY_WRAP_PUBLIC_TOKENS(
+        "Tokens",
+        UsdUsdFileFormatTokens,
+        USD_USD_FILE_FORMAT_TOKENS);
 }