Skip to content

Commit

Permalink
Add slots method that resolves MobSlots for either
Browse files Browse the repository at this point in the history
SourceMobSlotID or MonoSourceSlotIDs properties
  • Loading branch information
markreidvfx committed Apr 21, 2024
1 parent 4656580 commit e4d9e09
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/qt_aafmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ def setup(self):
mob = item.mob
if mob:
self.extend([mob])
slot = item.slot
if slot:
self.extend([slot])
for slot in item.slots():
if slot:
self.extend([slot])


self.properties['Name'] = self.name()
Expand Down
22 changes: 22 additions & 0 deletions src/aaf2/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,28 @@ def slot(self):
def slot(self, value):
self.slot_id = value.slot_id

def slots(self):
"""
A SourceReference can have multiple MobSlot references
if it contains the 'MonoSourceSlotIDs' property.
Returns a list of the MobSlot objects referenced
by either SourceMobSlotID or MonoSourceSlotIDs properties.
MobSlots that cannot be resolved will have a value of None.
"""

if 'MonoSourceSlotIDs' in self:
slot_ids = self['MonoSourceSlotIDs'].value
else:
slot_id = self.slot_id
if slot_id is None:
return [None]
slot_ids = [slot_id]

mob = self.mob
if mob is None:
return [None for _ in slot_ids]

return [mob.slot_at(slot_id, None) for slot_id in slot_ids]

@register_class
class SourceClip(SourceReference):
Expand Down

0 comments on commit e4d9e09

Please sign in to comment.