Skip to content

Commit

Permalink
Bindings: UnknownSchema added data property
Browse files Browse the repository at this point in the history
Signed-off-by: Natchar Ratanasirigulchai <[email protected]>
  • Loading branch information
natchar committed Sep 27, 2024
1 parent 5184c36 commit cabe1df
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/opentimelineio/unknownSchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ class UnknownSchema : public SerializableObject
return _original_schema_version;
}

AnyDictionary& data() noexcept
{
return _data;
}

bool read_from(Reader&) override;
void write_to(Writer&) const override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ static void define_bases1(py::module m) {
.def_property_readonly("is_unknown_schema", &SerializableObject::is_unknown_schema);

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

Expand Down
10 changes: 10 additions & 0 deletions tests/test_unknown_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ def test_is_unknown_schema(self):
unknown = self.orig.media_reference.metadata["stuff"]
self.assertTrue(unknown.is_unknown_schema)

def test_unknown_to_dict(self):
unknown = self.orig.media_reference.metadata["stuff"]
self.assertTrue(unknown.is_unknown_schema)
self.assertEqual(
unknown.data,
{
"some_data": 895,
"howlongami": otio.opentime.RationalTime(rate=30, value=100)
}
)

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

0 comments on commit cabe1df

Please sign in to comment.