Skip to content

Commit

Permalink
Some more pylint warning cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert committed Jul 1, 2019
1 parent 6f52808 commit 64bd810
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 36 deletions.
6 changes: 5 additions & 1 deletion src/Mod/Path/PathScripts/PathEngrave.py
Expand Up @@ -52,6 +52,10 @@ def translate(context, text, disambig=None):
class ObjectEngrave(PathEngraveBase.ObjectOp):
'''Proxy class for Engrave operation.'''

def __init__(self, obj, name):
super(ObjectEngrave, self).__init__(obj, name)
self.wires = []

def opFeatures(self, obj):
'''opFeatures(obj) ... return all standard features and edges based geomtries'''
return PathOp.FeatureTool | PathOp.FeatureDepths | PathOp.FeatureHeights | PathOp.FeatureStepDown | PathOp.FeatureBaseEdges
Expand Down Expand Up @@ -130,7 +134,7 @@ def opExecute(self, obj):
if self.commandlist:
self.commandlist.pop()

def opUpdateDepths(self, obj, ignoreErrors=False):
def opUpdateDepths(self, obj):
'''updateDepths(obj) ... engraving is always done at the top most z-value'''
job = PathUtils.findParentJob(obj)
self.opSetDefaultValues(obj, job)
Expand Down
8 changes: 8 additions & 0 deletions src/Mod/Path/PathScripts/PathStock.py
Expand Up @@ -44,6 +44,8 @@ def translate(context, text, disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)

class StockType:
# pylint: disable=no-init

NoStock = 'None'
FromBase = 'FromBase'
CreateBox = 'CreateBox'
Expand Down Expand Up @@ -121,6 +123,12 @@ def __init__(self, obj, base):
PathLog.track(obj.Label, base.Label)
obj.Proxy = self

# debugging aids
self.origin = None
self.length = None
self.width = None
self.height = None

def __getstate__(self):
return None
def __setstate__(self, state):
Expand Down
75 changes: 40 additions & 35 deletions src/Mod/Path/PathScripts/PathToolLibraryManager.py
Expand Up @@ -49,33 +49,34 @@ class FreeCADTooltableHandler(xml.sax.ContentHandler):
# http://www.tutorialspoint.com/python/python_xml_processing.htm

def __init__(self):
xml.sax.ContentHandler.__init__(self)
self.tooltable = None
self.tool = None
self.number = None

# Call when an element is found
def startElement(self, tag, attributes):
if tag == "Tooltable":
def startElement(self, name, attrs):
if name == "Tooltable":
self.tooltable = Path.Tooltable()
elif tag == "Toolslot":
self.number = int(attributes["number"])
elif tag == "Tool":
elif name == "Toolslot":
self.number = int(attrs["number"])
elif name == "Tool":
self.tool = Path.Tool()
self.tool.Name = str(attributes["name"])
self.tool.ToolType = str(attributes["type"])
self.tool.Material = str(attributes["mat"])
self.tool.Name = str(attrs["name"])
self.tool.ToolType = str(attrs["type"])
self.tool.Material = str(attrs["mat"])
# for some reason without the following line I get an error
#print attributes["diameter"]
self.tool.Diameter = float(attributes["diameter"])
self.tool.LengthOffset = float(attributes["length"])
self.tool.FlatRadius = float(attributes["flat"])
self.tool.CornerRadius = float(attributes["corner"])
self.tool.CuttingEdgeAngle = float(attributes["angle"])
self.tool.CuttingEdgeHeight = float(attributes["height"])
#print attrs["diameter"]
self.tool.Diameter = float(attrs["diameter"])
self.tool.LengthOffset = float(attrs["length"])
self.tool.FlatRadius = float(attrs["flat"])
self.tool.CornerRadius = float(attrs["corner"])
self.tool.CuttingEdgeAngle = float(attrs["angle"])
self.tool.CuttingEdgeHeight = float(attrs["height"])

# Call when an elements ends
def endElement(self, tag):
if tag == "Toolslot":
def endElement(self, name):
if name == "Toolslot":
if self.tooltable and self.tool and self.number:
self.tooltable.setTool(self.number, self.tool)
self.number = None
Expand All @@ -85,18 +86,19 @@ def endElement(self, tag):
class HeeksTooltableHandler(xml.sax.ContentHandler):

def __init__(self):
xml.sax.ContentHandler.__init__(self)
self.tooltable = Path.Tooltable()
self.tool = None
self.number = None

# Call when an element is found
def startElement(self, tag, attributes):
if tag == "Tool":
def startElement(self, name, attrs):
if name == "Tool":
self.tool = Path.Tool()
self.number = int(attributes["tool_number"])
self.tool.Name = str(attributes["title"])
elif tag == "params":
t = str(attributes["type"])
self.number = int(attrs["tool_number"])
self.tool.Name = str(attrs["title"])
elif name == "params":
t = str(attrs["type"])
if t == "drill":
self.tool.ToolType = "Drill"
elif t == "center_drill_bit":
Expand All @@ -111,25 +113,25 @@ def startElement(self, tag, attributes):
self.tool.ToolType = "Chamfer"
elif t == "engraving_bit":
self.tool.ToolType = "Engraver"
m = str(attributes["material"])
m = str(attrs["material"])
if m == "0":
self.tool.Material = "HighSpeedSteel"
elif m == "1":
self.tool.Material = "Carbide"
# for some reason without the following line I get an error
#print attributes["diameter"]
self.tool.Diameter = float(attributes["diameter"])
self.tool.LengthOffset = float(attributes["tool_length_offset"])
self.tool.FlatRadius = float(attributes["flat_radius"])
self.tool.CornerRadius = float(attributes["corner_radius"])
#print attrs["diameter"]
self.tool.Diameter = float(attrs["diameter"])
self.tool.LengthOffset = float(attrs["tool_length_offset"])
self.tool.FlatRadius = float(attrs["flat_radius"])
self.tool.CornerRadius = float(attrs["corner_radius"])
self.tool.CuttingEdgeAngle = float(
attributes["cutting_edge_angle"])
attrs["cutting_edge_angle"])
self.tool.CuttingEdgeHeight = float(
attributes["cutting_edge_height"])
attrs["cutting_edge_height"])

# Call when an elements ends
def endElement(self, tag):
if tag == "Tool":
def endElement(self, name):
if name == "Tool":
if self.tooltable and self.tool and self.number:
self.tooltable.setTool(self.number, self.tool)
self.number = None
Expand Down Expand Up @@ -286,7 +288,7 @@ def read(self, filename, listname):
if listname == "<Main>":
self.saveMainLibrary(tt)
return True
except Exception as e:
except Exception as e: # pylint: disable=broad-except
print("could not parse file", e)


Expand Down Expand Up @@ -317,7 +319,7 @@ def openFileWithExtension(name, ext):
fp.close()
print("Written ", PathUtil.toUnicode(fname))

except Exception as e:
except Exception as e: # pylint: disable=broad-except
print("Could not write file:", e)

def addnew(self, listname, tool, position = None):
Expand Down Expand Up @@ -605,6 +607,9 @@ def setupUi(self):
self.setFields()

class CommandToolLibraryEdit():
def __init__(self):
pass

def edit(self, job=None, cb=None):
editor = EditorPanel(job, cb)
editor.setupUi()
Expand Down

0 comments on commit 64bd810

Please sign in to comment.