Skip to content

Commit

Permalink
Addressed pylint warnings for PathPost
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert committed Jul 1, 2019
1 parent b552853 commit f16703e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
17 changes: 10 additions & 7 deletions src/Mod/Path/PathScripts/PathPost.py
Expand Up @@ -50,15 +50,17 @@ def translate(context, text, disambig=None):


class _TempObject:
Path = None
Name = "Fixture"
InList = []
Label = "Fixture"
# pylint: disable=no-init
Path = None
Name = "Fixture"
InList = []
Label = "Fixture"


class DlgSelectPostProcessor:

def __init__(self, parent=None):
# pylint: disable=unused-argument
self.dialog = FreeCADGui.PySideUic.loadUi(":/panels/DlgSelectPostProcessor.ui")
firstItem = None
for post in PathPreferences.allEnabledPostProcessors():
Expand Down Expand Up @@ -93,6 +95,7 @@ def exec_(self):


class CommandPathPost:
# pylint: disable=no-init
subpart = 1

def resolveFileName(self, job):
Expand Down Expand Up @@ -188,7 +191,7 @@ def IsActive(self):

return False

def exportObjectsWith(self, objs, job, needFilename=True, filepart=None):
def exportObjectsWith(self, objs, job, needFilename=True):
PathLog.track()
# check if the user has a project and has set the default post and
# output filename
Expand Down Expand Up @@ -234,7 +237,7 @@ def Activated(self):
elif hasattr(sel, "Path"):
try:
job = PathUtils.findParentJob(sel)
except Exception:
except Exception: # pylint: disable=broad-except
job = None
else:
job = None
Expand Down Expand Up @@ -378,7 +381,7 @@ def Activated(self):
postlist.append(sublist)

fail = True
rc = ''
rc = '' # pylint: disable=unused-variable
if split:
for slist in postlist:
(fail, rc) = self.exportObjectsWith(slist, job)
Expand Down
21 changes: 10 additions & 11 deletions src/Mod/Path/PathScripts/PathPostProcessor.py
Expand Up @@ -22,7 +22,6 @@
# * *
# ***************************************************************************

import FreeCAD
import PathScripts.PathLog as PathLog
import PathScripts.PathPreferences as PathPreferences
import sys
Expand All @@ -47,7 +46,7 @@ def load(cls, processor):
namespace = {}

#can't modify function local scope with exec in python3
exec("import %s as current_post" % postname, namespace)
exec("import %s as current_post" % postname, namespace) # pylint: disable=exec-used
current_post = namespace['current_post']

# make sure the script is reloaded if it was previously loaded
Expand All @@ -56,40 +55,34 @@ def load(cls, processor):
# resulting in 2 load messages if the script outputs one of those.
try:
# Python 2.7
exec("reload(%s)" % 'current_post')
exec("reload(%s)" % 'current_post') # pylint: disable=exec-used
except NameError:
# Python 3.4+
from importlib import reload
exec("reload(%s)" % 'current_post')
from importlib import reload # pylint: disable=redefined-builtin,unused-variable
exec("reload(%s)" % 'current_post') # pylint: disable=exec-used

sys.path = syspath

instance = PostProcessor(current_post)
instance.units = None
if hasattr(current_post, "UNITS"):
if current_post.UNITS == "G21":
instance.units = "Metric"
else:
instance.units = "Inch"

instance.machineName = None
if hasattr(current_post, "MACHINE_NAME"):
instance.machineName = current_post.MACHINE_NAME

instance.cornerMax = None
if hasattr(current_post, "CORNER_MAX"):
instance.cornerMax = {'x': current_post.CORNER_MAX['x'],
'y': current_post.CORNER_MAX['y'],
'z': current_post.CORNER_MAX['z']}

instance.cornerMin = None
if hasattr(current_post, "CORNER_MIN"):
instance.cornerMin = {'x': current_post.CORNER_MIN['x'],
'y': current_post.CORNER_MIN['y'],
'z': current_post.CORNER_MIN['z']}

instance.tooltip = None
instance.tooltipArgs = None
if hasattr(current_post, "TOOLTIP"):
instance.tooltip = current_post.TOOLTIP
if hasattr(current_post, "TOOLTIP_ARGS"):
Expand All @@ -98,6 +91,12 @@ def load(cls, processor):

def __init__(self, script):
self.script = script
self.tooltip = None
self.tooltipArgs = None
self.cornerMax = None
self.cornerMin = None
self.units = None
self.machineName = None

def export(self, obj, filename, args):
return self.script.export(obj, filename, args)
4 changes: 2 additions & 2 deletions src/Mod/Path/PathScripts/PostUtils.py
Expand Up @@ -52,12 +52,12 @@ def __init__(self, parent=None):
self.highlightingRules.append((QtCore.QRegExp("\\bF[0-9\\.]+\\b"),speedFormat))

def highlightBlock(self, text):
for pattern, format in self.highlightingRules:
for pattern, hlFormat in self.highlightingRules:
expression = QtCore.QRegExp(pattern)
index = expression.indexIn(text)
while index >= 0:
length = expression.matchedLength()
self.setFormat(index, length, format)
self.setFormat(index, length, hlFormat)
index = expression.indexIn(text, index + length)


Expand Down

0 comments on commit f16703e

Please sign in to comment.