Cleanup: pep8, unused args, indentation

This commit is contained in:
2019-09-15 05:35:42 +10:00
parent 96ff40859d
commit 19fc50ca6f

View File

@@ -187,11 +187,13 @@ class SequencerFadesAdd(Operator):
default=1.0, default=1.0,
min=0.01) min=0.01)
type: bpy.props.EnumProperty( type: bpy.props.EnumProperty(
items=[('IN_OUT', 'Fade In And Out', 'Fade selected strips in and out'), items=(
('IN_OUT', 'Fade In And Out', 'Fade selected strips in and out'),
('IN', 'Fade In', 'Fade in selected strips'), ('IN', 'Fade In', 'Fade in selected strips'),
('OUT', 'Fade Out', 'Fade out selected strips'), ('OUT', 'Fade Out', 'Fade out selected strips'),
('CURSOR_FROM', 'From Playhead', 'Fade from the time cursor to the end of overlapping sequences'), ('CURSOR_FROM', 'From Playhead', 'Fade from the time cursor to the end of overlapping sequences'),
('CURSOR_TO', 'To Playhead', 'Fade from the start of sequences under the time cursor to the current frame')], ('CURSOR_TO', 'To Playhead', 'Fade from the start of sequences under the time cursor to the current frame'),
),
name="Fade type", name="Fade type",
description="Fade in, out, both in and out, to, or from the playhead. Default is both in and out.", description="Fade in, out, both in and out, to, or from the playhead. Default is both in and out.",
default='IN_OUT') default='IN_OUT')
@@ -211,9 +213,11 @@ class SequencerFadesAdd(Operator):
scene.animation_data.action = action scene.animation_data.action = action
sequences = context.selected_sequences sequences = context.selected_sequences
if self.type in ['CURSOR_TO', 'CURSOR_FROM']: if self.type in {'CURSOR_TO', 'CURSOR_FROM'}:
sequences = [s for s in sequences sequences = [
if s.frame_final_start < context.scene.frame_current < s.frame_final_end] s for s in sequences
if s.frame_final_start < context.scene.frame_current < s.frame_final_end
]
max_duration = min(sequences, key=lambda s: s.frame_final_duration).frame_final_duration max_duration = min(sequences, key=lambda s: s.frame_final_duration).frame_final_duration
max_duration = floor(max_duration / 2.0) if self.type == 'IN_OUT' else max_duration max_duration = floor(max_duration / 2.0) if self.type == 'IN_OUT' else max_duration
@@ -228,7 +232,7 @@ class SequencerFadesAdd(Operator):
animated_property = 'volume' if hasattr(sequence, 'volume') else 'blend_alpha' animated_property = 'volume' if hasattr(sequence, 'volume') else 'blend_alpha'
fade_fcurve = self.fade_find_or_create_fcurve(context, sequence, animated_property) fade_fcurve = self.fade_find_or_create_fcurve(context, sequence, animated_property)
fades = self.calculate_fades(sequence, fade_fcurve, animated_property, duration) fades = self.calculate_fades(sequence, fade_fcurve, animated_property, duration)
self.fade_animation_clear(context, fade_fcurve, fades) self.fade_animation_clear(fade_fcurve, fades)
self.fade_animation_create(fade_fcurve, fades) self.fade_animation_create(fade_fcurve, fades)
faded_sequences.append(sequence) faded_sequences.append(sequence)
@@ -248,9 +252,7 @@ class SequencerFadesAdd(Operator):
return max(1, duration) return max(1, duration)
def is_long_enough(self, sequence, duration=0.0): def is_long_enough(self, sequence, duration=0.0):
minimum_duration = (duration * 2 minimum_duration = duration * 2 if self.type == 'IN_OUT' else duration
if self.type == 'IN_OUT' else
duration)
return sequence.frame_final_duration >= minimum_duration return sequence.frame_final_duration >= minimum_duration
def calculate_fades(self, sequence, fade_fcurve, animated_property, duration): def calculate_fades(self, sequence, fade_fcurve, animated_property, duration):
@@ -258,10 +260,10 @@ class SequencerFadesAdd(Operator):
Returns a list of Fade objects Returns a list of Fade objects
""" """
fades = [] fades = []
if self.type in ['IN', 'IN_OUT', 'CURSOR_TO']: if self.type in {'IN', 'IN_OUT', 'CURSOR_TO'}:
fade = Fade(sequence, fade_fcurve, 'IN', animated_property, duration) fade = Fade(sequence, fade_fcurve, 'IN', animated_property, duration)
fades.append(fade) fades.append(fade)
if self.type in ['OUT', 'IN_OUT', 'CURSOR_FROM']: if self.type in {'OUT', 'IN_OUT', 'CURSOR_FROM'}:
fade = Fade(sequence, fade_fcurve, 'OUT', animated_property, duration) fade = Fade(sequence, fade_fcurve, 'OUT', animated_property, duration)
fades.append(fade) fades.append(fade)
return fades return fades
@@ -283,7 +285,7 @@ class SequencerFadesAdd(Operator):
fade_fcurve = fcurves.new(data_path=searched_data_path) fade_fcurve = fcurves.new(data_path=searched_data_path)
return fade_fcurve return fade_fcurve
def fade_animation_clear(self, context, fade_fcurve, fades): def fade_animation_clear(self, fade_fcurve, fades):
""" """
Removes existing keyframes in the fades' time range, in fast mode, without Removes existing keyframes in the fades' time range, in fast mode, without
updating the fcurve updating the fcurve