Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
]
with self.assertRaises(SystemExit):
self.run_test()
sys.argv = [
'otioconvert',
'-i', SCREENING_EXAMPLE_PATH,
'-o', temp_file,
'-O', 'otio_json',
"--begin", "0,24",
"--end", "0",
]
with self.assertRaises(SystemExit):
self.run_test()
result = otio.adapters.read_from_file(temp_file, "otio_json")
self.assertEquals(len(result.tracks[0]), 0)
self.assertEquals(result.name, "Example_Screening.01")
finally:
shutil.rmtree(temp_dir)
def test_otio_json_default(self):
tl = otio.adapters.read_from_file(SCREENING_EXAMPLE_PATH)
self.assertMultiLineEqual(
otio.adapters.write_to_string(tl, 'otio_json'),
otio.adapters.write_to_string(tl)
)
test_str = otio.adapters.write_to_string(tl)
self.assertJsonEqual(tl, otio.adapters.read_from_string(test_str))
def test_hiero_flavored_xml(self):
timeline = adapters.read_from_file(HIERO_XML_PATH)
self.assertTrue(len(timeline.tracks), 1)
self.assertTrue(timeline.tracks[0].name == 'Video 1')
clips = [c for c in timeline.tracks[0].each_clip()]
self.assertTrue(len(clips), 2)
self.assertTrue(clips[0].name == 'A160C005_171213_R0MN')
self.assertTrue(clips[1].name == '/')
self.assertTrue(
isinstance(
clips[0].media_reference,
schema.ExternalReference
)
)
def test_edl_25fps(self):
# EXERCISE
edl_path = EXEMPLE_25_FPS_PATH
fps = 25
timeline = otio.adapters.read_from_file(edl_path, rate=fps)
track = timeline.tracks[0]
self.assertEqual(track[0].source_range.duration.value, 161)
self.assertEqual(track[1].source_range.duration.value, 200)
self.assertEqual(track[2].source_range.duration.value, 86)
self.assertEqual(track[3].source_range.duration.value, 49)
def test_edl_round_trip_disk2mem2disk(self):
timeline = otio.adapters.read_from_file(SCREENING_EXAMPLE_PATH)
tmp_path = tempfile.mkstemp(suffix=".edl", text=True)[1]
otio.adapters.write_to_file(timeline, tmp_path)
result = otio.adapters.read_from_file(tmp_path)
# When debugging, you can use this to see the difference in the OTIO
# otio.adapters.otio_json.write_to_file(timeline, "/tmp/original.otio")
# otio.adapters.otio_json.write_to_file(result, "/tmp/output.otio")
# os.system("opendiff /tmp/{original,output}.otio")
original_json = otio.adapters.otio_json.write_to_string(timeline)
output_json = otio.adapters.otio_json.write_to_string(result)
self.assertMultiLineEqual(original_json, output_json)
def test_flatten_example_code(self):
timeline = otio.adapters.read_from_file(MULTITRACK_EXAMPLE_PATH)
preflattened = otio.adapters.read_from_file(PREFLATTENED_EXAMPLE_PATH)
preflattened_track = preflattened.video_tracks()[0]
flattened_track = otio.algorithms.flatten_stack(
timeline.video_tracks()
)
# the names will be different, so clear them both
preflattened_track.name = ""
flattened_track.name = ""
self.assertOTIOEqual(
preflattened_track,
flattened_track
)
def test_edl_read(self):
edl_path = SCREENING_EXAMPLE_PATH
fps = 24
timeline = otio.adapters.read_from_file(edl_path)
self.assertTrue(timeline is not None)
self.assertEqual(len(timeline.tracks), 1)
self.assertEqual(len(timeline.tracks[0]), 9)
self.assertEqual(
timeline.tracks[0][0].name,
"ZZ100_501 (LAY3)"
)
self.assertEqual(
timeline.tracks[0][0].source_range.duration,
otio.opentime.from_timecode("00:00:01:07", fps)
)
self.assertEqual(
timeline.tracks[0][1].name,
"ZZ100_502A (LAY3)"
)
self.assertEqual(
def test_edl_round_trip_disk2mem2disk_speed_effects(self):
test_edl = SPEED_EFFECTS_TEST_SMALL
timeline = otio.adapters.read_from_file(test_edl)
tmp_path = tempfile.mkstemp(suffix=".edl", text=True)[1]
otio.adapters.write_to_file(timeline, tmp_path)
result = otio.adapters.read_from_file(tmp_path)
# When debugging, you can use this to see the difference in the OTIO
# otio.adapters.otio_json.write_to_file(timeline, "/tmp/original.otio")
# otio.adapters.otio_json.write_to_file(result, "/tmp/output.otio")
# os.system("xxdiff /tmp/{original,output}.otio")
# When debugging, use this to see the difference in the EDLs on disk
# os.system("xxdiff {} {}&".format(test_edl, tmp_path))
# The in-memory OTIO representation should be the same
def main():
""" main entry point """
args = _parsed_args()
for fp in args.filepath:
try:
parsed_otio = otio.adapters.read_from_file(fp)
except (otio.exceptions.OTIOError) as e:
sys.stderr.write(
"The file did not successfully parse, with error:"
" {}\n".format(e),
)
continue
except (Exception) as e:
sys.stderr.write("There was a system error: {}\n".format(e))
continue
_stat_otio(parsed_otio)