Skip to content

Commit cabe1df

Browse files
committed
Bindings: UnknownSchema added data property
Signed-off-by: Natchar Ratanasirigulchai <[email protected]>
1 parent 5184c36 commit cabe1df

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/opentimelineio/unknownSchema.h

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ class UnknownSchema : public SerializableObject
3131
return _original_schema_version;
3232
}
3333

34+
AnyDictionary& data() noexcept
35+
{
36+
return _data;
37+
}
38+
3439
bool read_from(Reader&) override;
3540
void write_to(Writer&) const override;
3641

src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ static void define_bases1(py::module m) {
182182
.def_property_readonly("is_unknown_schema", &SerializableObject::is_unknown_schema);
183183

184184
py::class_<UnknownSchema, SerializableObject, managing_ptr<UnknownSchema>>(m, "UnknownSchema")
185+
.def_property_readonly("data", [](UnknownSchema* schema) {
186+
auto ptr = schema->data().get_or_create_mutation_stamp();
187+
return (AnyDictionaryProxy*)(ptr); }, py::return_value_policy::take_ownership)
185188
.def_property_readonly("original_schema_name", &UnknownSchema::original_schema_name)
186189
.def_property_readonly("original_schema_version", &UnknownSchema::original_schema_version);
187190

tests/test_unknown_schema.py

+10
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ def test_is_unknown_schema(self):
6363
unknown = self.orig.media_reference.metadata["stuff"]
6464
self.assertTrue(unknown.is_unknown_schema)
6565

66+
def test_unknown_to_dict(self):
67+
unknown = self.orig.media_reference.metadata["stuff"]
68+
self.assertTrue(unknown.is_unknown_schema)
69+
self.assertEqual(
70+
unknown.data,
71+
{
72+
"some_data": 895,
73+
"howlongami": otio.opentime.RationalTime(rate=30, value=100)
74+
}
75+
)
6676

6777
if __name__ == '__main__':
6878
unittest.main()

0 commit comments

Comments
 (0)