LGTM.patch (14,302 bytes)
From 2c7a00c700750fa27ed31fd5336ee26340b81a61 Mon Sep 17 00:00:00 2001
From: luz paz <luzpaz@users.noreply.github.com>
Date: Sat, 18 Sep 2021 10:27:19 -0400
Subject: [PATCH 1/2] Fix LGTM 'Testing equality to None' warning
Ref: https://lgtm.com/projects/g/scribusproject/scribus?mode=tree&ruleFocus=7900090
---
OSX-package/linktools/MachO.py | 2 +-
OSX-package/linktools/ingest.py | 4 ++--
OSX-package/linktools/mkappbundle.py | 4 ++--
OSX-package/linktools/mkframework.py | 4 ++--
codegen/fromrelaxng/impldescription.py | 4 ++--
codegen/fromrelaxng/parserng.py | 2 +-
scribus/plugins/scripter/python/sceditor/console.py | 2 +-
scribus/plugins/scripter/python/sceditor/widget.py | 2 +-
8 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/OSX-package/linktools/MachO.py b/OSX-package/linktools/MachO.py
index 847d539d9f..4ce159ab96 100644
--- a/OSX-package/linktools/MachO.py
+++ b/OSX-package/linktools/MachO.py
@@ -7,7 +7,7 @@ def findFramework(path, name = None):
"find the framework folder for FW name"
if path == "" or path == "@executable_path" or path == "/":
return None
- elif name == None:
+ elif name is None:
return findFramework(os.path.dirname(path),
os.path.basename(path))
elif os.path.basename(path) == name + ".framework":
diff --git a/OSX-package/linktools/ingest.py b/OSX-package/linktools/ingest.py
index 71a9d07b2f..d53d451fae 100755
--- a/OSX-package/linktools/ingest.py
+++ b/OSX-package/linktools/ingest.py
@@ -48,7 +48,7 @@ while argp < len(sys.argv) :
print "Error: unknown option: " + sys.argv[argp]
usage()
sys.exit(1)
- elif bundle == None:
+ elif bundle is None:
bundle = sys.argv[argp]
argp = argp + 1
else:
@@ -56,7 +56,7 @@ while argp < len(sys.argv) :
usage()
sys.exit(1)
-if bundle == None:
+if bundle is None:
print "Error: no bundle path specified!"
usage()
sys.exit(1)
diff --git a/OSX-package/linktools/mkappbundle.py b/OSX-package/linktools/mkappbundle.py
index a8eff74c3c..7b51eda715 100755
--- a/OSX-package/linktools/mkappbundle.py
+++ b/OSX-package/linktools/mkappbundle.py
@@ -48,7 +48,7 @@ while argp < len(sys.argv) :
print "Error: unknown option: " + sys.argv[argp]
usage()
sys.exit(1)
- elif bundle == None:
+ elif bundle is None:
bundle = sys.argv[argp]
argp = argp + 1
else:
@@ -56,7 +56,7 @@ while argp < len(sys.argv) :
usage()
sys.exit(1)
-if bundle == None:
+if bundle is None:
print "Error: no bundle path specified!"
usage()
sys.exit(1)
diff --git a/OSX-package/linktools/mkframework.py b/OSX-package/linktools/mkframework.py
index c29e8479fa..c0d05258e9 100755
--- a/OSX-package/linktools/mkframework.py
+++ b/OSX-package/linktools/mkframework.py
@@ -53,7 +53,7 @@ while argp < len(sys.argv) :
print "Error: unknown option: " + sys.argv[argp]
usage()
sys.exit(1)
- elif bundle == None:
+ elif bundle is None:
bundle = sys.argv[argp]
argp = argp + 1
else:
@@ -61,7 +61,7 @@ while argp < len(sys.argv) :
usage()
sys.exit(1)
-if bundle == None:
+if bundle is None:
print "Error: no bundle path specified!"
usage()
sys.exit(1)
diff --git a/codegen/fromrelaxng/impldescription.py b/codegen/fromrelaxng/impldescription.py
index ec80e7e4c2..3fa8264af9 100644
--- a/codegen/fromrelaxng/impldescription.py
+++ b/codegen/fromrelaxng/impldescription.py
@@ -54,9 +54,9 @@ class Class(object):
def addIncludes(self, datatypes, refnames):
#print datatypes, refnames
for p in self.properties:
- if p.datatype == None and p.refname in refnames:
+ if p.datatype is None and p.refname in refnames:
p.datatype = refnames[p.refname].datatype
- if p.datatype == None:
+ if p.datatype is None:
print "X>>>", p.name, p.refname, refnames
if p.datatype.find("<") > 0:
diff --git a/codegen/fromrelaxng/parserng.py b/codegen/fromrelaxng/parserng.py
index 72d9367a18..51aec183e4 100644
--- a/codegen/fromrelaxng/parserng.py
+++ b/codegen/fromrelaxng/parserng.py
@@ -27,7 +27,7 @@ class RNG_Parser(object):
self.currentClass = c
elif self.currentClass != None:
newProp = Property(pattern, isOptional, isCollection)
- if newProp.datatype == None:
+ if newProp.datatype is None:
ref = pattern.getchildren()[0]
if ref.tag == qn('rng:ref'):
newProp.refname = ref.get(an('name'))
diff --git a/scribus/plugins/scripter/python/sceditor/console.py b/scribus/plugins/scripter/python/sceditor/console.py
index f0601e1800..8d22be1599 100644
--- a/scribus/plugins/scripter/python/sceditor/console.py
+++ b/scribus/plugins/scripter/python/sceditor/console.py
@@ -157,7 +157,7 @@ class PythonInterpreter(object):
def run(self, source, locals=None):
- if locals == None:
+ if locals is None:
locals = self.locals
code = compile(source, self.name, "exec")
try:
diff --git a/scribus/plugins/scripter/python/sceditor/widget.py b/scribus/plugins/scripter/python/sceditor/widget.py
index 4c70f07427..74ec2f435e 100644
--- a/scribus/plugins/scripter/python/sceditor/widget.py
+++ b/scribus/plugins/scripter/python/sceditor/widget.py
@@ -58,7 +58,7 @@ class RopeEditorWrapper(object):
def _get_block(self, line_no=None):
cursor = self.editview.textCursor()
row = cursor.blockNumber()
- if line_no == None:
+ if line_no is None:
line_no = row
block = cursor.block()
while row > line_no:
--
2.33.0
From 4329d5edef95f45a124c5c47131802b5b922db63 Mon Sep 17 00:00:00 2001
From: luz paz <luzpaz@users.noreply.github.com>
Date: Sat, 18 Sep 2021 10:29:03 -0400
Subject: [PATCH 2/2] Fix 'Testing equality to None' warning cont.
---
OSX-package/linktools/MachO.py | 10 +++++-----
OSX-package/linktools/mkappbundle.py | 2 +-
OSX-package/linktools/mkframework.py | 2 +-
codegen/fromrelaxng/impldescription.py | 10 +++++-----
codegen/fromrelaxng/parserng.py | 8 ++++----
scribus/plugins/scripter/new_api.py | 2 +-
scribus/plugins/scriptplugin/scripts/CalendarWizard.py | 2 +-
.../scriptplugin_py2x/scripts/CalendarWizard.py | 2 +-
8 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/OSX-package/linktools/MachO.py b/OSX-package/linktools/MachO.py
index 4ce159ab96..9d5998af14 100644
--- a/OSX-package/linktools/MachO.py
+++ b/OSX-package/linktools/MachO.py
@@ -54,7 +54,7 @@ class Executable:
pat = re.compile("\s*([^(]*)\s\((.+)\)")
for line in f:
m = pat.match(line)
- if m != None:
+ if m is not None:
result.append(Fix(m.group(1), m.group(2)))
status = f.close()
return result
@@ -87,11 +87,11 @@ def findExecutables(bundleDir):
p = os.path.join(root, n)
f = os.popen("file -b " + p, "r")
m = pat.match(f.readline())
- if m != None:
+ if m is not None:
result.append(Executable(p, m.group(1)))
print "found " + m.group(1) + ": " + n
f.close()
- return result
+ return result
@@ -130,7 +130,7 @@ class Fix:
def findLocation(self, exePath=None):
if self.isBundleRelative():
- if exePath != None:
+ if exePath is not None:
self.Location = os.path.normpath(
os.path.join(exePath, self.Link[17:]))
else:
@@ -183,7 +183,7 @@ class Fix:
log.append("-- ignoring " + self.Location)
return []
- if self.relPath != None and not stripFW:
+ if self.relPath is not None and not stripFW:
# copy framework
newFwPath = os.path.join(destBundlePath,
"Contents/Frameworks",
diff --git a/OSX-package/linktools/mkappbundle.py b/OSX-package/linktools/mkappbundle.py
index 7b51eda715..cc74667ccf 100755
--- a/OSX-package/linktools/mkappbundle.py
+++ b/OSX-package/linktools/mkappbundle.py
@@ -80,7 +80,7 @@ binPath = os.path.join(bundle, "Contents/MacOS")
if not os.path.exists(binPath):
os.makedirs(binPath, 0755)
-if binfile != None:
+if binfile is not None:
shutil.copy(binfile, os.path.join(binPath, appName))
shutil.copy(infofile, os.path.join(bundle, "Contents/Info.plist")
diff --git a/OSX-package/linktools/mkframework.py b/OSX-package/linktools/mkframework.py
index c0d05258e9..67a1a521a1 100755
--- a/OSX-package/linktools/mkframework.py
+++ b/OSX-package/linktools/mkframework.py
@@ -92,7 +92,7 @@ if os.path.exists(versionPath):
os.makedirs(versionPath, 0755)
-if libfile != None:
+if libfile is not None:
shutil.copy(libfile, os.path.join(versionPath, fwName))
os.system("install_name_tool -id @executable_path/" +
os.path.join("../Frameworks",
diff --git a/codegen/fromrelaxng/impldescription.py b/codegen/fromrelaxng/impldescription.py
index 3fa8264af9..0867268d90 100644
--- a/codegen/fromrelaxng/impldescription.py
+++ b/codegen/fromrelaxng/impldescription.py
@@ -91,16 +91,16 @@ class Class(object):
# this might not be enough:
reference = dt
- if include != None and include[0] != "<" and include[0] != '"':
+ if include is not None and include[0] != "<" and include[0] != '"':
include = '"' + include + '"'
- if reference != None:
+ if reference is not None:
if reference not in self.classreferences:
self.classreferences.append(reference)
- if include != None and include not in self.classincludes and include not in self.includes:
+ if include is not None and include not in self.classincludes and include not in self.includes:
self.classincludes.append(include)
else:
- if include != None and include not in self.includes:
+ if include is not None and include not in self.includes:
self.includes.append(include)
if include in self.classincludes:
self.classincludes.remove(include)
@@ -144,7 +144,7 @@ class Property(object):
if self.datatype is None:
dt = xml.find(qn('rng:data'))
- if dt != None:
+ if dt is not None:
xsltype = dt.get(an('type'))
self.datatype = xsltype if xsltype not in self.dataTypes else self.dataTypes[xsltype]
diff --git a/codegen/fromrelaxng/parserng.py b/codegen/fromrelaxng/parserng.py
index 51aec183e4..2192fdd1d8 100644
--- a/codegen/fromrelaxng/parserng.py
+++ b/codegen/fromrelaxng/parserng.py
@@ -19,13 +19,13 @@ class RNG_Parser(object):
if pattern.tag == qn('element'):
if pattern.get(an('impl:type')) == "ignore":
pass;
- elif pattern.get(an('impl:template')) != None:
+ elif pattern.get(an('impl:template')) is not None:
c = self.currentClass
self.currentClass = Class(pattern)
self.classes.append(self.currentClass)
self.parsePatterns(pattern.getchildren(), False, False)
self.currentClass = c
- elif self.currentClass != None:
+ elif self.currentClass is not None:
newProp = Property(pattern, isOptional, isCollection)
if newProp.datatype is None:
ref = pattern.getchildren()[0]
@@ -39,7 +39,7 @@ class RNG_Parser(object):
elif pattern.tag == qn('attribute'):
if pattern.get(an('impl:type')) == "ignore":
pass;
- elif self.currentClass != None:
+ elif self.currentClass is not None:
self.currentClass.properties.append(Property(pattern, isOptional, isCollection))
elif pattern.tag == qn('group'):
@@ -112,7 +112,7 @@ class RNG_Parser(object):
self.definitions[rule.get(an('name'))] = rule.getchildren()
if rule.get(an('impl:type')) == "ignore":
pass
- elif rule.get(an('impl:template')) != None:
+ elif rule.get(an('impl:template')) is not None:
c = self.currentClass
self.currentClass = Class(rule)
self.refnames[rule.get(an('name'))] = self.currentClass
diff --git a/scribus/plugins/scripter/new_api.py b/scribus/plugins/scripter/new_api.py
index fa18f46ee8..8abcbc5428 100755
--- a/scribus/plugins/scripter/new_api.py
+++ b/scribus/plugins/scripter/new_api.py
@@ -8,7 +8,7 @@ cc_re = re.compile("([A-Z][a-z]+)")
def is_camelcase(s):
- return cc_re.match(s) != None
+ return cc_re.match(s) is not None
def to_camelcase(s):
diff --git a/scribus/plugins/scriptplugin/scripts/CalendarWizard.py b/scribus/plugins/scriptplugin/scripts/CalendarWizard.py
index 4a13b75079..d1b24154d9 100644
--- a/scribus/plugins/scriptplugin/scripts/CalendarWizard.py
+++ b/scribus/plugins/scriptplugin/scripts/CalendarWizard.py
@@ -649,7 +649,7 @@ class TkCalendar(Frame):
cal = ScVerticalEventCalendar(year, months, self.weekVar.get(), draw, self.sepMonthsVar.get(), self.key)
self.master.withdraw()
err = cal.createCalendar()
- if err != None:
+ if err is not None:
self.master.deiconify()
self.statusVar.set(err)
else:
diff --git a/scribus/plugins/scriptplugin_py2x/scripts/CalendarWizard.py b/scribus/plugins/scriptplugin_py2x/scripts/CalendarWizard.py
index bf413e8276..5de140a037 100644
--- a/scribus/plugins/scriptplugin_py2x/scripts/CalendarWizard.py
+++ b/scribus/plugins/scriptplugin_py2x/scripts/CalendarWizard.py
@@ -649,7 +649,7 @@ class TkCalendar(Frame):
cal = ScVerticalEventCalendar(year, months, self.weekVar.get(), draw, self.sepMonthsVar.get(), self.key)
self.master.withdraw()
err = cal.createCalendar()
- if err != None:
+ if err is not None:
self.master.deiconify()
self.statusVar.set(err)
else:
--
2.33.0