Skip to content

Commit

Permalink
Fixed some pylint issues and whitelisted some
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert committed Nov 29, 2019
1 parent 012732e commit b182d7b
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathCircularHoleBase.py
Expand Up @@ -143,7 +143,7 @@ def holeDiameter(self, obj, base, sub):
return shape.Curve.Radius * 2

if shape.ShapeType == 'Face':
for i in range(len(shape.Edges)):
for i in range(len(shape.Edges)):
if (type(shape.Edges[i].Curve) == Part.Circle and
shape.Edges[i].Curve.Radius * 2 < shape.BoundBox.XLength*1.1 and
shape.Edges[i].Curve.Radius * 2 > shape.BoundBox.XLength*0.9):
Expand Down
8 changes: 7 additions & 1 deletion src/Mod/Path/PathScripts/PathDressupHoldingTags.py
Expand Up @@ -759,7 +759,13 @@ def __init__(self, obj, base):
obj.addProperty("App::PropertyIntegerList", "Disabled", "Tag", QtCore.QT_TRANSLATE_NOOP("Path_DressupTag", "IDs of disabled holding tags"))
obj.addProperty("App::PropertyInteger", "SegmentationFactor", "Tag", QtCore.QT_TRANSLATE_NOOP("Path_DressupTag", "Factor determining the # of segments used to approximate rounded tags."))

self.__setstate__(obj)
# for pylint ...
self.obj = obj
self.solids = []
self.tags = []
self.pathData = None
self.toolRadius = None
self.mappers = []

obj.Proxy = self
obj.Base = base
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Path/PathScripts/PathDrillingGui.py
Expand Up @@ -51,6 +51,7 @@ class TaskPanelOpPage(PathCircularHoleBaseGui.TaskPanelOpPage):
'''Controller for the drilling operation's page'''

def initPage(self, obj):
# pylint: disable=attribute-defined-outside-init
self.peckDepthSpinBox = PathGui.QuantitySpinBox(self.form.peckDepth, obj, 'PeckDepth')
self.peckRetractSpinBox = PathGui.QuantitySpinBox(self.form.peckRetractHeight, obj, 'RetractHeight')
self.dwellTimeSpinBox = PathGui.QuantitySpinBox(self.form.dwellTime, obj, 'DwellTime')
Expand Down Expand Up @@ -80,6 +81,7 @@ def getForm(self):
return FreeCADGui.PySideUic.loadUi(":/panels/PageOpDrillingEdit.ui")

def updateQuantitySpinBoxes(self, index = None):
# pylint: disable=unused-argument
self.peckDepthSpinBox.updateSpinBox()
self.peckRetractSpinBox.updateSpinBox()
self.dwellTimeSpinBox.updateSpinBox()
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathMillFace.py
Expand Up @@ -131,7 +131,7 @@ def areaOpShapes(self, obj):
else:
holes.append((b[0].Shape, wire))
else:
PathLog.error('The base subobject, "{}," is not a face. Ignoring "{}."'.format(sub, sub))
PathLog.error('The base subobject, "{0}," is not a face. Ignoring "{0}."'.format(sub))

if obj.ExcludeRaisedAreas is True and len(holes) > 0:
for shape, wire in holes:
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Path/PathScripts/PathToolBit.py
Expand Up @@ -311,6 +311,7 @@ def __init__(self):
class ToolBitFactory(object):

def CreateFromAttrs(self, attrs, name='ToolBit'):
# pylint: disable=protected-access
obj = Factory.Create(name, attrs['shape'])
obj.Label = attrs['name']
params = attrs['parameter']
Expand Down
10 changes: 4 additions & 6 deletions src/Mod/Path/PathScripts/PathToolBitEdit.py
Expand Up @@ -22,16 +22,13 @@
# * *
# ***************************************************************************

import FreeCAD
import FreeCADGui
import Path
import PathScripts.PathGui as PathGui
import PathScripts.PathLog as PathLog
import PathScripts.PathPreferences as PathPreferences
import PathScripts.PathSetupSheetGui as PathSetupSheetGui
import PathScripts.PathToolBit as PathToolBit
import copy
import math
import os
import re

from PySide import QtCore, QtGui
Expand Down Expand Up @@ -122,6 +119,7 @@ def setupAttributes(self, tool):
self.model.dataChanged.connect(self.updateData)

def updateData(self, topLeft, bottomRight):
# pylint: disable=unused-argument
if 0 == topLeft.column():
isset = self.model.item(topLeft.row(), 0).checkState() == QtCore.Qt.Checked
self.model.item(topLeft.row(), 1).setEnabled(isset)
Expand All @@ -138,11 +136,10 @@ def accept(self):
if enabled and not prop.getValue() is None:
prop.setupProperty(self.tool, name, PathToolBit.PropertyGroupAttribute, prop.getValue())
elif hasattr(self.tool, name):
self.obj.removeProperty(name)
self.tool.removeProperty(name)

