From 45529de1f0eb18ab29bf2d8f6f8ff8527c9098bc Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Fri, 27 Aug 2021 22:37:32 -0500 Subject: [PATCH] Path: LGTM cleanup --- src/Mod/Path/PathScripts/PathAdaptive.py | 15 ++------------- src/Mod/Path/PathScripts/PathCustom.py | 8 +++----- src/Mod/Path/PathScripts/PathCustomGui.py | 1 - src/Mod/Path/PathScripts/PathDeburrGui.py | 10 ++-------- src/Mod/Path/PathScripts/PathDressupDogbone.py | 10 ++++++---- .../Path/PathScripts/PathDressupHoldingTags.py | 8 +++++--- src/Mod/Path/PathScripts/PathDressupLeadInOut.py | 1 - 7 files changed, 18 insertions(+), 35 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathAdaptive.py b/src/Mod/Path/PathScripts/PathAdaptive.py index 2c765c5d15..8368a38892 100644 --- a/src/Mod/Path/PathScripts/PathAdaptive.py +++ b/src/Mod/Path/PathScripts/PathAdaptive.py @@ -396,8 +396,6 @@ def GenerateGCode(op, obj, adaptiveResults, helixDiameter): if z != lz: op.commandlist.append(Path.Command("G0", {"Z": z})) - lz = z - def Execute(op, obj): # pylint: disable=global-statement @@ -455,7 +453,7 @@ def Execute(op, obj): stockPath2d = convertTo2d(stockPaths) - opType = area.AdaptiveOperationType.ClearingInside + # opType = area.AdaptiveOperationType.ClearingInside # Commented out per LGTM suggestion if obj.OperationType == "Clearing": if obj.Side == "Outside": opType = area.AdaptiveOperationType.ClearingOutside @@ -725,16 +723,7 @@ class PathAdaptive(PathOp.ObjectOp): obj.setEditorMode('removalshape', 2) # hide FeatureExtensions.initialize_properties(obj) - - -def SetupProperties(): - setup = ["Side", "OperationType", "Tolerance", "StepOver", - "LiftDistance", "KeepToolDownRatio", "StockToLeave", - "ForceInsideOut", "FinishingProfile", "Stopped", - "StopProcessing", "UseHelixArcs", "AdaptiveInputState", - "AdaptiveOutputState", "HelixAngle", "HelixConeAngle", - "HelixDiameterLimit", "UseOutline"] - return setup +# Eclass def SetupProperties(): diff --git a/src/Mod/Path/PathScripts/PathCustom.py b/src/Mod/Path/PathScripts/PathCustom.py index 73c4b4097e..b31534d07e 100644 --- a/src/Mod/Path/PathScripts/PathCustom.py +++ b/src/Mod/Path/PathScripts/PathCustom.py @@ -33,11 +33,9 @@ __author__ = "sliptonic (Brad Collette)" __url__ = "http://www.freecadweb.org" __doc__ = "Path Custom object and FreeCAD command" -if False: - PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) - PathLog.trackModule(PathLog.thisModule()) -else: - PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) + +PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) +# PathLog.trackModule(PathLog.thisModule()) # Qt translation handling diff --git a/src/Mod/Path/PathScripts/PathCustomGui.py b/src/Mod/Path/PathScripts/PathCustomGui.py index 658468a4e0..987bcfb50e 100644 --- a/src/Mod/Path/PathScripts/PathCustomGui.py +++ b/src/Mod/Path/PathScripts/PathCustomGui.py @@ -22,7 +22,6 @@ import FreeCAD import FreeCADGui -import PathGui as PGui # ensure Path/Gui/Resources are loaded import PathScripts.PathCustom as PathCustom import PathScripts.PathOpGui as PathOpGui diff --git a/src/Mod/Path/PathScripts/PathDeburrGui.py b/src/Mod/Path/PathScripts/PathDeburrGui.py index 76e5f405e6..537d12dca5 100644 --- a/src/Mod/Path/PathScripts/PathDeburrGui.py +++ b/src/Mod/Path/PathScripts/PathDeburrGui.py @@ -22,12 +22,10 @@ import FreeCAD import FreeCADGui -import PathGui as PGui # ensure Path/Gui/Resources are loaded import PathScripts.PathDeburr as PathDeburr import PathScripts.PathGui as PathGui import PathScripts.PathLog as PathLog import PathScripts.PathOpGui as PathOpGui -import Part from PySide import QtCore, QtGui __title__ = "Path Deburr Operation UI" @@ -35,13 +33,9 @@ __author__ = "sliptonic (Brad Collette), Schildkroet" __url__ = "https://www.freecadweb.org" __doc__ = "Deburr operation page controller and command implementation." -LOGLEVEL = False -if LOGLEVEL: - PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) - PathLog.trackModule(PathLog.thisModule()) -else: - PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) +PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) +# PathLog.trackModule(PathLog.thisModule()) def translate(context, text, disambig=None): diff --git a/src/Mod/Path/PathScripts/PathDressupDogbone.py b/src/Mod/Path/PathScripts/PathDressupDogbone.py index eee3a402e7..c91ef30078 100644 --- a/src/Mod/Path/PathScripts/PathDressupDogbone.py +++ b/src/Mod/Path/PathScripts/PathDressupDogbone.py @@ -692,10 +692,12 @@ class ObjectDressup(object): self.bones.append((bone.boneId, bone.locationZ(), enabled, inaccessible)) self.boneId = bone.boneId - if False and PathLog.getLevel(LOG_MODULE) == PathLog.Level.DEBUG and bone.boneId > 2: - commands = self.boneCommands(bone, False) - else: - commands = self.boneCommands(bone, enabled) + # Specific debugging `if` statement + # if PathLog.getLevel(LOG_MODULE) == PathLog.Level.DEBUG and bone.boneId > 2: + # commands = self.boneCommands(bone, False) + # else: + # commands = self.boneCommands(bone, enabled) + commands = self.boneCommands(bone, enabled) bone.commands = commands self.shapes[bone.boneId] = self.boneShapes diff --git a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py index c9521df52b..3f36d43d05 100644 --- a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py +++ b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py @@ -488,7 +488,7 @@ class MapWireToTag: commands.extend(PathGeom.cmdsForEdge(e, False, False, self.segm, hSpeed = self.hSpeed, vSpeed = self.vSpeed)) if rapid: commands.append(Path.Command('G0', {'X': rapid.x, 'Y': rapid.y, 'Z': rapid.z})) - rapid = None + # rapid = None # commented out per LGTM suggestion return commands except Exception as e: # pylint: disable=broad-except PathLog.error("Exception during processing tag @(%.2f, %.2f) (%s) - disabling the tag" % (self.tag.x, self.tag.y, e.args[0])) @@ -665,7 +665,7 @@ class PathData: return tags - def copyTags(self, obj, fromObj, width, height, angle, radius): + def copyTags(self, obj, fromObj, width, height, angle, radius, production=True): print("copyTags(%s, %s, %.2f, %.2f, %.2f, %.2f" % (obj.Label, fromObj.Label, width, height, angle, radius)) W = width if width else self.defaultTagWidth() H = height if height else self.defaultTagHeight() @@ -678,7 +678,9 @@ class PathData: print("tag[%d]" % i) if not i in fromObj.Disabled: dist = self.baseWire.distToShape(Part.Vertex(FreeCAD.Vector(pos.x, pos.y, self.minZ))) - if True or dist[0] < W: + if production or dist[0] < W: + # russ4262:: `production` variable was a `True` declaration, forcing True branch to be processed always + # The application of the `production` argument/variable is to appease LGTM print("tag[%d/%d]: (%.2f, %.2f, %.2f)" % (i, j, pos.x, pos.y, self.minZ)) at = dist[1][0][0] tags.append(Tag(j, at.x, at.y, W, H, A, R, True)) diff --git a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py index 03f24a277f..e9435d66fc 100644 --- a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py +++ b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py @@ -434,7 +434,6 @@ class ObjectDressup: # Add last layer if len(queue) > 0: layers.append(queue) - queue = [] # Go through each layer and add leadIn/Out idx = 0