Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated each_child and each_clip functions #13

Merged
merged 1 commit into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/otio_aaf_adapter/adapters/aaf_adapter/aaf_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def validate_metadata(timeline):
all_checks = [__check(timeline, "duration().rate")]
edit_rate = __check(timeline, "duration().rate").value

for child in timeline.each_child():
for child in timeline.find_children():
checks = []
if _is_considered_gap(child):
checks = [
Expand Down Expand Up @@ -227,7 +227,7 @@ def _generate_empty_mobid(clip):

clip_mob_ids = {}

for otio_clip in input_otio.each_clip():
for otio_clip in input_otio.find_clips():
if _is_considered_gap(otio_clip):
continue
for strategy in strategies:
Expand All @@ -249,7 +249,7 @@ def _stackify_nested_groups(timeline):
"""
copied = copy.deepcopy(timeline)
for track in copied.tracks:
for i, child in enumerate(track.each_child()):
for i, child in enumerate(track.find_children()):
is_nested = isinstance(child, otio.schema.Track)
is_parent_in_stack = isinstance(child.parent(), otio.schema.Stack)
if is_nested and not is_parent_in_stack:
Expand Down Expand Up @@ -282,7 +282,7 @@ def __init__(self, root_file_transcriber, otio_track):
self.compositionmob = root_file_transcriber.compositionmob
self.aaf_file = root_file_transcriber.aaf_file
self.otio_track = otio_track
self.edit_rate = next(self.otio_track.each_child()).duration().rate
self.edit_rate = self.otio_track.find_children()[0].duration().rate
self.timeline_mobslot, self.sequence = self._create_timeline_mobslot()
self.timeline_mobslot.name = self.otio_track.name

Expand Down
7 changes: 4 additions & 3 deletions src/otio_aaf_adapter/adapters/advanced_authoring_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -1208,11 +1208,11 @@ def _attach_markers(collection):

"""
# iterate all timeline objects
for timeline in collection.each_child(descended_from_type=otio.schema.Timeline):
for timeline in collection.find_children(descended_from_type=otio.schema.Timeline):
tracks_map = {}

# build track mapping
for track in timeline.each_child(descended_from_type=otio.schema.Track):
for track in timeline.find_children(descended_from_type=otio.schema.Track):
metadata = track.metadata.get("AAF", {})
slot_id = metadata.get("SlotID")
track_number = metadata.get("PhysicalTrackNumber")
Expand All @@ -1222,7 +1222,8 @@ def _attach_markers(collection):
tracks_map[(int(slot_id), int(track_number))] = track

# iterate all tracks for their markers and attach them to the matching item
for current_track in timeline.each_child(descended_from_type=otio.schema.Track):
for current_track in timeline.find_children(
descended_from_type=otio.schema.Track):
for marker in list(current_track.markers):
metadata = marker.metadata.get("AAF", {})
slot_id = metadata.get("AttachedSlotID")
Expand Down
37 changes: 19 additions & 18 deletions tests/test_aaf_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def test_aaf_read(self):

self.assertEqual(len(timeline.audio_tracks()), 2)

clips = list(video_track.each_clip())
clips = video_track.find_clips()

self.assertEqual(
[
Expand Down Expand Up @@ -324,7 +324,7 @@ def test_aaf_read_trims(self):
]
)

clips = list(video_track.each_clip())
clips = video_track.find_clips()

self.assertEqual(
[item.name for item in video_track],
Expand Down Expand Up @@ -428,7 +428,7 @@ def test_aaf_read_transitions(self):
video_track = video_tracks[0]
self.assertEqual(len(video_track), 12)

clips = list(video_track.each_clip())
clips = video_track.find_clips()
self.assertEqual(len(clips), 4)

self.assertEqual(
Expand Down Expand Up @@ -633,7 +633,7 @@ def test_aaf_flatten_tracks(self):
t.name = ""
t.metadata.pop("AAF", None)

for c in t.each_child():
for c in t.find_children():
if hasattr(c, "media_reference") and c.media_reference:
mr = c.media_reference
mr.metadata.get("AAF", {}).pop('LastModified', None)
Expand All @@ -644,7 +644,7 @@ def test_aaf_flatten_tracks(self):
meta.pop('StartTime', None)

# We don't care about Gap start times, only their duration matters
for g in t.each_child(descended_from_type=otio.schema.Gap):
for g in t.find_children(descended_from_type=otio.schema.Gap):
dur = g.source_range.duration
rate = g.source_range.start_time.rate
g.source_range = otio.opentime.TimeRange(
Expand Down Expand Up @@ -967,7 +967,7 @@ def test_aaf_sourcemob_usage(self):
# `Usage_SubClip` value
subclip_timeline = otio.adapters.read_from_file(SUBCLIP_PATH)
subclip_usages = {"Subclip.BREATH": "Usage_SubClip"}
for clip in subclip_timeline.each_clip():
for clip in subclip_timeline.find_clips():
self.assertEqual(
clip.metadata.get("AAF", {}).get("SourceMobUsage"),
subclip_usages[clip.name]
Expand All @@ -982,7 +982,7 @@ def test_aaf_sourcemob_usage(self):
"t-hawk (loop)-HD.mp4": "",
"tech.fux (loop)-HD.mp4": ""
}
for clip in simple_timeline.each_clip():
for clip in simple_timeline.find_clips():
self.assertEqual(
clip.metadata.get("AAF", {}).get("SourceMobUsage", ""),
simple_usages[clip.name]
Expand Down Expand Up @@ -1203,9 +1203,9 @@ def test_attach_markers(self):

all_markers = {}
for i, track in enumerate(
timeline.each_child(descended_from_type=otio.schema.Track)
timeline.find_children(descended_from_type=otio.schema.Track)
):
for item in track.each_child():
for item in track.find_children():
markers = [
(
m.name,
Expand All @@ -1222,7 +1222,7 @@ def test_attach_markers(self):
def test_keyframed_properties(self):
def get_expected_dict(timeline):
expected = []
for clip in timeline.each_child(descended_from_type=otio.schema.Clip):
for clip in timeline.find_children(descended_from_type=otio.schema.Clip):
for effect in clip.effects:
props = {}
parameters = effect.metadata.get("AAF", {}).get("Parameters", {})
Expand Down Expand Up @@ -1568,7 +1568,7 @@ def test_aaf_writer_nometadata(self):
def _target_url_fixup(timeline):
# fixes up relative paths to be absolute to this test file
test_dir = os.path.dirname(os.path.abspath(__file__))
for clip in timeline.each_clip():
for clip in timeline.find_clips():
target_url_str = clip.media_reference.target_url
clip.media_reference.target_url = os.path.join(test_dir, target_url_str)

Expand Down Expand Up @@ -1609,7 +1609,7 @@ def test_aaf_roundtrip_first_clip(self):
def _target_url_fixup(timeline):
# fixes up relative paths to be absolute to this test file
test_dir = os.path.dirname(os.path.abspath(__file__))
for clip in timeline.each_clip():
for clip in timeline.find_clips():
target_url_str = clip.media_reference.target_url
clip.media_reference.target_url = os.path.join(test_dir, target_url_str)

Expand All @@ -1623,8 +1623,8 @@ def _target_url_fixup(timeline):
def _verify_first_clip(self, original_timeline, aaf_path):
timeline_from_aaf = otio.adapters.read_from_file(aaf_path)

original_clips = list(original_timeline.each_clip())
aaf_clips = list(timeline_from_aaf.each_clip())
original_clips = original_timeline.find_clips()
aaf_clips = timeline_from_aaf.find_clips()

self.assertTrue(len(original_clips) > 0)
self.assertEqual(len(aaf_clips), len(original_clips))
Expand Down Expand Up @@ -1719,10 +1719,11 @@ def _verify_aaf(self, aaf_path):
sequence = opgroup.segments[0]
self.assertTrue(isinstance(sequence, Sequence))

self.assertEqual(len(list(otio_track.each_child(shallow_search=True))),
len(sequence.components))
self.assertEqual(
len(otio_track.find_children(shallow_search=True)),
len(sequence.components))
for otio_child, aaf_component in zip(
otio_track.each_child(shallow_search=True),
otio_track.find_children(shallow_search=True),
sequence.components):
type_mapping = {
otio.schema.Clip: aaf2.components.SourceClip,
Expand All @@ -1740,7 +1741,7 @@ def _verify_aaf(self, aaf_path):
if isinstance(aaf_component, aaf2.components.OperationGroup):
nested_aaf_segments = aaf_component.segments
for nested_otio_child, nested_aaf_segment in zip(
otio_child.each_child(), nested_aaf_segments):
otio_child.find_children(), nested_aaf_segments):
self._is_otio_aaf_same(nested_otio_child,
nested_aaf_segment)
else:
Expand Down