def reject(self):
self.tool.Proxy.unloadBitBody(self.tool)
pass

def updateUI(self):
PathLog.track()
Expand All @@ -161,6 +158,7 @@ def updateShape(self):
self.bitEditor[editor].updateSpinBox()

def updateTool(self):
# pylint: disable=protected-access
PathLog.track()
self.tool.Label = str(self.form.toolName.text())
self.tool.BitShape = str(self.form.shapePath.text())
Expand Down
20 changes: 8 additions & 12 deletions src/Mod/Path/PathScripts/PathToolBitGui.py
Expand Up @@ -24,13 +24,11 @@

import FreeCAD
import FreeCADGui
import PathScripts.PathGui as PathGui
import PathScripts.PathIconViewProvider as PathIconViewProvider
import PathScripts.PathLog as PathLog
import PathScripts.PathPreferences as PathPreferences
import PathScripts.PathToolBit as PathToolBit
import PathScripts.PathToolBitEdit as PathToolBitEdit
import PathScripts.PathUtil as PathUtil
import os

from PySide import QtCore, QtGui
Expand All @@ -53,6 +51,7 @@ class ViewProvider(object):

def __init__(self, vobj, name):
PathLog.track(name, vobj.Object)
self.panel = None
self.icon = name
self.obj = vobj.Object
self.vobj = vobj
Expand Down Expand Up @@ -84,10 +83,10 @@ def getDisplayMode(self, mode):

def _openTaskPanel(self, vobj, deleteOnReject):
PathLog.track()
self.taskPanel = TaskPanel(vobj, deleteOnReject)
self.panel = TaskPanel(vobj, deleteOnReject)
FreeCADGui.Control.closeDialog()
FreeCADGui.Control.showDialog(self.taskPanel)
self.taskPanel.setupUi()
FreeCADGui.Control.showDialog(self.panel)
self.panel.setupUi()

def setCreate(self, vobj):
PathLog.track()
Expand All @@ -101,7 +100,7 @@ def setEdit(self, vobj, mode=0):
def unsetEdit(self, vobj, mode):
# pylint: disable=unused-argument
FreeCADGui.Control.closeDialog()
self.taskPanel = None
self.panel = None
return

def claimChildren(self):
Expand Down Expand Up @@ -143,19 +142,13 @@ def accept(self):
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.recompute()

def getFields(self):
self.editor.getFields()

def updateUI(self):
self.editor.updateUI()

def updateModel(self):
self.editor.updateTool()
FreeCAD.ActiveDocument.recompute()

def setFields(self):
self.editor.setFields()

def setupUi(self):
self.editor.setupUI()

Expand All @@ -164,6 +157,9 @@ class ToolBitSelector(object):
ToolRole = QtCore.Qt.UserRole + 1

def __init__(self):
self.buttons = None
self.editor = None
self.dialog = None
self.form = FreeCADGui.PySideUic.loadUi(':/panels/ToolBitSelector.ui')
self.setupUI()

Expand Down
12 changes: 7 additions & 5 deletions src/Mod/Path/PathScripts/PathToolBitLibraryGui.py
Expand Up @@ -32,7 +32,7 @@
import json
import os
import traceback
import uuid
import uuid as UUID

PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
Expand Down Expand Up @@ -70,7 +70,6 @@ def _rowWithUuid(self, uuid):

def _copyTool(self, uuid_, dstRow):
model = self.model()
items = []
model.insertRow(dstRow)
srcRow = self._rowWithUuid(uuid_)
for col in range(model.columnCount()):
Expand All @@ -81,7 +80,7 @@ def _copyTool(self, uuid_, dstRow):
model.setData(model.index(dstRow, col), srcItem.data(_PathRole), _PathRole)
# Even a clone of a tool gets its own uuid so it can be identified when
# rearranging the order or inserting/deleting rows
model.setData(model.index(dstRow, col), uuid.uuid4(), _UuidRole)
model.setData(model.index(dstRow, col), UUID.uuid4(), _UuidRole)
else:
model.item(dstRow, col).setEditable(False)

Expand All @@ -96,6 +95,7 @@ def dropEvent(self, event):
stream = PySide.QtCore.QDataStream(data)
srcRows = []
while not stream.atEnd():
# pylint: disable=unused-variable
row = stream.readInt32()
srcRows.append(row)
col = stream.readInt32()
Expand Down Expand Up @@ -141,7 +141,7 @@ def _toolAdd(self, nr, tool, path):
toolNr = PySide.QtGui.QStandardItem()
toolNr.setData(nr, PySide.QtCore.Qt.EditRole)
toolNr.setData(path, _PathRole)
toolNr.setData(uuid.uuid4(), _UuidRole)
toolNr.setData(UUID.uuid4(), _UuidRole)

