Fixed some pylint issues and whitelisted some

This commit is contained in:
Markus Lampert
2019-11-01 14:41:45 -07:00
parent db1f97b16e
commit 9910600799
13 changed files with 39 additions and 31 deletions

View File

@@ -143,7 +143,7 @@ class ObjectOp(PathOp.ObjectOp):
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):

View File

@@ -759,7 +759,13 @@ class ObjectTagDressup:
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

View File

@@ -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')
@@ -80,6 +81,7 @@ class TaskPanelOpPage(PathCircularHoleBaseGui.TaskPanelOpPage):
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()

View File

@@ -131,7 +131,7 @@ class ObjectFace(PathPocketBase.ObjectPocket):
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:

View File

@@ -311,6 +311,7 @@ class AttributePrototype(PathSetupSheetOpPrototype.OpPrototype):
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']

View File

@@ -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
@@ -122,6 +119,7 @@ class ToolBitEditor(object):
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)
@@ -138,11 +136,10 @@ class ToolBitEditor(object):
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()
@@ -161,6 +158,7 @@ class ToolBitEditor(object):
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())

View File

@@ -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
@@ -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
@@ -84,10 +83,10 @@ class ViewProvider(object):
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()
@@ -101,7 +100,7 @@ class ViewProvider(object):
def unsetEdit(self, vobj, mode):
# pylint: disable=unused-argument
FreeCADGui.Control.closeDialog()
self.taskPanel = None
self.panel = None
return
def claimChildren(self):
@@ -143,9 +142,6 @@ class TaskPanel:
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.recompute()
def getFields(self):
self.editor.getFields()
def updateUI(self):
self.editor.updateUI()
@@ -153,9 +149,6 @@ class TaskPanel:
self.editor.updateTool()
FreeCAD.ActiveDocument.recompute()
def setFields(self):
self.editor.setFields()
def setupUi(self):
self.editor.setupUI()
@@ -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()

View File

@@ -32,7 +32,7 @@ import PySide
import json
import os
import traceback
import uuid
import uuid as UUID
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
@@ -70,7 +70,6 @@ class _TableView(PySide.QtGui.QTableView):
def _copyTool(self, uuid_, dstRow):
model = self.model()
items = []
model.insertRow(dstRow)
srcRow = self._rowWithUuid(uuid_)
for col in range(model.columnCount()):
@@ -81,7 +80,7 @@ class _TableView(PySide.QtGui.QTableView):
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)
@@ -96,6 +95,7 @@ class _TableView(PySide.QtGui.QTableView):
stream = PySide.QtCore.QDataStream(data)
srcRows = []
while not stream.atEnd():
# pylint: disable=unused-variable
row = stream.readInt32()
srcRows.append(row)
col = stream.readInt32()
@@ -141,7 +141,7 @@ class ToolBitLibrary(object):
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)
@@ -159,6 +159,7 @@ class ToolBitLibrary(object):
def toolAdd(self):
PathLog.track()
# pylint: disable=broad-except
try:
nr = 0
for row in range(self.model.rowCount()):
@@ -170,7 +171,7 @@ class ToolBitLibrary(object):
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())
@@ -198,6 +199,7 @@ class ToolBitLibrary(object):
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):

View File

@@ -82,6 +82,7 @@ class ToolController:
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)
@@ -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)

View File

@@ -28,7 +28,6 @@ import Part
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

View File

@@ -36,6 +36,7 @@ PathLog.trackModule(PathLog.thisModule())
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])

View File

@@ -29,16 +29,16 @@ import PathTests.PathTestUtils as PathTestUtils
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')

View File

@@ -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'