Mod: remove some superfluous Boolean checks (#7213)
* Mod: remove some superfluous Python Boolean checks
This commit is contained in:
@@ -398,7 +398,7 @@ class _ViewProviderAxis:
|
||||
center = p2.add(Vector(dv).multiply(rad))
|
||||
normal = vobj.Object.Placement.Rotation.multVec(Vector(0,0,1))
|
||||
chord = dv.cross(normal)
|
||||
if arrow == True:
|
||||
if arrow:
|
||||
p3 = p2.add(Vector(chord).multiply(rad/2).negative())
|
||||
if vobj.BubblePosition.startswith("Arrow"):
|
||||
p4 = p3.add(Vector(dv).multiply(rad*2).negative())
|
||||
|
||||
@@ -231,7 +231,7 @@ class _CommandBuilding:
|
||||
if not Draft.getType(obj) in ["Site", "Building"] :
|
||||
buildingobj.append(obj)
|
||||
else :
|
||||
if link == True :
|
||||
if link :
|
||||
buildingobj.append(obj)
|
||||
else:
|
||||
warning = True
|
||||
|
||||
@@ -1704,7 +1704,7 @@ class _ToggleSubs:
|
||||
if mode is None:
|
||||
# take the first sub as base
|
||||
mode = sub.ViewObject.isVisible()
|
||||
if mode == True:
|
||||
if mode:
|
||||
sub.ViewObject.hide()
|
||||
else:
|
||||
sub.ViewObject.show()
|
||||
|
||||
@@ -139,7 +139,7 @@ class _CommandFloor:
|
||||
if not Draft.getType(obj) in ["Site", "Building"] :
|
||||
floorobj.append(obj)
|
||||
else :
|
||||
if link == True :
|
||||
if link:
|
||||
floorobj.append(obj)
|
||||
else:
|
||||
warning = True
|
||||
|
||||
@@ -473,7 +473,7 @@ class ViewProviderArchReference:
|
||||
if vobj.DiffuseColor and vobj.UpdateColors:
|
||||
vobj.DiffuseColor = vobj.DiffuseColor
|
||||
elif prop == "Visibility":
|
||||
if vobj.Visibility == True:
|
||||
if vobj.Visibility:
|
||||
if (not vobj.Object.Shape) or vobj.Object.Shape.isNull():
|
||||
vobj.Object.Proxy.reload = True
|
||||
vobj.Object.Proxy.execute(vobj.Object)
|
||||
|
||||
@@ -516,15 +516,15 @@ class _CommandSite:
|
||||
link = p.GetBool("FreeLinking",False)
|
||||
siteobj = []
|
||||
warning = False
|
||||
for obj in sel :
|
||||
for obj in sel:
|
||||
if (Draft.getType(obj) == "Building") or (hasattr(obj,"IfcType") and obj.IfcType == "Building"):
|
||||
siteobj.append(obj)
|
||||
else :
|
||||
if link == True :
|
||||
else:
|
||||
if link:
|
||||
siteobj.append(obj)
|
||||
else:
|
||||
warning = True
|
||||
if warning :
|
||||
if warning:
|
||||
message = translate( "Arch" , "Please either select only Building objects or nothing at all!\n\
|
||||
Site is not allowed to accept any other object besides Building.\n\
|
||||
Other objects will be removed from the selection.\n\
|
||||
@@ -534,7 +534,7 @@ Note: You can change that in the preferences.")
|
||||
message = translate( "Arch" , "There is no valid object in the selection.\n\
|
||||
Site creation aborted.") + "\n"
|
||||
ArchCommands.printMessage( message )
|
||||
else :
|
||||
else:
|
||||
ss = "[ "
|
||||
for o in siteobj:
|
||||
ss += "FreeCAD.ActiveDocument." + o.Name + ", "
|
||||
|
||||
@@ -1379,7 +1379,7 @@ class _StructuralSystem(ArchComponent.Component): # OBSOLETE - All Arch objects
|
||||
if hasattr(obj,"Align"):
|
||||
if obj.Align == False :
|
||||
apl = self.getAxisPlacement(obj)
|
||||
if obj.Align == True :
|
||||
if obj.Align:
|
||||
apl = None
|
||||
else :
|
||||
apl = self.getAxisPlacement(obj)
|
||||
@@ -1419,7 +1419,7 @@ class _StructuralSystem(ArchComponent.Component): # OBSOLETE - All Arch objects
|
||||
pts = []
|
||||
if len(obj.Axes) == 1:
|
||||
if hasattr(obj,"Align"):
|
||||
if obj.Align == True :
|
||||
if obj.Align:
|
||||
p0 = obj.Axes[0].Shape.Edges[0].Vertexes[1].Point
|
||||
for e in obj.Axes[0].Shape.Edges:
|
||||
p = e.Vertexes[1].Point
|
||||
|
||||
@@ -161,7 +161,7 @@ def upgrade(objects, delete=False, force=None):
|
||||
return None
|
||||
if len(obj.Shape.Edges) == 1:
|
||||
return None
|
||||
if is_straight_line(obj.Shape) == True:
|
||||
if is_straight_line(obj.Shape):
|
||||
return None
|
||||
if utils.get_type(obj) == "Wire":
|
||||
obj.Closed = True
|
||||
@@ -507,10 +507,9 @@ def upgrade(objects, delete=False, force=None):
|
||||
elif len(objects) > 1 and len(edges) > 1:
|
||||
result = makeWires(objects)
|
||||
if result:
|
||||
if result == True:
|
||||
_msg(translate("draft","Found several wires or edges: wiring them"))
|
||||
else:
|
||||
_msg(translate("draft","Found several non-treatable objects: creating compound"))
|
||||
_msg(translate("draft","Found several wires or edges: wiring them"))
|
||||
else:
|
||||
_msg(translate("draft","Found several non-treatable objects: creating compound"))
|
||||
# special case, we have only one open wire. We close it,
|
||||
# unless it has only 1 edge!
|
||||
elif len(objects) == 1 and len(openwires) == 1:
|
||||
|
||||
@@ -194,7 +194,7 @@ class DraftBSplineGuiTools(DraftWireGuiTools):
|
||||
return
|
||||
|
||||
pts = obj.Points
|
||||
if (obj.Closed == True):
|
||||
if obj.Closed:
|
||||
curve = obj.Shape.Edges[0].Curve
|
||||
else:
|
||||
curve = obj.Shape.Curve
|
||||
@@ -455,7 +455,7 @@ class DraftCircleGuiTools(GuiTools):
|
||||
px = obj.Radius * math.cos(math.radians(angle))
|
||||
py = obj.Radius * math.sin(math.radians(angle))
|
||||
p = App.Vector(px, py, 0.0)
|
||||
if global_placement == True:
|
||||
if global_placement:
|
||||
p = obj.getGlobalPlacement().multVec(p)
|
||||
return p
|
||||
return None
|
||||
|
||||
@@ -93,7 +93,7 @@ class ExplodeGroup:
|
||||
import FreeCADGui
|
||||
oo.ViewObject.show()
|
||||
if color and isdefault(oo.ViewObject.DiffuseColor):
|
||||
if color == True:
|
||||
if color:
|
||||
oo.ViewObject.DiffuseColor=randomcolor()
|
||||
else:
|
||||
oo.ViewObject.DiffuseColor=color
|
||||
|
||||
@@ -484,9 +484,9 @@ def p_offset_action(p):
|
||||
# newobj.ViewObject.Proxy = 0
|
||||
p[0] = [newobj]
|
||||
|
||||
def checkObjShape(obj) :
|
||||
def checkObjShape(obj):
|
||||
if printverbose: print('Check Object Shape')
|
||||
if obj.Shape.isNull() == True :
|
||||
if obj.Shape.isNull():
|
||||
if printverbose: print('Shape is Null - recompute')
|
||||
obj.recompute()
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ def compute():
|
||||
App.ActiveDocument.recompute()
|
||||
|
||||
|
||||
if c1.isChecked()==True:
|
||||
if c1.isChecked():
|
||||
gearMesh = App.ActiveDocument.addObject("Mesh::Feature", "Gear3D-mesh")
|
||||
|
||||
faces = []
|
||||
|
||||
@@ -174,7 +174,7 @@ class PathBoundary:
|
||||
lastExit = None
|
||||
for cmd in self.baseOp.Path.Commands[1:]:
|
||||
if cmd.Name in PathGeom.CmdMoveAll:
|
||||
if bogusX == True:
|
||||
if bogusX:
|
||||
bogusX = "X" not in cmd.Parameters
|
||||
if bogusY:
|
||||
bogusY = "Y" not in cmd.Parameters
|
||||
|
||||
@@ -666,9 +666,9 @@ def HEIDEN_Line(
|
||||
H_Line += " " + H_Line_Params[1][0]
|
||||
|
||||
# F parameter (check rapid o feed)
|
||||
if line_rapid == True:
|
||||
if line_rapid:
|
||||
H_Line_Params[1][1] = FEED_MAX_SPEED
|
||||
if MACHINE_USE_FMAX == True and line_rapid == True:
|
||||
if MACHINE_USE_FMAX and line_rapid:
|
||||
H_Line += " FMAX"
|
||||
else:
|
||||
if (
|
||||
@@ -837,9 +837,9 @@ def HEIDEN_Arc(
|
||||
H_ArcPoint += " " + H_Arc_Params[1][0]
|
||||
|
||||
# F parameter
|
||||
if arc_rapid == True:
|
||||
if arc_rapid:
|
||||
H_Arc_Params[1][1] = FEED_MAX_SPEED
|
||||
if MACHINE_USE_FMAX == True and arc_rapid == True:
|
||||
if MACHINE_USE_FMAX and arc_rapid:
|
||||
H_ArcPoint += " FMAX"
|
||||
else:
|
||||
if (
|
||||
|
||||
@@ -431,7 +431,7 @@ def export(objectslist, filename, argstring):
|
||||
|
||||
if not MODAL or command != lastcommand:
|
||||
outstring.append(mappedCommand)
|
||||
# if MODAL == True:
|
||||
# if MODAL:
|
||||
# #\better: append iff MODAL == False
|
||||
# if command == lastcommand:
|
||||
# outstring.pop(0)
|
||||
|
||||
@@ -56,10 +56,10 @@ class MenuCreateCases(unittest.TestCase):
|
||||
self.b = False
|
||||
for i in list:
|
||||
if i == 'TestMenu': self.b=True
|
||||
self.failUnless(self.b==True,"Test menu not found")
|
||||
self.failUnless(self.b,"Test menu not found")
|
||||
|
||||
def tearDown(self):
|
||||
if self.b == True:
|
||||
if self.b:
|
||||
FreeCAD.Console.PrintLog ('Test menu successfully added\n')
|
||||
else:
|
||||
FreeCAD.Console.PrintLog ('Adding Test menu failed\n')
|
||||
@@ -84,7 +84,7 @@ class MenuDeleteCases(unittest.TestCase):
|
||||
self.failUnless(self.b==True,"Test menu still added")
|
||||
|
||||
def tearDown(self):
|
||||
if self.b == True:
|
||||
if self.b:
|
||||
FreeCAD.Console.PrintLog ('Test menu successfully removed\n')
|
||||
else:
|
||||
FreeCAD.Console.PrintLog ('Removing Test menu failed\n')
|
||||
|
||||
Reference in New Issue
Block a user