fixed pylint warning for PathJob

This commit is contained in:
Markus Lampert
2019-06-23 18:18:45 -07:00
parent 23efe695ae
commit f4bee893d7
3 changed files with 24 additions and 6 deletions

View File

@@ -45,13 +45,13 @@ if LOGLEVEL:
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
"""Path Job object and FreeCAD command"""
# Qt translation handling
def translate(context, text, disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class JobTemplate:
# pylint: disable=no-init
'''Attribute and sub element strings for template export/import.'''
Description = 'Desc'
GeometryTolerance = 'Tolerance'
@@ -68,6 +68,7 @@ def isArchPanelSheet(obj):
return hasattr(obj, 'Proxy') and isinstance(obj.Proxy, ArchPanel.PanelSheet)
def isResourceClone(obj, propLink, resourceName):
# pylint: disable=unused-argument
if hasattr(propLink, 'PathResource') and (resourceName is None or resourceName == propLink.PathResource):
return True
return False
@@ -135,6 +136,9 @@ class ObjectJob:
self.setupSetupSheet(obj)
self.setupBaseModel(obj, models)
self.tooltip = None
self.tooltipArgs = None
obj.Proxy = self
self.setFromTemplateFile(obj, templateFile)
@@ -229,7 +233,7 @@ class ObjectJob:
if obj.Operations.ViewObject:
try:
obj.Operations.ViewObject.DisplayMode
except Exception:
except Exception: # pylint: disable=broad-except
name = obj.Operations.Name
label = obj.Operations.Label
ops = FreeCAD.ActiveDocument.addObject("Path::FeatureCompoundPython", "Operations")
@@ -345,7 +349,7 @@ class ObjectJob:
if before:
try:
group.insert(group.index(before), op)
except Exception as e:
except Exception as e: # pylint: disable=broad-except
PathLog.error(e)
group.append(op)
else:
@@ -388,7 +392,7 @@ class ObjectJob:
@classmethod
def baseCandidates(cls):
'''Answer all objects in the current document which could serve as a Base for a job.'''
return sorted(filter(lambda obj: cls.isBaseCandidate(obj) , FreeCAD.ActiveDocument.Objects), key=lambda o: o.Label)
return sorted([obj for obj in FreeCAD.ActiveDocuemnt.Objects if cls.isBaseCandidate(obj)], key=lambda o: o.Label)
@classmethod
def isBaseCandidate(cls, obj):

View File

@@ -53,6 +53,9 @@ class CommandJobCreate:
and a template to be used for the initial creation.
'''
def __init__(self):
pass
def GetResources(self):
return {'Pixmap': 'Path-Job',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Path_Job", "Job"),
@@ -90,6 +93,10 @@ class CommandJobTemplateExport:
on Job creation and be available for selection.
'''
def __init__(self):
pass
def GetResources(self):
return {'Pixmap': 'Path-ExportTemplate',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Path_Job", "Export Template"),

View File

@@ -53,6 +53,7 @@ class _ItemDelegate(QtGui.QStyledItemDelegate):
QtGui.QStyledItemDelegate.__init__(self, parent)
def createEditor(self, parent, option, index):
# pylint: disable=unused-argument
editor = QtGui.QSpinBox(parent)
self.controller.setupColumnEditor(index, editor)
return editor
@@ -61,12 +62,18 @@ class JobCreate:
DataObject = QtCore.Qt.ItemDataRole.UserRole
def __init__(self, parent=None, sel=None):
# pylint: disable=unused-argument
self.dialog = FreeCADGui.PySideUic.loadUi(":/panels/DlgJobCreate.ui")
self.itemsSolid = QtGui.QStandardItem(translate('PathJob', 'Solids'))
self.items2D = QtGui.QStandardItem(translate('PathJob', '2D'))
self.itemsJob = QtGui.QStandardItem(translate('PathJob', 'Jobs'))
self.dialog.templateGroup.hide()
self.dialog.modelGroup.hide()
# debugging support
self.candidates = None
self.delegate = None
self.index = None
self.model = None
def setupTitle(self, title):
self.dialog.setWindowTitle(title)
@@ -90,7 +97,7 @@ class JobCreate:
expand2Ds = False
expandJobs = False
for i, base in enumerate(self.candidates):
for base in self.candidates:
if not base in jobResources and not PathJob.isResourceClone(job, base, None) and not hasattr(base, 'StockType'):
item0 = QtGui.QStandardItem()
item1 = QtGui.QStandardItem()
@@ -244,7 +251,7 @@ class JobCreate:
models = []
for i in range(self.itemsSolid.rowCount()):
for j in range(self.itemsSolid.child(i, 1).data(QtCore.Qt.EditRole)):
for j in range(self.itemsSolid.child(i, 1).data(QtCore.Qt.EditRole)): # pylint: disable=unused-variable
models.append(self.itemsSolid.child(i).data(self.DataObject))
for i in range(self.items2D.rowCount()):