LGTM: various fixes for using string operator instead of numeric

This commit is contained in:
luz.paz
2019-10-22 10:42:18 -04:00
committed by Yorik van Havre
parent e4c8890d52
commit 1bc33025d6
23 changed files with 49 additions and 54 deletions

View File

@@ -123,7 +123,7 @@ class _ViewProviderPartJoinFeature:
vobj.Proxy = self
def getIcon(self):
if self.Object == None:
if self.Object is None:
return getIconPath("Part_JoinConnect.svg")
else:
return getIconPath( {

View File

@@ -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")

View File

@@ -101,7 +101,7 @@ class Hole():
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"
@@ -116,7 +116,7 @@ class Hole():
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)
@@ -134,7 +134,7 @@ class Hole():
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:
@@ -274,7 +274,7 @@ class Hole():
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

View File

@@ -46,7 +46,7 @@ class HoleGui:
# 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
@@ -62,7 +62,7 @@ class HoleGui:
# 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")

View File

@@ -94,7 +94,7 @@ class TaskHole:
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
@@ -367,7 +367,7 @@ class TaskHole:
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)

View File

@@ -56,10 +56,9 @@ class DistanceBolt:
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

View File

@@ -57,7 +57,7 @@ class Epitrochoid:
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"

View File

@@ -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

View File

@@ -64,7 +64,7 @@ class BoxCylinder:
def makeParallelepiped():
doc = FreeCAD.activeDocument()
if doc == None:
if doc is None:
doc = FreeCAD.newDocument()
obj=doc.addObject("Part::FeaturePython","Parallelepiped")
obj.Label = "Parallelepiped"
@@ -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

View File

@@ -39,7 +39,7 @@ class MySpring:
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"

View File

@@ -213,7 +213,7 @@ class Shaft:
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:
@@ -226,7 +226,7 @@ class Shaft:
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:
@@ -239,7 +239,7 @@ class Shaft:
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:
@@ -252,7 +252,7 @@ class Shaft:
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:
@@ -265,7 +265,7 @@ class Shaft:
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:

View File

@@ -39,7 +39,7 @@ class TaskWizardShaft:
# 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

View File

@@ -198,7 +198,7 @@ class WizardShaftTable:
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:

View File

@@ -422,7 +422,7 @@ def Execute(op,obj):
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)

View File

@@ -486,7 +486,7 @@ class PathSimulation:
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

View File

@@ -57,7 +57,7 @@ del rob,Start,t,l,w
#
# 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)
@@ -105,4 +105,3 @@ ExportCompactSub(App.activeDocument().Robot,App.activeDocument().Trajectory,temp
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))

View File

@@ -513,7 +513,7 @@ class Drawexporter(object):
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

View File

@@ -10,7 +10,7 @@ EndPoint = 2
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")
@@ -32,5 +32,3 @@ f.Constraints = l
App.activeDocument().recompute()
f.Geometry

View File

@@ -158,7 +158,7 @@ class MathParser:
break
value = self.vars.get(var, None)
if value == None:
if value is None:
raise ValueError(
"Unrecognized variable: '" +
var +
@@ -233,7 +233,7 @@ class Spreadsheet:
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]
@@ -809,7 +809,7 @@ class SpreadsheetView(QtGui.QWidget):
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):
@@ -838,7 +838,7 @@ class SpreadsheetView(QtGui.QWidget):
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)
@@ -874,7 +874,7 @@ class SpreadsheetView(QtGui.QWidget):
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))

View File

@@ -226,13 +226,13 @@ class FormulaTranslator(object):
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]):

View File

@@ -69,7 +69,7 @@ class TemplatePyMod_Cmd2:
p=PolygonCreator(d,v,10)
def IsActive(self):
if FreeCAD.ActiveDocument == None:
if FreeCAD.ActiveDocument is None:
return False
else:
return True
@@ -159,7 +159,7 @@ class TemplatePyMod_Cmd5:
from pivy import coin
global myRenderArea
if myRenderArea == None:
if myRenderArea is None:
root = coin.SoSeparator()
myCamera = coin.SoPerspectiveCamera()
myMaterial = coin.SoMaterial()

View File

