@@ -21,8 +21,9 @@ def track_trimmed_to_range(in_track, trim_range):
2121 .. note:: The track is never expanded, only shortened.
2222
2323 Please note that you could do nearly the same thing non-destructively by
24- just setting the :py:class:`opentimelineio.schema.Track`\' s source_range but sometimes you want
25- to really cut away the stuff outside and that's what this function is meant for.
24+ just setting the :py:class:`opentimelineio.schema.Track`\' s source_range but
25+ sometimes you want to really cut away the stuff outside and that's what this
26+ function is meant for.
2627
2728 :param opentimelineio.schema.Track in_track: Track to trim
2829 :param TimeRange trim_range:
@@ -56,8 +57,7 @@ def track_trimmed_to_range(in_track, trim_range):
5657 trim_amount = trim_range .start_time - child_range .start_time
5758 child_source_range = opentime .TimeRange (
5859 start_time = child_source_range .start_time + trim_amount ,
59- duration = child_source_range .duration - trim_amount
60-
60+ duration = child_source_range .duration - trim_amount ,
6161 )
6262
6363 # should we trim the end?
@@ -67,8 +67,7 @@ def track_trimmed_to_range(in_track, trim_range):
6767 trim_amount = child_end - trim_end
6868 child_source_range = opentime .TimeRange (
6969 start_time = child_source_range .start_time ,
70- duration = child_source_range .duration - trim_amount
71-
70+ duration = child_source_range .duration - trim_amount ,
7271 )
7372
7473 # set the new child's trims
@@ -122,11 +121,7 @@ def track_with_expanded_transitions(in_track):
122121 next_transition = next_thing
123122
124123 result_track .append (
125- _trim_from_transitions (
126- thing ,
127- pre = pre_transition ,
128- post = next_transition
129- )
124+ _trim_from_transitions (thing , pre = pre_transition , post = next_transition )
130125 )
131126
132127 # loop
@@ -138,13 +133,12 @@ def track_with_expanded_transitions(in_track):
138133
139134
140135def _expand_transition (target_transition , from_track ):
141- """ Expand transitions into the portions of pre-and-post clips that
136+ """Expand transitions into the portions of pre-and-post clips that
142137 overlap with the transition.
143138 """
144139
145140 result = from_track .neighbors_of (
146- target_transition ,
147- schema .NeighborGapPolicy .around_transitions
141+ target_transition , schema .NeighborGapPolicy .around_transitions
148142 )
149143
150144 trx_duration = target_transition .in_offset + target_transition .out_offset
@@ -154,43 +148,31 @@ def _expand_transition(target_transition, from_track):
154148
155149 if isinstance (pre , schema .Transition ):
156150 raise exceptions .TransitionFollowingATransitionError (
157- "cannot put two transitions next to each other in a track: "
158- "{}, {}" .format (
159- pre ,
160- target_transition
151+ "cannot put two transitions next to each other in a track: {}, {}" .format (
152+ pre , target_transition
161153 )
162154 )
163155 if target_transition .in_offset is None :
164- raise RuntimeError (
165- f"in_offset is None on: { target_transition } "
166- )
156+ raise RuntimeError (f"in_offset is None on: { target_transition } " )
167157
168158 if target_transition .out_offset is None :
169- raise RuntimeError (
170- f"out_offset is None on: { target_transition } "
171- )
159+ raise RuntimeError (f"out_offset is None on: { target_transition } " )
172160
173161 pre .name = (pre .name or "" ) + "_transition_pre"
174162
175163 # ensure that pre.source_range is set, because it will get manipulated
176164 tr = pre .trimmed_range ()
177165
178166 pre .source_range = opentime .TimeRange (
179- start_time = (
180- tr .end_time_exclusive () - target_transition .in_offset
181- ),
182- duration = trx_duration .rescaled_to (
183- tr .start_time
184- )
167+ start_time = (tr .end_time_exclusive () - target_transition .in_offset ),
168+ duration = trx_duration .rescaled_to (tr .start_time ),
185169 )
186170
187171 post = copy .deepcopy (result [1 ])
188172 if isinstance (post , schema .Transition ):
189173 raise exceptions .TransitionFollowingATransitionError (
190- "cannot put two transitions next to each other in a track: "
191- "{}, {}" .format (
192- target_transition ,
193- post
174+ "cannot put two transitions next to each other in a track: {}, {}" .format (
175+ target_transition , post
194176 )
195177 )
196178
@@ -200,17 +182,17 @@ def _expand_transition(target_transition, from_track):
200182 tr = post .trimmed_range ()
201183
202184 post .source_range = opentime .TimeRange (
203- start_time = (
204- tr .start_time - target_transition . in_offset
205- ). rescaled_to ( tr . start_time ) ,
206- duration = trx_duration .rescaled_to (tr .start_time )
185+ start_time = (tr . start_time - target_transition . in_offset ). rescaled_to (
186+ tr .start_time
187+ ),
188+ duration = trx_duration .rescaled_to (tr .start_time ),
207189 )
208190
209191 return pre , target_transition , post
210192
211193
212194def _trim_from_transitions (thing , pre = None , post = None ):
213- """ Trim clips next to transitions. """
195+ """Trim clips next to transitions."""
214196
215197 result = copy .deepcopy (thing )
216198
0 commit comments