Skip to content

Commit

Permalink
LGTM: various fixes for using string operator instead of numeric
Browse files Browse the repository at this point in the history
  • Loading branch information
luzpaz authored and yorikvanhavre committed Oct 25, 2019
1 parent e4c8890 commit 1bc3302
Show file tree
Hide file tree
Showing 23 changed files with 49 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/Mod/Part/JoinFeatures.py
Expand Up @@ -123,7 +123,7 @@ def __init__(self,vobj):
vobj.Proxy = self

def getIcon(self):
if self.Object == None:
if self.Object is None:
return getIconPath("Part_JoinConnect.svg")
else:
return getIconPath( {
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Part/MakeBottle.py
Expand Up @@ -67,7 +67,7 @@ def makeBottle(myWidth=50.0, myHeight=70.0, myThickness=30.0):

def makeBoreHole():
# create a document if needed
if App.ActiveDocument == None:
if App.ActiveDocument is None:
App.newDocument("Solid")

Group = App.ActiveDocument.addObject("App::DocumentObjectGroup","Group")
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/PartDesign/FeatureHole/FeatureHole.py
Expand Up @@ -101,7 +101,7 @@ def execute(self, feature):

def onChanged(self, fp, prop):
#self.App.Console.PrintMessage("Change property: " + str(prop) + "\n")
if fp == None or fp.Support == None:
if fp is None or fp.Support is None:
return

if (prop == "HoleType" or prop == "Threaded" or prop == "Counterbore" or prop == "Countersink"
Expand All @@ -116,7 +116,7 @@ def onChanged(self, fp, prop):

def executePositionChanged(self, fp):
"Change the position of the hole"
if fp.Support == None:
if fp.Support is None:
return
plane = self.feature.HoleGroove.Sketch.Support[0]
# Get support (face)
Expand All @@ -134,7 +134,7 @@ def executePositionChanged(self, fp):
firstLine = None
for e in wire.Edges:
if type(e.Curve) == Part.LineSegment:
if firstLine == None:
if firstLine is None:
firstLine = e
firstDirection = e.Curve.EndPoint - e.Curve.StartPoint
else:
Expand Down Expand Up @@ -274,7 +274,7 @@ def setHoleDirection(self, feature):

def executeSketchChanged(self, fp):
"Change the sketch shape of the hole"
if self.feature.HoleGroove == None:
if self.feature.HoleGroove is None:
return
if fp.HoleType == "Thru":
# TODO: Make this more stable
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/PartDesign/FeatureHole/HoleGui.py
Expand Up @@ -46,7 +46,7 @@ def Activated(self):

# Get active document
doc = FreeCAD.activeDocument()
if doc == None:
if doc is None:
QtGui.QMessageBox.critical(mw, "No document", "A document must be open in order to create a hole feature")
return

Expand All @@ -62,7 +62,7 @@ def Activated(self):

# Show feature preview
body = FreeCADGui.activeView().getActiveObject("pdbody");
if body == None:
if body is None:
QtGui.QMessageBox.critical(mw, "No active body", "Please create a body or make a body active")

feature = doc.addObject("Part::FeaturePython","Hole")
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/PartDesign/FeatureHole/TaskHole.py
Expand Up @@ -94,7 +94,7 @@ def getMainWindow(self):
def setupUi(self):
mw = self.getMainWindow()
form = mw.findChild(QtGui.QWidget, "TaskHole")
if form == None:
if form is None:
return
form.tabWidget = form.findChild(QtGui.QTabWidget, "tabWidget")
# Type
Expand Down Expand Up @@ -367,7 +367,7 @@ def updateUI(self):
self.form.spinThreadLength.setValue(self.feature.ThreadLength)
# Position
self.form.buttonSupport.setText("Face")
if self.feature.Support == None:
if self.feature.Support is None:
# First-time initialization
selection = FreeCADGui.Selection.getSelectionEx()
self.feature.Support = (selection[0].Object, selection[0].SubElementNames)
Expand Down
3 changes: 1 addition & 2 deletions src/Mod/PartDesign/Scripts/DistanceBolt.py
Expand Up @@ -56,10 +56,9 @@ def execute(self, fp):

def makeDistanceBolt():
doc = FreeCAD.activeDocument()
if doc == None:
if doc is None:
doc = FreeCAD.newDocument()
bolt=doc.addObject("Part::FeaturePython","Distance_Bolt")
bolt.Label = "Distance bolt"
DistanceBolt(bolt)
bolt.ViewObject.Proxy=0

2 changes: 1 addition & 1 deletion src/Mod/PartDesign/Scripts/Epitrochoid.py
Expand Up @@ -57,7 +57,7 @@ def execute(self, fp): #main part of script

def makeEpitrochoid():
doc = FreeCAD.activeDocument()
if doc == None:
if doc is None:
doc = FreeCAD.newDocument()
epitrochoid=doc.addObject("Part::FeaturePython","Epitrochoid") #add object to document
epitrochoid.Label = "Epitrochoid"
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/PartDesign/Scripts/Gear.py
Expand Up @@ -17,8 +17,8 @@ def proceed():

def compute():
QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
if FreeCAD.ActiveDocument==None:

if FreeCAD.ActiveDocument is None:
FreeCAD.newDocument("Gear")

oldDocumentObjects=App.ActiveDocument.Objects
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/PartDesign/Scripts/Parallelepiped.py
Expand Up @@ -64,7 +64,7 @@ def execute(self, fp):

def makeParallelepiped():
doc = FreeCAD.activeDocument()
if doc == None:
if doc is None:
doc = FreeCAD.newDocument()
obj=doc.addObject("Part::FeaturePython","Parallelepiped")
obj.Label = "Parallelepiped"
Expand All @@ -74,7 +74,7 @@ def makeParallelepiped():

def makeBoxCylinder():
doc = FreeCAD.activeDocument()
if doc == None:
if doc is None:
doc = FreeCAD.newDocument()
cyl=doc.addObject("Part::Cylinder","Cylinder")
cyl.Radius=16.0
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/PartDesign/Scripts/Spring.py
Expand Up @@ -39,7 +39,7 @@ def execute(self, fp):

def makeMySpring():
doc = FreeCAD.activeDocument()
if doc == None:
if doc is None:
doc = FreeCAD.newDocument()
spring=doc.addObject("Part::FeaturePython","My_Spring")
spring.Label = "My Spring"
Expand Down
10 changes: 5 additions & 5 deletions src/Mod/PartDesign/WizardShaft/Shaft.py
Expand Up @@ -213,7 +213,7 @@ def showDiagram(self, which):
if which in self.Fstr:
ax = self.Fstr.index(which)
text = self.Qstrings[ax]
if self.F[ax] == None:
if self.F[ax] is None:
# No data
return
if self.F[ax].name in self.diagrams:
Expand All @@ -226,7 +226,7 @@ def showDiagram(self, which):
elif which in self.Mstr:
ax = self.Mstr.index(which)
text = self.Mstrings[ax]
if self.M[ax] == None:
if self.M[ax] is None:
# No data
return
if self.M[ax].name in self.diagrams:
Expand All @@ -239,7 +239,7 @@ def showDiagram(self, which):
elif which in self.wstr:
ax = self.wstr.index(which)
text = self.wstrings[ax]
if self.w[ax] == None:
if self.w[ax] is None:
# No data
return
if self.w[ax].name in self.diagrams:
Expand All @@ -252,7 +252,7 @@ def showDiagram(self, which):
elif which in self.sigmaNstr:
ax = self.sigmaNstr.index(which)
text = self.sigmaNstrings[ax]
if self.sigmaN[ax] == None:
if self.sigmaN[ax] is None:
# No data
return
if self.sigmaN[ax].name in self.diagrams:
Expand All @@ -265,7 +265,7 @@ def showDiagram(self, which):
elif which in self.sigmaBstr:
ax = self.sigmaBstr.index(which)
text = self.sigmaBstrings[ax]
if self.sigmaB[ax] == None:
if self.sigmaB[ax] is None:
# No data
return
if self.sigmaB[ax].name in self.diagrams:
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/PartDesign/WizardShaft/WizardShaft.py
Expand Up @@ -39,7 +39,7 @@ def __init__(self, doc):
# Get active document or create a new one
# Important because when setting the default data in WizardShaftTable() the
# updateSketch() slot will be activated and it relies on finding a valid document
if self.doc == None:
if self.doc is None:
self.Gui.activateWorkbench("PartDesignWorkbench")
self.doc = self.App.newDocument()
# Grab the newly created feature window
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/PartDesign/WizardShaft/WizardShaftTable.py
Expand Up @@ -198,7 +198,7 @@ def slotValueChanged(self, value):
self.editedValue = value

def slotEditingFinished(self):
if self.editedRow == None:
if self.editedRow is None:
return
rowName = self.rowDictReverse[self.editedRow]
if rowName is None:
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathAdaptive.py
Expand Up @@ -422,7 +422,7 @@ def progressFn(tpaths):

start = time.time()

if inputStateChanged or adaptiveResults == None:
if inputStateChanged or adaptiveResults is None:
a2d = area.Adaptive2d()
a2d.stepOverFactor = 0.01*obj.StepOver
a2d.toolDiameter = float(op.tool.Diameter)
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathSimulatorGui.py
Expand Up @@ -486,7 +486,7 @@ def SimStop(self):
def InvalidOperation(self):
if len(self.activeOps) == 0:
return True
if (self.tool == None):
if (self.tool is None):
TSError("No tool assigned for the operation")
return True
return False
Expand Down
3 changes: 1 addition & 2 deletions src/Mod/Robot/RobotExample.py
Expand Up @@ -57,7 +57,7 @@
#
# Working with the robot document objects:
# first create a robot in the active document
if(App.activeDocument() == None):App.newDocument()
if(App.activeDocument() is None):App.newDocument()

App.activeDocument().addObject("Robot::RobotObject","Robot")
# Define the visual representation and the kinematic definition (see [[6-Axis Robot]] for details about that)
Expand Down Expand Up @@ -105,4 +105,3 @@
for w in App.activeDocument().Trajectory.Trajectory.Waypoints:
(A,B,C) = (w.Pos.Rotation.toEuler())
print("LIN {X %.3f,Y %.3f,Z %.3f,A %.3f,B %.3f,C %.3f} ; %s"%(w.Pos.Base.x,w.Pos.Base.y,w.Pos.Base.z,A,B,C,w.Name))

2 changes: 1 addition & 1 deletion src/Mod/Sandbox/exportDRAWEXE.py
Expand Up @@ -513,7 +513,7 @@ def process_object(self,ob,checksupported=False,toplevel=False):
curname=nxtname
i+=1
elif (isDraftPolygon(ob) and ob.ChamferSize.Value == 0 and\
ob.FilletRadius.Value == 0 and ob.Support == None) or\
ob.FilletRadius.Value == 0 and ob.Support is None) or\
ob.TypeId == "Part::Prism" or \
ob.TypeId == "Part::RegularPolygon":
if checksupported: return True # The object is supported
Expand Down
4 changes: 1 addition & 3 deletions src/Mod/Sketcher/SketcherExample.py
Expand Up @@ -10,7 +10,7 @@
MiddlePoint = 3

# create a document and a Sketch object
if(App.activeDocument() == None):App.newDocument()
if(App.activeDocument() is None):App.newDocument()

f = App.activeDocument().addObject("Sketcher::SketchObject","Sketch")

Expand All @@ -32,5 +32,3 @@
App.activeDocument().recompute()

f.Geometry


10 changes: 5 additions & 5 deletions src/Mod/Spreadsheet/App/Spreadsheet_legacy.py
Expand Up @@ -158,7 +158,7 @@ def parseVariable(self):
break

value = self.vars.get(var, None)
if value == None:
if value is None:
raise ValueError(
"Unrecognized variable: '" +
var +
Expand Down Expand Up @@ -233,7 +233,7 @@ def __setattr__(self, key, value):
if self.isKey(key):
key = key.lower()
if DEBUG: print("Setting key ",key," to value ",value)
if (value == "") or (value == None):
if (value == "") or (value is None):
# remove cell
if key in self._cells.keys():
del self._cells[key]
Expand Down Expand Up @@ -809,7 +809,7 @@ def update(self):
content = getattr(self.spreadsheet.Proxy,cell)
if self.spreadsheet.Proxy.isFunction(cell):
self.doNotChange = True
if content == None:
if content is None:
content = ""
if DEBUG: print("Updating ",cell," to ",content)
if self.table.item(r,c):
Expand Down Expand Up @@ -838,7 +838,7 @@ def changeCell(self,r,c,value=None):
self.doNotChange = False
elif self.spreadsheet:
key = "abcdefghijklmnopqrstuvwxyz"[c]+str(r+1)
if value == None:
if value is None:
value = self.table.item(r,c).text()
if value == "":
if DEBUG: print("Wiping "+key)
Expand Down Expand Up @@ -874,7 +874,7 @@ def setEditLine(self,r,c,orr=None,orc=None):
from DraftTools import translate
self.label.setText(str(translate("Spreadsheet","Cell"))+" "+c.upper()+str(r)+" :")
content = self.spreadsheet.Proxy.getFunction(c+str(r))
if content == None:
if content is None:
content = ""
self.lineEdit.setText(str(content))

Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Spreadsheet/importXLSX.py
Expand Up @@ -226,13 +226,13 @@ def isKey(self, theExpr):
if theExpr[0] in sepToken:
branch = sepToken[theExpr[0]]

if branch == None:
if branch is None:
keyToken = True
else:
#print('There is a branch. look up: ', theExpr[1])
if (lenExpr > 1) and (theExpr[1] in treeDict[branch]):
branch = treeDict[branch][theExpr[0]]
if branch == None:
if branch is None:
keyToken = True
else:
if (lenExpr > 2) and (theExpr[2] in treeDict[branch]):
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/TemplatePyMod/Commands.py
Expand Up @@ -69,7 +69,7 @@ def addVertex(self, d):
p=PolygonCreator(d,v,10)

def IsActive(self):
if FreeCAD.ActiveDocument == None:
if FreeCAD.ActiveDocument is None:
return False
else:
return True
Expand Down Expand Up @@ -159,7 +159,7 @@ def Activated(self):
from pivy import coin

global myRenderArea
if myRenderArea == None:
if myRenderArea is None:
root = coin.SoSeparator()
myCamera = coin.SoPerspectiveCamera()
myMaterial = coin.SoMaterial()
Expand Down

0 comments on commit 1bc3302

Please sign in to comment.