Skip to content

Commit

Permalink
Draft: use string operator instead of numeric LGTM fix
Browse files Browse the repository at this point in the history
  • Loading branch information
luzpaz authored and yorikvanhavre committed Oct 25, 2019
1 parent cf854a5 commit bec8e1b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
16 changes: 8 additions & 8 deletions src/Mod/Draft/Draft.py
Expand Up @@ -134,25 +134,25 @@ def getParam(param,default=None):
t = getParamType(param)
#print("getting param ",param, " of type ",t, " default: ",str(default))
if t == "int":
if default == None:
if default is None:
default = 0
if param == "linewidth":
return FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View").GetInt("DefaultShapeLineWidth",default)
return p.GetInt(param,default)
elif t == "string":
if default == None:
if default is None:
default = ""
return p.GetString(param,default)
elif t == "float":
if default == None:
if default is None:
default = 0
return p.GetFloat(param,default)
elif t == "bool":
if default == None:
if default is None:
default = False
return p.GetBool(param,default)
elif t == "unsigned":
if default == None:
if default is None:
default = 0
if param == "color":
return FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View").GetUnsigned("DefaultShapeLineColor",default)
Expand Down Expand Up @@ -312,7 +312,7 @@ def autogroup(obj):

def dimSymbol(symbol=None,invert=False):
"""returns the current dim symbol from the preferences as a pivy SoMarkerSet"""
if symbol == None:
if symbol is None:
symbol = getParam("dimsymbol",0)
from pivy import coin
if symbol == 0:
Expand Down Expand Up @@ -4558,10 +4558,10 @@ def updateData(self, obj, prop):
for i in range(arcsegs+1):
p = self.circle.valueAt(self.circle.FirstParameter+((self.circle.LastParameter-self.circle.FirstParameter)/arcsegs)*i)
if (p.sub(mp)).Length <= spacing:
if cut == None:
if cut is None:
cut = i
else:
if cut == None:
if cut is None:
pts1.append([p.x,p.y,p.z])
else:
pts2.append([p.x,p.y,p.z])
Expand Down
14 changes: 7 additions & 7 deletions src/Mod/Draft/DraftGeomUtils.py
Expand Up @@ -806,7 +806,7 @@ def lookfor(aVertex, inEdges):
return [count]+linstances

if (len(lEdges) < 2):
if aVertex == None:
if aVertex is None:
return lEdges
else:
result = lookfor(aVertex,lEdges)
Expand All @@ -829,7 +829,7 @@ def lookfor(aVertex, inEdges):
return lEdges

olEdges = [] # ol stands for ordered list
if aVertex == None:
if aVertex is None:
for i in range(len(lEdges)*2) :
if len(lEdges[i/2].Vertexes) > 1:
result = lookfor(lEdges[i/2].Vertexes[i%2],lEdges)
Expand Down Expand Up @@ -1073,7 +1073,7 @@ def findPerpendicular(point,edgeslist,force=None):
edgeslist = edgeslist.Edges
except:
return None
if (force == None):
if (force is None):
valid = None
for edge in edgeslist:
dist = findDistance(point,edge,strict=True)
Expand Down Expand Up @@ -2268,25 +2268,25 @@ def getBoundaryAngles(angle,alist):
lower = None
for a in alist:
if a < angle:
if lower == None:
if lower is None:
lower = a
else:
if a > lower:
lower = a
if lower == None:
if lower is None:
lower = 0
for a in alist:
if a > lower:
lower = a
higher = None
for a in alist:
if a > angle:
if higher == None:
if higher is None:
higher = a
else:
if a < higher:
higher = a
if higher == None:
if higher is None:
higher = 2*math.pi
for a in alist:
if a < higher:
Expand Down
14 changes: 7 additions & 7 deletions src/Mod/Draft/DraftGui.py
Expand Up @@ -249,7 +249,7 @@ def displayExternal(internValue,decimals=None,dim='Length',showUnit=True,unit=No
if dim == 'Length':
q = FreeCAD.Units.Quantity(internValue,FreeCAD.Units.Length)
if not unit:
if (decimals == None) and showUnit:
if (decimals is None) and showUnit:
return q.UserString
conversion = q.getUserPreferred()[1]
uom = q.getUserPreferred()[2]
Expand All @@ -261,7 +261,7 @@ def displayExternal(internValue,decimals=None,dim='Length',showUnit=True,unit=No
return FreeCAD.Units.Quantity(internValue,FreeCAD.Units.Angle).UserString
else:
conversion = 1.0
if decimals == None:
if decimals is None:
decimals = 2
uom = "??"
if not showUnit:
Expand Down Expand Up @@ -915,16 +915,16 @@ def setFocus(self,f=None):
elif self.angleLock.isVisible() and self.angleLock.isChecked():
self.lengthValue.setFocus()
self.lengthValue.selectAll()
elif f==None or f=="x":
elif (f is None) or (f == "x"):
self.xValue.setFocus()
self.xValue.selectAll()
elif f=="y":
elif f == "y":
self.yValue.setFocus()
self.yValue.selectAll()
elif f=="z":
elif f == "z":
self.zValue.setFocus()
self.zValue.selectAll()
elif f=="radius":
elif f == "radius":
self.radiusValue.setFocus()
self.radiusValue.selectAll()

Expand Down Expand Up @@ -1973,7 +1973,7 @@ def runAutoGroup(self):
FreeCADGui.runCommand("Draft_AutoGroup")

def setAutoGroup(self,value=None):
if value == None:
if value is None:
self.autogroup = None
self.autoGroupButton.setText("None")
self.autoGroupButton.setIcon(QtGui.QIcon.fromTheme('Draft_AutoGroup_off',
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Draft/DraftSnap.py
Expand Up @@ -407,7 +407,7 @@ def snapToObject(self, lastpoint, active, constrain, eline, point, oldActive):
winner = None
fp = point
for snap in snaps:
if (not snap) or (snap[0] == None):
if (not snap) or (snap[0] is None):
pass
#print("debug: Snapper: invalid snap point: ",snaps)
else:
Expand Down Expand Up @@ -1364,7 +1364,7 @@ def saveSnapModes(self):
def toggle(self,checked=None):
"toggles the snap mode"
if hasattr(self,"toolbarButtons"):
if checked == None:
if checked is None:
self.masterbutton.toggle()
elif checked:
if hasattr(self,"savedButtonStates"):
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/getSVG.py
Expand Up @@ -842,7 +842,7 @@ def format_point(coords, action='L'):
wiredEdges.extend(w.Edges)
if len(wiredEdges) != len(obj.Shape.Edges):
for i,e in enumerate(obj.Shape.Edges):
if (DraftGeomUtils.findEdge(e,wiredEdges) == None):
if (DraftGeomUtils.findEdge(e,wiredEdges) is None):
svg += getPath([e],pathname='%s_nwe%04d' % \
(obj.Name,i))
else:
Expand Down

0 comments on commit bec8e1b

Please sign in to comment.