Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify code by combining 'or' statements #3756

Merged
merged 2 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/windows/add_to_timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,15 @@ def accept(self):
position = max(start_position, new_clip["position"] - fade_length)
new_clip["position"] = position

if fade_value == 'Fade In' or fade_value == 'Fade In & Out':
if fade_value in ['Fade In', 'Fade In & Out']:
start = openshot.Point(round(start_time * fps_float) + 1, 0.0, openshot.BEZIER)
start_object = json.loads(start.Json())
end = openshot.Point(min(round((start_time + fade_length) * fps_float) + 1, round(end_time * fps_float) + 1), 1.0, openshot.BEZIER)
end_object = json.loads(end.Json())
new_clip['alpha']["Points"].append(start_object)
new_clip['alpha']["Points"].append(end_object)

if fade_value == 'Fade Out' or fade_value == 'Fade In & Out':
if fade_value in ['Fade Out', 'Fade In & Out']:
start = openshot.Point(max(round((end_time * fps_float) + 1) - (round(fade_length * fps_float) + 1), round(start_time * fps_float) + 1), 1.0, openshot.BEZIER)
start_object = json.loads(start.Json())
end = openshot.Point(round(end_time * fps_float) + 1, 0.0, openshot.BEZIER)
Expand Down
5 changes: 2 additions & 3 deletions src/windows/views/blender_listview.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,9 +839,8 @@ def Render(self):

_ = get_app()._tr

if not self.version:
if not self.blender_version_check():
return
if not self.version and not self.blender_version_check():
return

self.command_output = ""
self.current_frame = 0
Expand Down
6 changes: 2 additions & 4 deletions src/windows/views/timeline_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,9 @@ def get_html(self):
def keyPressEvent(self, event):
""" Keypress callback for timeline """
key_value = event.key()
if (key_value == Qt.Key_Shift or key_value == Qt.Key_Control):

if key_value in [Qt.Key_Shift, Qt.Key_Control]:
# Only pass a few keystrokes to the webview (CTRL and SHIFT)
return QWebEngineView.keyPressEvent(self, event)

else:
# Ignore most keypresses
event.ignore()
Expand Down Expand Up @@ -245,7 +243,7 @@ def get_html(self):
def keyPressEvent(self, event):
""" Keypress callback for timeline """
key_value = event.key()
if (key_value == Qt.Key_Shift or key_value == Qt.Key_Control):
if key_value in [Qt.Key_Shift, Qt.Key_Control]:
# Only pass a few keystrokes to the webview (CTRL and SHIFT)
return QWebView.keyPressEvent(self, event)
else:
Expand Down
18 changes: 9 additions & 9 deletions src/windows/views/timeline_webview.py
Original file line number Diff line number Diff line change
Expand Up @@ -1178,11 +1178,11 @@ def Layout_Triggered(self, action, clip_ids):
clip.data["location_x"] = {"Points": [p_object]}
clip.data["location_y"] = {"Points": [p_object]}

if action == MENU_LAYOUT_CENTER or \
action == MENU_LAYOUT_TOP_LEFT or \
action == MENU_LAYOUT_TOP_RIGHT or \
action == MENU_LAYOUT_BOTTOM_LEFT or \
action == MENU_LAYOUT_BOTTOM_RIGHT:
if action in [MENU_LAYOUT_CENTER,
MENU_LAYOUT_TOP_LEFT,
MENU_LAYOUT_TOP_RIGHT,
MENU_LAYOUT_BOTTOM_LEFT,
MENU_LAYOUT_BOTTOM_RIGHT]:
# Reset scale mode
clip.data["scale"] = openshot.SCALE_FIT
clip.data["gravity"] = new_gravity
Expand Down Expand Up @@ -1432,7 +1432,7 @@ def Copy_Triggered(self, action, clip_ids, tran_ids):

self.copy_clipboard[clip_id] = {}

if action == MENU_COPY_CLIP or action == MENU_COPY_ALL:
if action in [MENU_COPY_CLIP, MENU_COPY_ALL]:
self.copy_clipboard[clip_id] = clip.data
elif action == MENU_COPY_KEYFRAMES_ALL:
self.copy_clipboard[clip_id]['alpha'] = clip.data['alpha']
Expand Down Expand Up @@ -1475,7 +1475,7 @@ def Copy_Triggered(self, action, clip_ids, tran_ids):

self.copy_transition_clipboard[tran_id] = {}

if action == MENU_COPY_TRANSITION or action == MENU_COPY_ALL:
if action in [MENU_COPY_TRANSITION, MENU_COPY_ALL]:
self.copy_transition_clipboard[tran_id] = tran.data
elif action == MENU_COPY_KEYFRAMES_ALL:
self.copy_transition_clipboard[tran_id]['brightness'] = tran.data['brightness']
Expand Down Expand Up @@ -1886,7 +1886,7 @@ def Slice_Triggered(self, action, clip_ids, trans_ids, playhead_position=0):
# Determine if waveform needs to be redrawn
has_audio_data = clip_id in self.waveform_cache

if action == MENU_SLICE_KEEP_LEFT or action == MENU_SLICE_KEEP_BOTH:
if action in [MENU_SLICE_KEEP_LEFT, MENU_SLICE_KEEP_BOTH]:
# Get details of original clip
position_of_clip = float(clip.data["position"])
start_of_clip = float(clip.data["start"])
Expand Down Expand Up @@ -1949,7 +1949,7 @@ def Slice_Triggered(self, action, clip_ids, trans_ids, playhead_position=0):
# Invalid transition, skip to next item
continue

if action == MENU_SLICE_KEEP_LEFT or action == MENU_SLICE_KEEP_BOTH:
if action in [MENU_SLICE_KEEP_LEFT, MENU_SLICE_KEEP_BOTH]:
# Get details of original transition
position_of_tran = float(trans.data["position"])

Expand Down