From 8f11aecde7409633595b23f24b446943225aa319 Mon Sep 17 00:00:00 2001 From: Nathan Lovato Date: Thu, 14 May 2020 18:31:18 -0600 Subject: Power Sequencer: address docstring warnings The previous commit passed tests without warnings or errors here, but LazyDodo sent me a log with warnings he was getting on his machine. This commit attempts to address them. Note: I'm not getting warnings when running unit tests here. --- .../operators/cut_strips_under_cursor.py | 20 ++++++--- power_sequencer/operators/delete_direct.py | 15 +++++-- .../operators/expand_to_surrounding_cuts.py | 40 ++++++++++++----- power_sequencer/operators/fade_add.py | 52 ++++++++++++++++------ power_sequencer/operators/fade_clear.py | 12 +++-- power_sequencer/operators/scene_merge_from.py | 9 ++-- .../operators/select_all_left_or_right.py | 2 +- power_sequencer/operators/snap.py | 8 +++- power_sequencer/operators/snap_selection.py | 12 +++-- .../operators/trim_left_or_right_handles.py | 13 ++++-- 10 files changed, 135 insertions(+), 48 deletions(-) (limited to 'power_sequencer') diff --git a/power_sequencer/operators/cut_strips_under_cursor.py b/power_sequencer/operators/cut_strips_under_cursor.py index b7c64135..d7e1141a 100644 --- a/power_sequencer/operators/cut_strips_under_cursor.py +++ b/power_sequencer/operators/cut_strips_under_cursor.py @@ -23,14 +23,16 @@ from .utils.functions import get_mouse_frame_and_channel class POWER_SEQUENCER_OT_split_strips_under_cursor(bpy.types.Operator): """ Splits all strips under cursor including muted strips, but excluding locked strips. - Auto selects sequences under the time cursor when you don't have a selection. + Auto selects sequences under the time cursor when you don't have a selection """ doc = { "name": doc_name(__qualname__), "demo": "https://i.imgur.com/ZyEd0jD.gif", "description": doc_description(__doc__), - "shortcuts": [({"type": "K", "value": "PRESS"}, {}, "Cut All Strips Under Cursor")], + "shortcuts": [ + ({"type": "K", "value": "PRESS"}, {}, "Cut All Strips Under Cursor") + ], "keymap": "Sequencer", } bl_idname = doc_idname(__qualname__) @@ -39,7 +41,10 @@ class POWER_SEQUENCER_OT_split_strips_under_cursor(bpy.types.Operator): bl_options = {"REGISTER", "UNDO"} side: bpy.props.EnumProperty( - items=[("LEFT", "", ""), ("RIGHT", "", "")], name="Side", default="LEFT", options={"HIDDEN"} + items=[("LEFT", "", ""), ("RIGHT", "", "")], + name="Side", + default="LEFT", + options={"HIDDEN"}, ) @classmethod @@ -61,5 +66,10 @@ class POWER_SEQUENCER_OT_split_strips_under_cursor(bpy.types.Operator): deselect = False if deselect: bpy.ops.sequencer.select_all(action="DESELECT") - (context.selected_sequences or bpy.ops.power_sequencer.select_strips_under_cursor()) - return bpy.ops.sequencer.split(frame=context.scene.frame_current, side=self.side) + ( + context.selected_sequences + or bpy.ops.power_sequencer.select_strips_under_cursor() + ) + return bpy.ops.sequencer.split( + frame=context.scene.frame_current, side=self.side + ) diff --git a/power_sequencer/operators/delete_direct.py b/power_sequencer/operators/delete_direct.py index c6d77131..b39ae12f 100644 --- a/power_sequencer/operators/delete_direct.py +++ b/power_sequencer/operators/delete_direct.py @@ -22,7 +22,7 @@ from .utils.doc import doc_name, doc_idname, doc_brief, doc_description class POWER_SEQUENCER_OT_delete_direct(bpy.types.Operator): """ - Deletes strips without confirmation, and cleans up crossfades nicely. + Deletes strips without confirmation, and cleans up crossfades nicely """ doc = { @@ -50,7 +50,9 @@ class POWER_SEQUENCER_OT_delete_direct(bpy.types.Operator): bl_description = doc_brief(doc["description"]) bl_options = {"REGISTER", "UNDO"} - is_removing_transitions: bpy.props.BoolProperty(name="Remove Transitions", default=False) + is_removing_transitions: bpy.props.BoolProperty( + name="Remove Transitions", default=False + ) @classmethod def poll(cls, context): @@ -59,12 +61,17 @@ class POWER_SEQUENCER_OT_delete_direct(bpy.types.Operator): def invoke(self, context, event): frame, channel = get_mouse_frame_and_channel(context, event) if not context.selected_sequences: - bpy.ops.power_sequencer.select_closest_to_mouse(frame=frame, channel=channel) + bpy.ops.power_sequencer.select_closest_to_mouse( + frame=frame, channel=channel + ) return self.execute(context) def execute(self, context): selection = context.selected_sequences - if self.is_removing_transitions and bpy.ops.power_sequencer.transitions_remove.poll(): + if ( + self.is_removing_transitions + and bpy.ops.power_sequencer.transitions_remove.poll() + ): bpy.ops.power_sequencer.transitions_remove() bpy.ops.sequencer.delete() diff --git a/power_sequencer/operators/expand_to_surrounding_cuts.py b/power_sequencer/operators/expand_to_surrounding_cuts.py index d18e5bf6..1435b23c 100644 --- a/power_sequencer/operators/expand_to_surrounding_cuts.py +++ b/power_sequencer/operators/expand_to_surrounding_cuts.py @@ -25,7 +25,7 @@ class POWER_SEQUENCER_OT_expand_to_surrounding_cuts(bpy.types.Operator): *Brief* Expand selected strips to surrounding cuts Finds potential gaps surrounding each block of selected sequences and extends the corresponding - sequence handle to it. + sequence handle to it """ doc = { @@ -33,7 +33,11 @@ class POWER_SEQUENCER_OT_expand_to_surrounding_cuts(bpy.types.Operator): "demo": "", "description": doc_description(__doc__), "shortcuts": [ - ({"type": "E", "value": "PRESS", "ctrl": True}, {}, "Expand to Surrounding Cuts") + ( + {"type": "E", "value": "PRESS", "ctrl": True}, + {}, + "Expand to Surrounding Cuts", + ) ], "keymap": "Sequencer", } @@ -64,34 +68,50 @@ class POWER_SEQUENCER_OT_expand_to_surrounding_cuts(bpy.types.Operator): sequences_frame_start = min( sequences, key=lambda s: s.frame_final_start ).frame_final_start - sequences_frame_end = max(sequences, key=lambda s: s.frame_final_end).frame_final_end + sequences_frame_end = max( + sequences, key=lambda s: s.frame_final_end + ).frame_final_end frame_left, frame_right = find_closest_cuts( context, sequences_frame_start, sequences_frame_end ) - if sequences_frame_start == frame_left and sequences_frame_end == frame_right: + if ( + sequences_frame_start == frame_left + and sequences_frame_end == frame_right + ): continue - to_extend_left = [s for s in sequences if s.frame_final_start == sequences_frame_start] - to_extend_right = [s for s in sequences if s.frame_final_end == sequences_frame_end] + to_extend_left = [ + s for s in sequences if s.frame_final_start == sequences_frame_start + ] + to_extend_right = [ + s for s in sequences if s.frame_final_end == sequences_frame_end + ] for s in to_extend_left: s.frame_final_start = ( - frame_left if frame_left < sequences_frame_start else sequences_frame_start + frame_left + if frame_left < sequences_frame_start + else sequences_frame_start ) for s in to_extend_right: s.frame_final_end = ( - frame_right if frame_right > sequences_frame_end else sequences_frame_end + frame_right + if frame_right > sequences_frame_end + else sequences_frame_end ) return {"FINISHED"} def find_closest_cuts(context, frame_min, frame_max): frame_left = max( - context.sequences, key=lambda s: s.frame_final_end if s.frame_final_end <= frame_min else -1 + context.sequences, + key=lambda s: s.frame_final_end if s.frame_final_end <= frame_min else -1, ).frame_final_end frame_right = min( context.sequences, - key=lambda s: s.frame_final_start if s.frame_final_start >= frame_max else 1000000, + key=lambda s: s.frame_final_start + if s.frame_final_start >= frame_max + else 1000000, ).frame_final_start return frame_left, frame_right diff --git a/power_sequencer/operators/fade_add.py b/power_sequencer/operators/fade_add.py index 1bb808cd..70a0798b 100644 --- a/power_sequencer/operators/fade_add.py +++ b/power_sequencer/operators/fade_add.py @@ -31,7 +31,7 @@ class POWER_SEQUENCER_OT_fade_add(bpy.types.Operator): - From playhead: the fade animation goes from the start of sequences under the playhead to the playhead - To playhead: the fade animation goes from the playhead to the end of sequences under the playhead - By default, the duration of the fade is 1 second. + By default, the duration of the fade is 1 second """ doc = { @@ -51,7 +51,10 @@ class POWER_SEQUENCER_OT_fade_add(bpy.types.Operator): bl_options = {"REGISTER", "UNDO"} duration_seconds: bpy.props.FloatProperty( - name="Fade Duration", description="Duration of the fade in seconds", default=1.0, min=0.01 + name="Fade Duration", + description="Duration of the fade in seconds", + default=1.0, + min=0.01, ) type: bpy.props.EnumProperty( items=[ @@ -95,8 +98,12 @@ class POWER_SEQUENCER_OT_fade_add(bpy.types.Operator): 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 = floor(max_duration / 2.0) if self.type == "IN_OUT" else max_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 + ) faded_sequences = [] for sequence in sequences: @@ -106,16 +113,25 @@ class POWER_SEQUENCER_OT_fade_add(bpy.types.Operator): if not self.is_long_enough(sequence, duration): continue - animated_property = "volume" if hasattr(sequence, "volume") else "blend_alpha" - fade_fcurve = fade_find_or_create_fcurve(context, sequence, animated_property) - fades = self.calculate_fades(sequence, fade_fcurve, animated_property, duration) + animated_property = ( + "volume" if hasattr(sequence, "volume") else "blend_alpha" + ) + fade_fcurve = fade_find_or_create_fcurve( + context, sequence, animated_property + ) + fades = self.calculate_fades( + sequence, fade_fcurve, animated_property, duration + ) fade_animation_clear(context, fade_fcurve, fades) fade_animation_create(fade_fcurve, fades) faded_sequences.append(sequence) sequence_string = "sequence" if len(faded_sequences) == 1 else "sequences" self.report( - {"INFO"}, "Added fade animation to {} {}.".format(len(faded_sequences), sequence_string) + {"INFO"}, + "Added fade animation to {} {}.".format( + len(faded_sequences), sequence_string + ), ) return {"FINISHED"} @@ -216,9 +232,13 @@ class Fade: if type == "IN": self.start = Vector((sequence.frame_final_start, 0.0)) - self.end = Vector((sequence.frame_final_start + self.duration, self.max_value)) + self.end = Vector( + (sequence.frame_final_start + self.duration, self.max_value) + ) elif type == "OUT": - self.start = Vector((sequence.frame_final_end - self.duration, self.max_value)) + self.start = Vector( + (sequence.frame_final_end - self.duration, self.max_value) + ) self.end = Vector((sequence.frame_final_end, 0.0)) def calculate_max_value(self, sequence, fade_fcurve): @@ -233,11 +253,15 @@ class Fade: else: if self.type == "IN": fade_end = sequence.frame_final_start + self.duration - keyframes = (k for k in fade_fcurve.keyframe_points if k.co[0] >= fade_end) + keyframes = ( + k for k in fade_fcurve.keyframe_points if k.co[0] >= fade_end + ) if self.type == "OUT": fade_start = sequence.frame_final_end - self.duration keyframes = ( - k for k in reversed(fade_fcurve.keyframe_points) if k.co[0] <= fade_start + k + for k in reversed(fade_fcurve.keyframe_points) + if k.co[0] <= fade_start ) try: max_value = next(keyframes).co[1] @@ -251,4 +275,6 @@ class Fade: def calculate_duration_frames(context, duration_seconds): - return round(duration_seconds * context.scene.render.fps / context.scene.render.fps_base) + return round( + duration_seconds * context.scene.render.fps / context.scene.render.fps_base + ) diff --git a/power_sequencer/operators/fade_clear.py b/power_sequencer/operators/fade_clear.py index 9cba7e16..16443691 100644 --- a/power_sequencer/operators/fade_clear.py +++ b/power_sequencer/operators/fade_clear.py @@ -24,7 +24,7 @@ class POWER_SEQUENCER_OT_fade_clear(bpy.types.Operator): *brief* Removes fade animation from selected sequences. Removes opacity or volume animation on selected sequences and resets the - property to a value of 1.0. Works on all types of sequences. + property to a value of 1.0. Works on all types of sequences """ doc = { @@ -32,7 +32,11 @@ class POWER_SEQUENCER_OT_fade_clear(bpy.types.Operator): "demo": "", "description": doc_description(__doc__), "shortcuts": [ - ({"type": "F", "value": "PRESS", "alt": True, "ctrl": True}, {}, "Clear Fades") + ( + {"type": "F", "value": "PRESS", "alt": True, "ctrl": True}, + {}, + "Clear Fades", + ) ], "keymap": "Sequencer", } @@ -49,7 +53,9 @@ class POWER_SEQUENCER_OT_fade_clear(bpy.types.Operator): fcurves = context.scene.animation_data.action.fcurves for sequence in context.selected_sequences: - animated_property = "volume" if hasattr(sequence, "volume") else "blend_alpha" + animated_property = ( + "volume" if hasattr(sequence, "volume") else "blend_alpha" + ) data_path = sequence.path_from_id() + "." + animated_property fcurve_map = { curve.data_path: curve diff --git a/power_sequencer/operators/scene_merge_from.py b/power_sequencer/operators/scene_merge_from.py index 4e695b02..2908ebcd 100644 --- a/power_sequencer/operators/scene_merge_from.py +++ b/power_sequencer/operators/scene_merge_from.py @@ -16,7 +16,6 @@ # import bpy -from bpy.props import BoolProperty from .utils.doc import doc_name, doc_idname, doc_brief, doc_description @@ -27,7 +26,7 @@ class POWER_SEQUENCER_OT_merge_from_scene_strip(bpy.types.Operator): WARNING: Currently the operator doesn't recreate any animation data, - be careful by choosing to delete the scene after the merge. + be careful by choosing to delete the scene after the merge """ doc = { @@ -42,7 +41,7 @@ class POWER_SEQUENCER_OT_merge_from_scene_strip(bpy.types.Operator): bl_description = doc_brief(doc["description"]) bl_options = {"REGISTER", "UNDO"} - delete_scene: BoolProperty( + delete_scene: bpy.props.BoolProperty( name="Delete Strip's scene", description="Delete the SceneStrip's scene after the merging", default=True, @@ -75,7 +74,9 @@ class POWER_SEQUENCER_OT_merge_from_scene_strip(bpy.types.Operator): context.window.scene = strip_scene bpy.ops.scene.delete() context.window.scene = start_scene - self.report(type={"WARNING"}, message="Merged scenes lose all their animation data.") + self.report( + type={"WARNING"}, message="Merged scenes lose all their animation data." + ) return {"FINISHED"} diff --git a/power_sequencer/operators/select_all_left_or_right.py b/power_sequencer/operators/select_all_left_or_right.py index 9f570b4b..01e35306 100644 --- a/power_sequencer/operators/select_all_left_or_right.py +++ b/power_sequencer/operators/select_all_left_or_right.py @@ -21,7 +21,7 @@ from .utils.doc import doc_name, doc_idname, doc_brief, doc_description class POWER_SEQUENCER_OT_select_all_left_or_right(bpy.types.Operator): """ - *Brief* Selects all strips left or right of the time cursor. + *Brief* Selects all strips left or right of the time cursor """ doc = { diff --git a/power_sequencer/operators/snap.py b/power_sequencer/operators/snap.py index cee5ad56..42b029d1 100644 --- a/power_sequencer/operators/snap.py +++ b/power_sequencer/operators/snap.py @@ -24,7 +24,7 @@ class POWER_SEQUENCER_OT_snap(bpy.types.Operator): """ *Brief* Snaps selected strips to the time cursor ignoring locked sequences. - Automatically selects sequences if there is no active selection. + Automatically selects sequences if there is no active selection """ doc = { @@ -32,7 +32,11 @@ class POWER_SEQUENCER_OT_snap(bpy.types.Operator): "demo": "", "description": doc_description(__doc__), "shortcuts": [ - ({"type": "S", "value": "PRESS", "shift": True}, {}, "Snap sequences to cursor") + ( + {"type": "S", "value": "PRESS", "shift": True}, + {}, + "Snap sequences to cursor", + ) ], "keymap": "Sequencer", } diff --git a/power_sequencer/operators/snap_selection.py b/power_sequencer/operators/snap_selection.py index 7ad81b4d..5900579b 100644 --- a/power_sequencer/operators/snap_selection.py +++ b/power_sequencer/operators/snap_selection.py @@ -24,7 +24,7 @@ class POWER_SEQUENCER_OT_snap_selection(bpy.types.Operator): *Brief* Snap the entire selection to the time cursor. Automatically selects sequences if there is no active selection. - To snap each strip individually, see Snap. + To snap each strip individually, see Snap """ doc = { @@ -32,7 +32,11 @@ class POWER_SEQUENCER_OT_snap_selection(bpy.types.Operator): "demo": "", "description": doc_description(__doc__), "shortcuts": [ - ({"type": "S", "value": "PRESS", "alt": True}, {}, "Snap selection to cursor") + ( + {"type": "S", "value": "PRESS", "alt": True}, + {}, + "Snap selection to cursor", + ) ], "keymap": "Sequencer", } @@ -51,7 +55,9 @@ class POWER_SEQUENCER_OT_snap_selection(bpy.types.Operator): if context.selected_sequences else get_sequences_under_cursor(context) ) - frame_first = min(sequences, key=lambda s: s.frame_final_start).frame_final_start + frame_first = min( + sequences, key=lambda s: s.frame_final_start + ).frame_final_start time_offset = context.scene.frame_current - frame_first apply_time_offset(context, sequences, time_offset) return {"FINISHED"} diff --git a/power_sequencer/operators/trim_left_or_right_handles.py b/power_sequencer/operators/trim_left_or_right_handles.py index 675814ce..b93bee53 100644 --- a/power_sequencer/operators/trim_left_or_right_handles.py +++ b/power_sequencer/operators/trim_left_or_right_handles.py @@ -26,7 +26,7 @@ class POWER_SEQUENCER_OT_trim_left_or_right_handles(bpy.types.Operator): Trims or extends the handle closest to the time cursor for all selected strips. If you keep the Shift key down, the edit will ripple through the timeline. - Auto selects sequences under the time cursor when you don't have a selection. + Auto selects sequences under the time cursor when you don't have a selection """ doc = { @@ -78,9 +78,16 @@ class POWER_SEQUENCER_OT_trim_left_or_right_handles(bpy.types.Operator): frame_current = context.scene.frame_current # Only select sequences under the time cursor - sequences = context.selected_sequences if context.selected_sequences else context.sequences + sequences = ( + context.selected_sequences + if context.selected_sequences + else context.sequences + ) for s in sequences: - s.select = s.frame_final_start <= frame_current and s.frame_final_end >= frame_current + s.select = ( + s.frame_final_start <= frame_current + and s.frame_final_end >= frame_current + ) sequences = [s for s in sequences if s.select] if not sequences: return {"FINISHED"} -- cgit v1.2.3