Skip to content

Commit 917c125

Browse files
authored
Merge pull request #3738 from MartinThoma/simplify-0.4
STY: Simplify the code
2 parents d07defe + 98d6e5a commit 917c125

20 files changed

+145
-124
lines changed

installer/analyze_bundle.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
file_path = os.path.join(root, basename)
1212

1313
output = str(subprocess.Popen(["oTool", "-L", file_path], stdout=subprocess.PIPE).communicate()[0])
14-
if not "is not an object file" in output:
14+
if "is not an object file" not in output:
1515
dependency_path = output.replace('\\n','').split('\\t')[1].split(' ')[0]
1616
dependency_version = output.replace('\\n','').split('\\t')[1].split(' (')[1].replace(')','')
1717

18-
if "@executable_path" not in dependency_path:
19-
if not dependency_path in unique_dependencies.keys():
20-
unique_dependencies[dependency_path] = file_path
21-
print("%s => %s (%s)" % (basename, dependency_path, dependency_version))
18+
if "@executable_path" not in dependency_path and dependency_path not in unique_dependencies.keys():
19+
unique_dependencies[dependency_path] = file_path
20+
print("%s => %s (%s)" % (basename, dependency_path, dependency_version))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
# For Debian packaging it could be a fakeroot so reset flag to prevent execution of
5959
# system update services for Mime and Desktop registrations.
6060
# The debian/openshot.postinst script must do those.
61-
if not os.getenv("FAKEROOTKEY") == None:
61+
if os.getenv("FAKEROOTKEY") is not None:
6262
log.info("NOTICE: Detected execution in a FakeRoot so disabling calls to system update services.")
6363
ROOT = False
6464

src/classes/image_types.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,17 @@ def is_image(file):
2929
"""Check a File object if the file extension is a known image format"""
3030
path = file["path"].lower()
3131

32-
if path.endswith((".jpg", ".jpeg", ".png", ".bmp", ".svg", ".thm", ".gif", ".bmp", ".pgm", ".tif", ".tiff")):
33-
return True
34-
else:
35-
return False
32+
img_file_extensions = (
33+
".jpg",
34+
".jpeg",
35+
".png",
36+
".bmp",
37+
".svg",
38+
".thm",
39+
".gif",
40+
".bmp",
41+
".pgm",
42+
".tif",
43+
".tiff",
44+
)
45+
return path.endswith(img_file_extensions)

src/classes/logger_libopenshot.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,8 @@ def run(self):
7777

7878
# Receive all debug message sent from libopenshot (if any)
7979
socks = dict(poller.poll(1000))
80-
if socks:
81-
if socks.get(socket) == zmq.POLLIN:
82-
msg = socket.recv(zmq.NOBLOCK)
80+
if socks and socks.get(socket) == zmq.POLLIN:
81+
msg = socket.recv(zmq.NOBLOCK)
8382

84-
# Log the message (if any)
8583
if msg:
8684
log.info(msg.strip().decode('UTF-8'))

src/classes/query.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,17 @@ def filter(OBJECT_TYPE, **kwargs):
113113
match = True
114114
for key, value in kwargs.items():
115115

116-
# Equals
117-
if key in child and not child[key] == value:
116+
if key in child and child[key] != value:
118117
match = False
119118
break
120119

121120
# Intersection Position
122-
if key == "intersect":
123-
if (child.get("position", 0) > value or
124-
child.get("position", 0) + (child.get("end", 0) - child.get("start", 0)) < value):
125-
match = False
121+
if key == "intersect" and (
122+
child.get("position", 0) > value
123+
or child.get("position", 0) + (child.get("end", 0) - child.get("start", 0)) < value
124+
):
125+
match = False
126+
126127

127128
# Add matched record
128129
if match:
@@ -341,7 +342,7 @@ def filter(**kwargs):
341342
# Loop through all kwargs (and look for matches)
342343
match = True
343344
for key, value in kwargs.items():
344-
if key in child and not child[key] == value:
345+
if key in child and child[key] != value:
345346
match = False
346347
break
347348

src/classes/ui_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def load_theme():
5555
s = settings.get_settings()
5656

5757
# If theme not reported by OS
58-
if QIcon.themeName() == '' and not s.get("theme") == "No Theme":
58+
if QIcon.themeName() == '' and s.get("theme") != "No Theme":
5959

6060
# Address known Ubuntu bug of not reporting configured theme name, use default ubuntu theme
6161
if os.getenv('DESKTOP_SESSION') == 'ubuntu':

src/tests/query_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import sys, os
2929
# Import parent folder (so it can find other imports)
3030
PATH = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
31-
if not PATH in sys.path:
31+
if PATH not in sys.path:
3232
sys.path.append(PATH)
3333

3434
import random

src/windows/main_window.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def closeEvent(self, event):
114114
self.tutorial_manager.hide_dialog()
115115

116116
# Prompt user to save (if needed)
117-
if app.project.needs_save() and not self.mode == "unittest":
117+
if app.project.needs_save() and self.mode != "unittest":
118118
log.info('Prompt user to save project')
119119
# Translate object
120120
_ = app._tr
@@ -751,10 +751,7 @@ def promptImageSequence(self, filename=None):
751751
_("Would you like to import %s as an image sequence?") % filename,
752752
QMessageBox.No | QMessageBox.Yes
753753
)
754-
if ret == QMessageBox.Yes:
755-
return True
756-
else:
757-
return False
754+
return bool(ret == QMessageBox.Yes)
758755

759756
def actionAdd_to_Timeline_trigger(self, event):
760757
# Loop through selected files
@@ -2663,7 +2660,7 @@ def __init__(self, mode=None):
26632660
get_current_Version()
26642661

26652662
# Connect signals
2666-
if not self.mode == "unittest":
2663+
if self.mode != "unittest":
26672664
self.RecoverBackup.connect(self.recover_backup)
26682665

26692666
# Initialize and start the thumbnail HTTP server
@@ -2860,7 +2857,7 @@ def __init__(self, mode=None):
28602857
self.OpenProjectSignal.connect(self.open_project)
28612858

28622859
# Show window
2863-
if not self.mode == "unittest":
2860+
if self.mode != "unittest":
28642861
self.show()
28652862
else:
28662863
log.info('Hiding UI for unittests')

src/windows/models/blender_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def update_model(self, clear=True):
149149
row.append(col)
150150

151151
# Append ROW to MODEL (if does not already exist in model)
152-
if not path in self.model_paths:
152+
if path not in self.model_paths:
153153
self.model.appendRow(row)
154154
self.model_paths[path] = path
155155

src/windows/models/changelog_model.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,14 @@ def update_model(self, filter=None, clear=True):
6666
author_str = commit.get("author", "")
6767
subject_str = commit.get("subject", "")
6868

69-
if filter:
70-
if not (filter.lower() in hash_str.lower() or filter.lower() in date_str.lower() or filter.lower() in author_str.lower() or filter.lower() in subject_str.lower()):
71-
continue
69+
if filter and not (
70+
filter.lower() in hash_str.lower()
71+
or filter.lower() in date_str.lower()
72+
or filter.lower() in author_str.lower()
73+
or filter.lower() in subject_str.lower()
74+
):
75+
continue
76+
7277

7378
row = []
7479

0 commit comments

Comments
 (0)