From ef3324fa9e7cf30359ec6d57d0efd4f6b4c54598 Mon Sep 17 00:00:00 2001 From: luzpaz Date: Fri, 29 Jul 2022 22:01:40 -0400 Subject: [PATCH] PD: Fix 'testing inequality to None' syntax (#7279) * PD: Fix 'testing inequality to None' syntax - Substitute `is not None` for `!= None` - Fix trailing whitespace --- src/Mod/PartDesign/FeatureHole/FeatureHole.py | 72 +++++++++--------- src/Mod/PartDesign/FeatureHole/TaskHole.py | 74 +++++++++---------- .../FeatureHole/ViewProviderHole.py | 8 +- src/Mod/PartDesign/TestPartDesignGui.py | 22 +++--- src/Mod/PartDesign/WizardShaft/WizardShaft.py | 4 +- 5 files changed, 90 insertions(+), 90 deletions(-) diff --git a/src/Mod/PartDesign/FeatureHole/FeatureHole.py b/src/Mod/PartDesign/FeatureHole/FeatureHole.py index da4d520d8f..284694bc4a 100644 --- a/src/Mod/PartDesign/FeatureHole/FeatureHole.py +++ b/src/Mod/PartDesign/FeatureHole/FeatureHole.py @@ -32,7 +32,7 @@ def makeVector(point): class Hole(): "Hole feature" App = FreeCAD - Gui = FreeCADGui + Gui = FreeCADGui def __init__(self, feature): self.feature = feature @@ -78,14 +78,14 @@ class Hole(): self.oldCountersink = False def execute(self, feature): - if feature.Support != None: + if feature.Support is not None: (support, element) = feature.Support feature.Placement = feature.HoleGroove.Placement shape = feature.HoleGroove.Shape.copy() shape.Placement = FreeCAD.Placement() feature.Shape = shape - - self.Gui.ActiveDocument.hide(support.Name) + + self.Gui.ActiveDocument.hide(support.Name) # Copy display properties from support featview = feature.ViewObject suppview = support.ViewObject @@ -125,7 +125,7 @@ class Hole(): refs = plane.References if len(refs) == 0: return - + axis = plane.References[0][0] firstTime = (len(axis.References) == 0) if firstTime: @@ -156,7 +156,7 @@ class Hole(): except Exception: # Unknown curvetype GeomAbs_OtherCurve continue - axis.References = [(support, elementList[0]), (support, "Edge" + str(firstLineIndex+1)), (support, "Edge" + str(secondLineIndex+1))] + axis.References = [(support, elementList[0]), (support, "Edge" + str(firstLineIndex+1)), (support, "Edge" + str(secondLineIndex+1))] axis.Offset = 1.0 axis.Offset2 = 1.0 self.feature.PositionType = "Linear" @@ -166,7 +166,7 @@ class Hole(): #l2 = Part.LineSegment(e.Curve) #axis.Offset = p.distanceToLine(l1.StartPoint, l1.EndPoint - l1.StartPoint) #axis.Offset2 = p.distanceToLine(l1.StartPoint, l2.EndPoint - l2.StartPoint) - # TODO: Ensure that the hole is inside the face! + # TODO: Ensure that the hole is inside the face! break elif type(e.Curve) == Part.Circle: allEdges = support.Shape.Edges @@ -195,12 +195,12 @@ class Hole(): break except: continue - break - + break + # Grab a point from the wire of the support face axisbase = axis.Shape.Curve.StartPoint axisdir = axis.Shape.Curve.EndPoint - axisbase - found = False + found = False if not firstTime and len(refs) > 1: # Try to keep the old point, to avoid the sketch plane jumping around (obj, sub) = refs[1] @@ -215,12 +215,12 @@ class Hole(): break if not found: point = face.OuterWire.Vertexes[0] # Better this than nothing... and it can't actually happen, can it? - + # Find the index of the point in the support shape allVertexes = support.Shape.Vertexes for v in range(len(allVertexes)): - if allVertexes[v].Point == point.Point: - # Use this point and the axis to define the sketch plane + if allVertexes[v].Point == point.Point: + # Use this point and the axis to define the sketch plane if len(refs) < 2: refs.append((support, "Vertex" + str(v+1))) else: @@ -234,7 +234,7 @@ class Hole(): else: self.executeSketchChanged(fp) # Update the sketch of the hole self.setHoleDirection(fp) - + def setHoleDirection(self, feature): # Make sure the hole goes into the material, not out of it sketch = feature.HoleGroove.Sketch @@ -244,7 +244,7 @@ class Hole(): p1 = None p2 = None for v in sketch.Shape.Vertexes: - # Find the two sketch vertices that are on the sketch axis + # Find the two sketch vertices that are on the sketch axis if v.Point.distanceToLine(axisbase, axisdir) < 1E-10: # TODO: use Precision::Confusion() if p1 is None: p1 = v.Point @@ -263,7 +263,7 @@ class Hole(): dir = p2 - p1 else: top = p2 - dir = p1 - p2 + dir = p1 - p2 if not support.Shape.isInside(top + dir.multiply(1E-8), 1E-10, False): # Toggle the angle angle = sketch.Constraints[12].Value @@ -291,17 +291,17 @@ class Hole(): self.createOrUpdateStandardSketch(fp, length, radius) def createOrUpdateStandardSketch(self, fp, depth, radius): - (support, elements) = fp.Support + (support, elements) = fp.Support if fp.HoleGroove.Sketch.GeometryCount == 0: #FreeCAD.Console.PrintMessage("Standard sketch\n") - # New sketch + # New sketch sketch = fp.HoleGroove.Sketch axis = sketch.Support[0].References[0][0] # Geo -1,1 is the origin (Point) # Geo -1 is the X-axis # Geo -2 is the Y-axis # First external geometry is -3 - sketch.addExternal(axis.Name,"LineSegment") # Geo -3: Datum axis + sketch.addExternal(axis.Name,"LineSegment") # Geo -3: Datum axis sketch.addExternal(support.Name, elements[0]) # Geo -4: Support face # Note: Creating the sketch first with depth = 100.0 and then changing the constraint later seems to be more stable tempDepth = 100.0 @@ -314,8 +314,8 @@ class Hole(): sketch.addGeometry(Part.LineSegment(self.App.Vector(10.0,-10.0,0),self.App.Vector(20.0,-10.0,0))) # Geo2: Top of hole sketch.addConstraint(Sketcher.Constraint('Coincident',1,1,2,1)) # Datum2 sketch.addConstraint(Sketcher.Constraint('Perpendicular',2, 1)) # Datum3 - sketch.addGeometry(Part.LineSegment(self.App.Vector(20.0,-10.0,0),self.App.Vector(20.0,-25.0,0))) # Geo3: Vertical mantle of hole - sketch.addConstraint(Sketcher.Constraint('Coincident',2,2,3,1)) # temporary + sketch.addGeometry(Part.LineSegment(self.App.Vector(20.0,-10.0,0),self.App.Vector(20.0,-25.0,0))) # Geo3: Vertical mantle of hole + sketch.addConstraint(Sketcher.Constraint('Coincident',2,2,3,1)) # temporary sketch.addConstraint(Sketcher.Constraint('Parallel',3, 1)) # Datum4 sketch.addConstraint(Sketcher.Constraint('Distance',3,2,1, 10.0)) # Datum5: Radius sketch.addConstraint(Sketcher.Constraint('Distance',3,2,2, 15.0)) # Datum6: Depth @@ -323,7 +323,7 @@ class Hole(): sketch.addConstraint(Sketcher.Constraint('Coincident',4,1,1,2)) # Datum7 sketch.addConstraint(Sketcher.Constraint('Coincident',4,2,3,2)) # Datum8 # TODO: The tip angle of 118 degrees is for steel only. It should be taken from Part material data - # (as soon as that is implemented) + # (as soon as that is implemented) sketch.addConstraint(Sketcher.Constraint('Angle',4,1,1,2, 118.0/2.0 * math.pi / 180.0)) # Datum9 # Locate at the intersection of the two external geometries sketch.addConstraint(Sketcher.Constraint('PointOnObject',1,1,-3))# Datum10 @@ -332,7 +332,7 @@ class Hole(): # This datum is specific for this holetype, so move it to the last position sketch.delConstraint(4) sketch.addConstraint(Sketcher.Constraint('Coincident',2,2,3,1)) # Datum13 - fp.HoleGroove.ReferenceAxis = (sketch,['Axis0']) + fp.HoleGroove.ReferenceAxis = (sketch,['Axis0']) if self.oldCounterbore == True: # Remove counterbore from existing sketch #FreeCAD.Console.PrintMessage("Counter to Standard sketch\n") @@ -345,7 +345,7 @@ class Hole(): sketch.delConstraint(14) sketch.delConstraint(13) sketch.delGeometry(6) - sketch.delGeometry(5) + sketch.delGeometry(5) sketch.addConstraint(Sketcher.Constraint('Coincident',2,2,3,1)) # Datum13 elif self.oldCountersink == True: # Remove countersink from existing sketch @@ -355,7 +355,7 @@ class Hole(): sketch.delConstraint(15) sketch.delConstraint(14) sketch.delConstraint(13) - sketch.delGeometry(5) + sketch.delGeometry(5) sketch.addConstraint(Sketcher.Constraint('Coincident',2,2,3,1)) # Datum13 else: # Update existing standard sketch @@ -369,12 +369,12 @@ class Hole(): sketch.delConstraint(13) sketch.delConstraint(12) sketch.delConstraint(11) - sketch.delExternal(1) + sketch.delExternal(1) sketch.addExternal(support.Name, elements[0]) # Geo -4: Support face sketch.addConstraint(Sketcher.Constraint('PointOnObject',1,1,-4))# Datum11 sketch.addConstraint(Sketcher.Constraint('Angle',0,1,-3, 1, angle))# Datum12 sketch.addConstraint(Sketcher.Constraint('Coincident',2,2,3,1)) # Datum13 - + self.setHoleDirection(fp) self.oldCounterbore = False self.oldCountersink = False @@ -404,17 +404,17 @@ class Hole(): sketch.delConstraint(13) sketch.delConstraint(12) sketch.delConstraint(11) - sketch.delExternal(1) + sketch.delExternal(1) sketch.addExternal(support.Name, elements[0]) # Geo -4: Support face sketch.addConstraint(Sketcher.Constraint('PointOnObject',1,1,-4))# Datum11 sketch.addConstraint(Sketcher.Constraint('Angle',0,1,-3, 1, angle))# Datum12 sketch.addConstraint(Sketcher.Constraint('Distance',2, cradius)) # Datum13 sketch.addConstraint(Sketcher.Constraint('Coincident',2,2,5,1)) # Datum14 sketch.addConstraint(Sketcher.Constraint('Distance',3, 1, 2, cdepth)) # Datum15 - sketch.addConstraint(Sketcher.Constraint('Parallel',5, 1)) # Datum16 + sketch.addConstraint(Sketcher.Constraint('Parallel',5, 1)) # Datum16 sketch.addConstraint(Sketcher.Constraint('Coincident',5,2,6,1)) # Datum17 sketch.addConstraint(Sketcher.Constraint('Perpendicular',6, -3)) # Datum18 - sketch.addConstraint(Sketcher.Constraint('Coincident',6,2,3,1)) # Datum19 + sketch.addConstraint(Sketcher.Constraint('Coincident',6,2,3,1)) # Datum19 else: # Change standard to counterbore in existing sketch #FreeCAD.Console.PrintMessage("Standard to Counterbore sketch\n") @@ -430,7 +430,7 @@ class Hole(): sketch.addGeometry(Part.LineSegment(self.App.Vector(p2.x,p2.y-20.0, 0),p3)) # Geo6: bottom of counterbore sketch.addConstraint(Sketcher.Constraint('Coincident',5,2,6,1)) # Datum17 sketch.addConstraint(Sketcher.Constraint('Perpendicular',6, -3)) # Datum18 - sketch.addConstraint(Sketcher.Constraint('Coincident',6,2,3,1)) # Datum19 + sketch.addConstraint(Sketcher.Constraint('Coincident',6,2,3,1)) # Datum19 self.setHoleDirection(fp) self.oldCounterbore = True @@ -441,7 +441,7 @@ class Hole(): sangle = fp.CountersinkAngle * math.pi / 180.0 (support, elements) = fp.Support - if self.oldCountersink == True: + if self.oldCountersink == True: # Update properties of existing countersink sketch #FreeCAD.Console.PrintMessage("Update to Countersink sketch\n") sketch = fp.HoleGroove.Sketch @@ -458,13 +458,13 @@ class Hole(): sketch.delConstraint(13) sketch.delConstraint(12) sketch.delConstraint(11) - sketch.delExternal(1) + sketch.delExternal(1) sketch.addExternal(support.Name, elements[0]) # Geo -4: Support face sketch.addConstraint(Sketcher.Constraint('PointOnObject',1,1,-4))# Datum11 sketch.addConstraint(Sketcher.Constraint('Angle',0,1,-3, 1, angle))# Datum12 sketch.addConstraint(Sketcher.Constraint('Distance',2, sradius)) # Datum13 sketch.addConstraint(Sketcher.Constraint('Coincident',2,2,5,1)) # Datum14 - sketch.addConstraint(Sketcher.Constraint('Angle',5,2, 1,2, sangle)) # Datum15 + sketch.addConstraint(Sketcher.Constraint('Angle',5,2, 1,2, sangle)) # Datum15 sketch.addConstraint(Sketcher.Constraint('Coincident',3,1,5,2)) # Datum16 else: # Change standard to countersink in existing sketch @@ -475,8 +475,8 @@ class Hole(): p2 = sketch.Geometry[2].EndPoint sketch.addGeometry(Part.LineSegment(p2,self.App.Vector(p2.x,p2.y-20.0,0))) # Geo5: Chamfer of countersink sketch.addConstraint(Sketcher.Constraint('Coincident',2,2,5,1)) # Datum14 - sketch.addConstraint(Sketcher.Constraint('Angle',5,2, 1,2, sangle)) # Datum15 - sketch.addConstraint(Sketcher.Constraint('Coincident',3,1,5,2)) # Datum16 + sketch.addConstraint(Sketcher.Constraint('Angle',5,2, 1,2, sangle)) # Datum15 + sketch.addConstraint(Sketcher.Constraint('Coincident',3,1,5,2)) # Datum16 self.setHoleDirection(fp) self.oldCounterbore = False diff --git a/src/Mod/PartDesign/FeatureHole/TaskHole.py b/src/Mod/PartDesign/FeatureHole/TaskHole.py index 6805cb27bd..63aa82de5d 100644 --- a/src/Mod/PartDesign/FeatureHole/TaskHole.py +++ b/src/Mod/PartDesign/FeatureHole/TaskHole.py @@ -46,37 +46,37 @@ class TaskHole: return True def reject(self): - if (self.feature != None): + if (self.feature is not None): self.hideFeature() # Show the support again document = self.feature.Document body = FreeCADGui.activeView().getActiveObject("pdbody"); groove = self.feature.HoleGroove sketch = groove.Sketch plane = sketch.Support[0] - axis = plane.References[0][0] + axis = plane.References[0][0] body.removeObject(self.feature) - document.removeObject(self.feature.Name) + document.removeObject(self.feature.Name) body.removeObject(groove) document.removeObject(groove.Name) body.removeObject(sketch) try: - document.removeObject(sketch.Name) + document.removeObject(sketch.Name) except Exception: pass # This always throws an exception: "Sketch support has been deleted" from SketchObject::execute() body.removeObject(plane) document.removeObject(plane.Name) body.removeObject(axis) - document.removeObject(axis.Name) + document.removeObject(axis.Name) FreeCADGui.ActiveDocument.resetEdit() FreeCADGui.Control.closeDialog(self) return True - + def isAllowedAlterDocument(self): return False - + def isAllowedAlterView(self): return False - + def isAllowedAlterSelection(self): return True @@ -100,9 +100,9 @@ class TaskHole: # Type form.tabType = form.tabWidget.findChild(QtGui.QWidget, "tab_type") form.buttonThru = form.tabType.findChild(QtGui.QRadioButton, "buttonThru") - form.buttonDepth = form.tabType.findChild(QtGui.QRadioButton, "buttonDepth") - form.checkThreaded = form.tabType.findChild(QtGui.QCheckBox, "checkThreaded") - form.checkCounterbore = form.tabType.findChild(QtGui.QCheckBox, "checkCounterbore") + form.buttonDepth = form.tabType.findChild(QtGui.QRadioButton, "buttonDepth") + form.checkThreaded = form.tabType.findChild(QtGui.QCheckBox, "checkThreaded") + form.checkCounterbore = form.tabType.findChild(QtGui.QCheckBox, "checkCounterbore") form.checkCountersink = form.tabType.findChild(QtGui.QCheckBox, "checkCountersink") # Norm form.tabNorm = form.tabWidget.findChild(QtGui.QWidget, "tab_norm") @@ -114,7 +114,7 @@ class TaskHole: for tol in Standards.standards_tolerance: form.comboTolerance.addItem(tol) form.comboNormDia = form.tabNorm.findChild(QtGui.QComboBox, "comboNormDia") - form.comboNormBoltWasher = form.tabNorm.findChild(QtGui.QComboBox, "comboNormBoltWasher") + form.comboNormBoltWasher = form.tabNorm.findChild(QtGui.QComboBox, "comboNormBoltWasher") # Thread form.tabThread = form.tabWidget.findChild(QtGui.QWidget, "tab_thread") form.comboThreadNorm = form.tabThread.findChild(QtGui.QComboBox, "comboThreadNorm") @@ -127,8 +127,8 @@ class TaskHole: form.comboFinishNorm.addItem(std) # Data form.tabData = form.tabWidget.findChild(QtGui.QWidget, "tab_data") - form.spinDiameter = form.tabData.findChild(QtGui.QDoubleSpinBox, "spinDiameter") - form.spinDepth = form.tabData.findChild(QtGui.QDoubleSpinBox, "spinDepth") + form.spinDiameter = form.tabData.findChild(QtGui.QDoubleSpinBox, "spinDiameter") + form.spinDepth = form.tabData.findChild(QtGui.QDoubleSpinBox, "spinDepth") form.spinCounterboreDiameter = form.tabData.findChild(QtGui.QDoubleSpinBox, "spinCounterboreDiameter") form.spinCounterboreDepth = form.tabData.findChild(QtGui.QDoubleSpinBox, "spinCounterboreDepth") form.spinCountersinkAngle = form.tabData.findChild(QtGui.QDoubleSpinBox, "spinCountersinkAngle") @@ -186,7 +186,7 @@ class TaskHole: # Update the UI self.updateUI() return True - + def getRefText(self, ref): (obj, element) = ref if isinstance(element, basestring): @@ -226,7 +226,7 @@ class TaskHole: self.form.comboNormBoltWasher.setEnabled(True) else: self.form.comboNormBoltWasher.setEnabled(False) - # comboNorm + # comboNorm standards = Standards.getStandards(holetype) self.form.comboNorm.blockSignals(True) self.form.comboNorm.clear() @@ -266,7 +266,7 @@ class TaskHole: elif holetype == "counterbore": throughStandard = Standards.getThroughHoleStandard(self.feature.Norm) self.feature.Diameter = Standards.getThroughHoleDia(throughStandard, self.feature.NormDiameter, self.feature.NormTolerance) - self.feature.CounterboreDiameter = Standards.getCounterboreDia(self.feature.Norm, self.feature.NormDiameter, self.feature.ExtraNorm) + self.feature.CounterboreDiameter = Standards.getCounterboreDia(self.feature.Norm, self.feature.NormDiameter, self.feature.ExtraNorm) # TODO: Calculate counter bore depth from standard for bolt and washer(s) # Requires accessing all the norms for bolts # self.feature.CounterboreDepth = calcCounterboreDepth(...) @@ -282,7 +282,7 @@ class TaskHole: else: self.form.tabNorm.setEnabled(True) self.form.comboTolerance.setEnabled(False) - self.form.tabThread.setEnabled(True) + self.form.tabThread.setEnabled(True) self.form.comboThreadNorm.blockSignals(True) standards = Standards.getStandards("thread") if not self.feature.NormThread in standards: @@ -341,7 +341,7 @@ class TaskHole: elif self.feature.Countersink == True: self.form.spinCounterboreDiameter.setEnabled(True) self.form.spinCounterboreDiameter.setValue(self.feature.CounterboreDiameter) - self.form.spinCounterboreDepth.setEnabled(False) + self.form.spinCounterboreDepth.setEnabled(False) self.form.spinCountersinkAngle.setEnabled(True) self.form.spinCountersinkAngle.setValue(self.feature.CountersinkAngle) else: @@ -362,7 +362,7 @@ class TaskHole: self.form.spinCountersinkAngle.setEnabled(False) if self.feature.Threaded == True: self.form.spinDiameter.setEnabled(False) - if self.feature.NormThreadFinish != "Custom": + if self.feature.NormThreadFinish != "Custom": self.form.spinThreadLength.setEnabled(False) self.form.spinThreadLength.setValue(self.feature.ThreadLength) # Position @@ -373,7 +373,7 @@ class TaskHole: self.feature.Support = (selection[0].Object, selection[0].SubElementNames) self.form.lineSupport.setText(self.getRefText(self.feature.Support)) if self.feature.PositionType == self.types[0]: - # Linear + # Linear self.form.buttonRef1.setText("Line/Plane") self.form.buttonRef1.setEnabled(True) self.form.buttonRef2.setText("Line/Plane") @@ -383,7 +383,7 @@ class TaskHole: self.form.labelRef1.setEnabled(True) self.form.labelRef1.setText("Distance") axis = self.feature.HoleGroove.Sketch.Support[0].References[0][0] - if len(axis.References) > 0 and axis.References[0] != None: + if len(axis.References) > 0 and axis.References[0] is not None: if (len(axis.References) == 3): self.form.lineRef1.setText(self.getRefText(axis.References[1])) else: @@ -392,7 +392,7 @@ class TaskHole: self.form.spinRef1.setValue(axis.Offset) self.form.labelRef2.setEnabled(True) self.form.labelRef2.setText("Distance") - if len(axis.References) > 1 and axis.References[1] != None: + if len(axis.References) > 1 and axis.References[1] is not None: if (len(axis.References) == 3): self.form.lineRef2.setText(self.getRefText(axis.References[2])) else: @@ -406,7 +406,7 @@ class TaskHole: self.form.buttonRef2.setEnabled(False) self.form.lineRef1.setEnabled(True) axis = self.feature.HoleGroove.Sketch.Support[0].References[0][0] - if len(axis.References) > 0 and axis.References[0] != None: + if len(axis.References) > 0 and axis.References[0] is not None: self.form.lineRef1.setText(self.getRefText(axis.References[0])) self.form.lineRef2.setEnabled(False) self.form.labelRef1.setEnabled(False) @@ -470,23 +470,23 @@ class TaskHole: def comboNormBoltWasher(self, index): self.feature.ExtraNorm = str(self.form.comboNormBoltWasher.itemText(index)) self.updateUI() - + def comboThreadNorm(self, index): - self.feature.NormThread = str(self.form.comboThreadNorm.itemText(index)) + self.feature.NormThread = str(self.form.comboThreadNorm.itemText(index)) self.updateUI() - + def comboThreadDia(self, index): diameter = str(self.form.comboThreadDia.itemText(index)) self.feature.NormDiameter = float(diameter[1:]) self.updateUI() - + def checkCustomThreadLength(self, checked): if checked == True: self.feature.NormThreadFinish = "Custom" else: self.feature.NormThreadFinish = str(self.form.comboFinishNorm.currentText()) self.updateUI() - + def comboFinishNorm(self, index): self.feature.NormThreadFinish = str(self.form.comboFinishNorm.itemText(index)) self.updateUI() @@ -515,7 +515,7 @@ class TaskHole: def spinThreadLength(self, val): if (val > 0.0): self.feature.ThreadLength = val - + def comboType(self, index): self.feature.PositionType = self.types[index] self.updateUI() @@ -532,12 +532,12 @@ class TaskHole: if shape.Surface.__class__ != Part.Plane: FreeCAD.Console.PrintMessage("Selected face must be planar\n") return - if self.feature.PositionType == self.types[0]: + if self.feature.PositionType == self.types[0]: # The Hole support is also the first reference of the sketch axis in Linear mode with edges selected if len(refs) == 3: refs[0] = (feature, element) axis.References = refs - self.feature.Support = (feature, [element]) + self.feature.Support = (feature, [element]) elif self.selectionMode == "LinearReference": if shape.ShapeType == "Edge": if shape.Curve.__class__ != Part.LineSegment: @@ -560,7 +560,7 @@ class TaskHole: refs = [(feature, element)] else: FreeCAD.Console.PrintMessage("Wrong shape type selected\n") - return + return axis.References = refs axis.Document.recompute() elif self.selectionMode == "LinearReference2": @@ -584,7 +584,7 @@ class TaskHole: refs.append((feature, element)) else: FreeCAD.Console.PrintMessage("Wrong shape type selected\n") - return + return axis.References = refs axis.Document.recompute() elif self.selectionMode == "CircularReference": @@ -598,7 +598,7 @@ class TaskHole: return else: FreeCAD.Console.PrintMessage("Wrong shape type selected\n") - return + return refs = [(feature, element)] axis.References = refs axis.Document.recompute() @@ -616,13 +616,13 @@ class TaskHole: def hideFeature(self): # Make sure selection takes place on support, not on hole feature - if self.feature.Support != None: + if self.feature.Support is not None: FreeCADGui.ActiveDocument.hide(self.feature.Name) (support, elements) = self.feature.Support FreeCADGui.ActiveDocument.show(support.Name) def showFeature(self): - if self.feature.Support != None: + if self.feature.Support is not None: FreeCADGui.ActiveDocument.show(self.feature.Name) (support, elements) = self.feature.Support FreeCADGui.ActiveDocument.hide(support.Name) diff --git a/src/Mod/PartDesign/FeatureHole/ViewProviderHole.py b/src/Mod/PartDesign/FeatureHole/ViewProviderHole.py index b3ac7602f3..2c6b83fd7b 100644 --- a/src/Mod/PartDesign/FeatureHole/ViewProviderHole.py +++ b/src/Mod/PartDesign/FeatureHole/ViewProviderHole.py @@ -40,8 +40,8 @@ class ViewProviderHole: # : PyCXX: Error creating object of type N2Py7SeqBaseINS_6ObjectEEE from None if not hasattr(self, "Object"): return - - if self.Object != None: + + if self.Object is not None: return [self.Object.HoleGroove, # the groove feature self.Object.HoleGroove.Sketch.Support[0], # the groove sketchplane (datum plane) feature self.Object.HoleGroove.Sketch.Support[0].References[0][0]] # the sketchplane first reference (datum line) @@ -63,9 +63,9 @@ class ViewProviderHole: ''' Print the name of the property that has changed ''' #FreeCAD.Console.PrintMessage("Change property: " + str(prop) + "\n") pass - + def setEdit(self,vp,mode): - panel = TaskHole(self.Object) + panel = TaskHole(self.Object) FreeCADGui.Control.showDialog(panel) if not panel.setupUi(): diff --git a/src/Mod/PartDesign/TestPartDesignGui.py b/src/Mod/PartDesign/TestPartDesignGui.py index 9174dcceea..f08e2cf297 100644 --- a/src/Mod/PartDesign/TestPartDesignGui.py +++ b/src/Mod/PartDesign/TestPartDesignGui.py @@ -40,7 +40,7 @@ class CallableCheckWorkflow: def __call__(self): diag = QApplication.activeModalWidget() self.test.assertIsNotNone(diag, "Dialog box could not be found") - if (diag != None): + if (diag is not None): cbuttons = diag.findChildren(QtGui.QPushButton) cbutton = cbuttons[1] dialogcheck = CallableCheckDialog(self.test) @@ -60,7 +60,7 @@ class CallableCheckWarning: def __call__(self): diag = QApplication.activeModalWidget() self.test.assertIsNotNone(diag, "Input dialog box could not be found") - if (diag != None): + if (diag is not None): QtCore.QTimer.singleShot(0, diag, QtCore.SLOT('accept()')) class CallableComboBox: @@ -69,10 +69,10 @@ class CallableComboBox: def __call__(self): diag = QApplication.activeModalWidget() self.test.assertIsNotNone(diag, "Warning dialog box could not be found") - if (diag != None): + if (diag is not None): cbox = diag.findChild(QtGui.QComboBox) self.test.assertIsNotNone(cbox, "ComboBox widget could not be found") - if (cbox != None): + if (cbox is not None): QtCore.QTimer.singleShot(0, diag, QtCore.SLOT('accept()')) App = FreeCAD @@ -155,7 +155,7 @@ class PartDesignGuiTestCases(unittest.TestCase): self.BodySource.addObject(self.Sketch) self.Sketch.Support = (self.BodySource.Origin.OriginFeatures[3], ['']) self.Sketch.MapMode = 'FlatFace' - + geoList = [] geoList.append(Part.LineSegment(App.Vector(-10.000000,10.000000,0),App.Vector(10.000000,10.000000,0))) @@ -195,8 +195,8 @@ class PartDesignGuiTestCases(unittest.TestCase): QtCore.QTimer.singleShot(500, cobj) Gui.runCommand('PartDesign_MoveFeature') #assert depenedencies of the Sketch - self.Doc.recompute() - + self.Doc.recompute() + self.assertFalse(self.Sketch.Support[0][0] in self.BodySource.Origin.OriginFeatures) self.assertTrue(self.Sketch.Support[0][0] in self.BodyTarget.Origin.OriginFeatures) self.assertEqual(len(self.BodySource.Group), 0, "Source body feature count is wrong") @@ -219,7 +219,7 @@ class PartDesignTransformed(unittest.TestCase): self.TempDoc = os.path.join(tempDir, 'PartDesignTransformed.FCStd') App.ActiveDocument.saveAs(self.TempDoc) App.closeDocument("PartDesignTransformed") - + def testMultiTransformCase(self): App.Console.PrintMessage('Testing applying MultiTransform to the Box outside the body\n') App.open(self.TempDoc) @@ -231,10 +231,10 @@ class PartDesignTransformed(unittest.TestCase): Gui.runCommand("PartDesign_MultiTransform") App.closeDocument("PartDesignTransformed") - + def tearDown(self): #closing doc - if (App.ActiveDocument != None and App.ActiveDocument.Name == PartDesignTransformed): + if (App.ActiveDocument is not None and App.ActiveDocument.Name == PartDesignTransformed): App.closeDocument("PartDesignTransformed") #print ("omit closing document for debugging") @@ -248,7 +248,7 @@ class PartDesignTransformed(unittest.TestCase): # self.Box.addGeometry(Part.LineSegment(App.Vector(69.432587,36.960674,0),App.Vector(69.432587,-53.196629,0))) # self.Box.addGeometry(Part.LineSegment(App.Vector(69.432587,-53.196629,0),App.Vector(-99.230339,-53.196629,0))) # self.Box.addGeometry(Part.LineSegment(App.Vector(-99.230339,-53.196629,0),App.Vector(-99.230339,36.960674,0))) -# +# # def tearDown(self): # #closing doc # FreeCAD.closeDocument("SketchGuiTest") diff --git a/src/Mod/PartDesign/WizardShaft/WizardShaft.py b/src/Mod/PartDesign/WizardShaft/WizardShaft.py index ae02afa5d7..13cc7ea033 100644 --- a/src/Mod/PartDesign/WizardShaft/WizardShaft.py +++ b/src/Mod/PartDesign/WizardShaft/WizardShaft.py @@ -189,7 +189,7 @@ class WizardShaftGui: 'ToolTip': ToolTip} def IsActive(self): - return FreeCAD.ActiveDocument != None + return FreeCAD.ActiveDocument is not None def __del__(self): global WizardShaftDlg @@ -198,7 +198,7 @@ class WizardShaftGui: class WizardShaftGuiCallback: def Activated(self): global WizardShaftDlg - if WizardShaftDlg != None and WizardShaftDlg.table != None: + if WizardShaftDlg is not None and WizardShaftDlg.table is not None: WizardShaftDlg.table.finishEditConstraint() def isActive(self):