toolName = PySide.QtGui.QStandardItem()
toolName.setData(tool['name'], PySide.QtCore.Qt.EditRole)
Expand All @@ -159,6 +159,7 @@ def _toolAdd(self, nr, tool, path):

def toolAdd(self):
PathLog.track()
# pylint: disable=broad-except
try:
nr = 0
for row in range(self.model.rowCount()):
Expand All @@ -170,7 +171,7 @@ def toolAdd(self):
tool = PathToolBit.Declaration(foo)
self._toolAdd(nr + i, tool, foo)
self.toolTableView.resizeColumnsToContents()
except:
except Exception:
PathLog.error('something happened')
PathLog.error(traceback.print_exc())

Expand Down Expand Up @@ -198,6 +199,7 @@ def toolEnumerate(self):
self.model.setData(self.model.index(row, 0), row + 1, PySide.QtCore.Qt.EditRole)

def toolSelect(self, selected, deselected):
# pylint: disable=unused-argument
self.form.toolDelete.setEnabled(len(self.toolTableView.selectedIndexes()) > 0)

def open(self, path=None, dialog=False):
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Path/PathScripts/PathToolController.py
Expand Up @@ -82,6 +82,7 @@ def onDocumentRestored(self, obj):
obj.setEditorMode('Placement', 2)

def onDelete(self, obj, arg2=None):
# pylint: disable=unused-argument
if not self.usesLegacyTool(obj):
if len(obj.Tool.InList) == 1:
obj.Document.removeObject(obj.Tool.Name)
Expand Down Expand Up @@ -214,6 +215,7 @@ def Create(name = 'Default Tool', tool=None, toolNumber=1, assignViewProvider=Tr
return obj

def FromTemplate(template, assignViewProvider=True):
# pylint: disable=unused-argument
PathLog.track()

name = template.get(ToolControllerTemplate.Name, ToolControllerTemplate.Label)
Expand Down
1 change: 0 additions & 1 deletion src/Mod/Path/PathScripts/PathToolControllerGui.py
Expand Up @@ -28,7 +28,6 @@
import PathScripts
import PathScripts.PathGui as PathGui
import PathScripts.PathLog as PathLog
import PathScripts.PathToolBit as PathToolBit
import PathScripts.PathToolBitGui as PathToolBitGui
import PathScripts.PathToolEdit as PathToolEdit
import PathScripts.PathUtil as PathUtil
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Path/PathTests/TestPathHelix.py
Expand Up @@ -36,6 +36,7 @@
class TestPathHelix(PathTestUtils.PathTestBase):

def setUp(self):
self.clone = None
self.doc = FreeCAD.open(FreeCAD.getHomePath() + 'Mod/Path/PathTests/test_holes00.fcstd')
self.job = PathJob.Create('Job', [self.doc.Body])

Expand Down
8 changes: 4 additions & 4 deletions src/Mod/Path/PathTests/TestPathToolBit.py
Expand Up @@ -29,16 +29,16 @@
class TestPathToolBit(PathTestUtils.PathTestBase):

def test00(self):
'''Find a tool template from file name'''
'''Find a tool shapee from file name'''

path = PathToolBit.findTemplate('endmill-straight.fcstd')
path = PathToolBit.findShape('endmill-straight.fcstd')
self.assertIsNot(path, None)
self.assertNotEqual(path, 'endmill-straight.fcstd')

def test01(self):
'''Find a tool template from an invalid absolute path.'''
'''Find a tool shapee from an invalid absolute path.'''

path = PathToolBit.findTemplate('/this/is/unlikely/a/valid/path/v-bit.fcstd')
path = PathToolBit.findShape('/this/is/unlikely/a/valid/path/v-bit.fcstd')
self.assertIsNot(path, None)
self.assertNotEqual(path, '/this/is/unlikely/a/valid/path/v-bit.fcstd')

Expand Down
1 change: 1 addition & 0 deletions src/Mod/Path/utils/path-lint.sh
Expand Up @@ -56,6 +56,7 @@ EXTERNAL_MODULES+=' Path'
EXTERNAL_MODULES+=' PySide'
EXTERNAL_MODULES+=' PySide.QtCore'
EXTERNAL_MODULES+=' PySide.QtGui'
EXTERNAL_MODULES+=' Sketcher'
EXTERNAL_MODULES+=' TechDraw'
EXTERNAL_MODULES+=' TestSketcherApp'
EXTERNAL_MODULES+=' area'
Expand Down

0 comments on commit b182d7b

Please sign in to comment.