@@ -758,7 +758,7 @@ class UndoRedoCases(unittest.TestCase):
# undo the first transaction
self.Doc.undo()
self.failUnless(self.Doc.getObject("test1") == None)
self.failUnless(self.Doc.getObject("test1") is None)
self.failUnless(self.Doc.getObject("Del").Integer == 2)
self.assertEqual(self.Doc.UndoNames,[])
self.assertEqual(self.Doc.UndoCount,0)
@@ -938,7 +938,7 @@ class DocumentGroupCases(unittest.TestCase):
self.Doc.openTransaction("Remove")
self.Doc.removeObject("Label_2")
self.Doc.commitTransaction()
self.failUnless(G1.getObject("Label_2") == None)
self.failUnless(G1.getObject("Label_2") is None)
self.Doc.undo()
self.failUnless(G1.getObject("Label_2") != None)
@@ -954,7 +954,7 @@ class DocumentGroupCases(unittest.TestCase):
self.Doc.openTransaction("Remove")
self.Doc.removeObject("Label_2")
self.Doc.commitTransaction()
self.failUnless(G1.getObject("Label_2") == None)
self.failUnless(G1.getObject("Label_2") is None)
self.Doc.openTransaction("Remove")
self.Doc.removeObject("Group")
self.Doc.commitTransaction()
@@ -965,7 +965,7 @@ class DocumentGroupCases(unittest.TestCase):
# Remove first object and then the group in one transaction
self.Doc.openTransaction("Remove")
self.Doc.removeObject("Label_2")
self.failUnless(G1.getObject("Label_2") == None)
self.failUnless(G1.getObject("Label_2") is None)
self.Doc.removeObject("Group")
self.Doc.commitTransaction()
self.Doc.undo()
@@ -977,9 +977,9 @@ class DocumentGroupCases(unittest.TestCase):
G1.addObject(L3)
self.Doc.openTransaction("Remove")
self.Doc.removeObject("Label_2")
self.failUnless(G1.getObject("Label_2") == None)
self.failUnless(G1.getObject("Label_2") is None)
self.Doc.removeObject("Label_3")
self.failUnless(G1.getObject("Label_3") == None)
self.failUnless(G1.getObject("Label_3") is None)
self.Doc.removeObject("Group")
self.Doc.commitTransaction()
self.Doc.undo()
@@ -1001,7 +1001,7 @@ class DocumentGroupCases(unittest.TestCase):
grp2 = self.Doc.addObject("App::DocumentObjectGroup","Group2")
grp1.addObject(obj1)
self.failUnless(obj1.getParentGroup()==grp1)
self.failUnless(obj1.getParentGeoFeatureGroup()==None)
self.failUnless(obj1.getParentGeoFeatureGroup() is None)
self.failUnless(grp1.hasObject(obj1))
grp2.addObject(obj1)
self.failUnless(grp1.hasObject(obj1)==False)
@@ -1012,8 +1012,8 @@ class DocumentGroupCases(unittest.TestCase):
prt2 = self.Doc.addObject("App::Part","Part2")
prt1.addObject(grp2)
self.failUnless(grp2.getParentGeoFeatureGroup()==prt1)
self.failUnless(grp2.getParentGroup()==None)
self.failUnless(grp2.getParentGeoFeatureGroup() == prt1)
self.failUnless(grp2.getParentGroup() is None)
self.failUnless(grp2.hasObject(obj1))
self.failUnless(prt1.hasObject(grp2))
self.failUnless(prt1.hasObject(obj1))

View File

@@ -128,12 +128,12 @@ def updateqrc(qrcpath,lncode):
for i in range(len(resources)):
if ".qm" in resources[i]:
pos = i
if pos == None:
if pos is None:
print("No existing .qm file in this resource. Appending to the end position")
for i in range(len(resources)):
if "</qresource>" in resources[i]:
pos = i-1
if pos == None:
if pos is None:
print("ERROR: couldn't add qm files to this resource: " + qrcpath)
sys.exit()
@@ -264,4 +264,3 @@ if __name__ == "__main__":
print("ERROR: language path for " + ln + " not found!")
else:
doLanguage(ln,fmodule)