Skip to content

Commit 2042227

Browse files
committed
Simplify code by combining 'or' statements
1 parent a17a730 commit 2042227

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

src/windows/add_to_timeline.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,15 @@ def accept(self):
242242
position = max(start_position, new_clip["position"] - fade_length)
243243
new_clip["position"] = position
244244

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

253-
if fade_value == 'Fade Out' or fade_value == 'Fade In & Out':
253+
if fade_value in ['Fade Out', 'Fade In & Out']:
254254
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)
255255
start_object = json.loads(start.Json())
256256
end = openshot.Point(round(end_time * fps_float) + 1, 0.0, openshot.BEZIER)

src/windows/views/blender_listview.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -843,9 +843,8 @@ def Render(self):
843843

844844
_ = get_app()._tr
845845

846-
if not self.version:
847-
if not self.blender_version_check():
848-
return
846+
if not self.version and not self.blender_version_check():
847+
return
849848

850849
self.command_output = ""
851850
self.current_frame = 0

src/windows/views/timeline_mixins.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,9 @@ def get_html(self):
133133
def keyPressEvent(self, event):
134134
""" Keypress callback for timeline """
135135
key_value = event.key()
136-
if (key_value == Qt.Key_Shift or key_value == Qt.Key_Control):
137-
136+
if key_value in [Qt.Key_Shift, Qt.Key_Control]:
138137
# Only pass a few keystrokes to the webview (CTRL and SHIFT)
139138
return QWebEngineView.keyPressEvent(self, event)
140-
141139
else:
142140
# Ignore most keypresses
143141
event.ignore()
@@ -212,11 +210,9 @@ def get_html(self):
212210
def keyPressEvent(self, event):
213211
""" Keypress callback for timeline """
214212
key_value = event.key()
215-
if (key_value == Qt.Key_Shift or key_value == Qt.Key_Control):
216-
213+
if key_value in [Qt.Key_Shift, Qt.Key_Control]:
217214
# Only pass a few keystrokes to the webview (CTRL and SHIFT)
218215
return QWebView.keyPressEvent(self, event)
219-
220216
else:
221217
# Ignore most keypresses
222218
event.ignore()

src/windows/views/timeline_webview.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1183,11 +1183,11 @@ def Layout_Triggered(self, action, clip_ids):
11831183
clip.data["location_x"] = {"Points": [p_object]}
11841184
clip.data["location_y"] = {"Points": [p_object]}
11851185

1186-
if action == MENU_LAYOUT_CENTER or \
1187-
action == MENU_LAYOUT_TOP_LEFT or \
1188-
action == MENU_LAYOUT_TOP_RIGHT or \
1189-
action == MENU_LAYOUT_BOTTOM_LEFT or \
1190-
action == MENU_LAYOUT_BOTTOM_RIGHT:
1186+
if action in [MENU_LAYOUT_CENTER,
1187+
MENU_LAYOUT_TOP_LEFT,
1188+
MENU_LAYOUT_TOP_RIGHT,
1189+
MENU_LAYOUT_BOTTOM_LEFT,
1190+
MENU_LAYOUT_BOTTOM_RIGHT]:
11911191
# Reset scale mode
11921192
clip.data["scale"] = openshot.SCALE_FIT
11931193
clip.data["gravity"] = new_gravity
@@ -1437,7 +1437,7 @@ def Copy_Triggered(self, action, clip_ids, tran_ids):
14371437

14381438
self.copy_clipboard[clip_id] = {}
14391439

1440-
if action == MENU_COPY_CLIP or action == MENU_COPY_ALL:
1440+
if action in [MENU_COPY_CLIP, MENU_COPY_ALL]:
14411441
self.copy_clipboard[clip_id] = clip.data
14421442
elif action == MENU_COPY_KEYFRAMES_ALL:
14431443
self.copy_clipboard[clip_id]['alpha'] = clip.data['alpha']
@@ -1480,7 +1480,7 @@ def Copy_Triggered(self, action, clip_ids, tran_ids):
14801480

14811481
self.copy_transition_clipboard[tran_id] = {}
14821482

1483-
if action == MENU_COPY_TRANSITION or action == MENU_COPY_ALL:
1483+
if action in [MENU_COPY_TRANSITION, MENU_COPY_ALL]:
14841484
self.copy_transition_clipboard[tran_id] = tran.data
14851485
elif action == MENU_COPY_KEYFRAMES_ALL:
14861486
self.copy_transition_clipboard[tran_id]['brightness'] = tran.data['brightness']
@@ -1891,7 +1891,7 @@ def Slice_Triggered(self, action, clip_ids, trans_ids, playhead_position=0):
18911891
# Determine if waveform needs to be redrawn
18921892
has_audio_data = clip_id in self.waveform_cache
18931893

1894-
if action == MENU_SLICE_KEEP_LEFT or action == MENU_SLICE_KEEP_BOTH:
1894+
if action in [MENU_SLICE_KEEP_LEFT, MENU_SLICE_KEEP_BOTH]:
18951895
# Get details of original clip
18961896
position_of_clip = float(clip.data["position"])
18971897
start_of_clip = float(clip.data["start"])
@@ -1954,7 +1954,7 @@ def Slice_Triggered(self, action, clip_ids, trans_ids, playhead_position=0):
19541954
# Invalid transition, skip to next item
19551955
continue
19561956

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

0 commit comments

Comments
 (0)