flame: adding docstring to maintained segment selection

This commit is contained in:
Jakub Jezek 2022-01-05 22:46:37 +01:00
parent 5d39784abb
commit 655e85f12a
No known key found for this signature in database
GPG key ID: D8548FBF690B100A

View file

@ -491,26 +491,41 @@ def create_pype_marker(segment):
def maintained_segment_selection(sequence): def maintained_segment_selection(sequence):
"""Maintain selection during context """Maintain selection during context
Attributes:
sequence (flame.PySequence): python api object
Yield:
list of flame.PySegment
Example: Example:
>>> with maintained_selection(): >>> with maintained_segment_selection(sequence) as selected_segments:
... node['selected'].setValue(True) ... for segment in selected_segments:
>>> print(node['selected'].value()) ... segment.selected = False
False >>> print(segment.selected)
True
""" """
selected_segments = [] selected_segments = []
# loop versions in sequence
for ver in sequence.versions: for ver in sequence.versions:
# loop track in versions
for track in ver.tracks: for track in ver.tracks:
# ignore all empty tracks and hidden too
if len(track.segments) == 0 and track.hidden: if len(track.segments) == 0 and track.hidden:
continue continue
# loop all segment in remaining tracks
for segment in track.segments: for segment in track.segments:
# ignore all segments not selected
if segment.selected != True: if segment.selected != True:
continue continue
# add it to original selection
selected_segments.append(segment) selected_segments.append(segment)
try: try:
# do the operation # do the operation on selected segments
yield yield selected_segments
finally: finally:
# reset all selected clips
reset_segment_selection(sequence) reset_segment_selection(sequence)
# select only original selection of segments
for segment in selected_segments: for segment in selected_segments:
segment.selected = True segment.selected = True