From 4262094bb6de47dc8f54d56f13f4accaa60afa52 Mon Sep 17 00:00:00 2001 From: ml Date: Sun, 23 Oct 2016 11:05:07 -0700 Subject: [PATCH] Consolidated finding post processor scripts into class method. --- src/Mod/Path/PathScripts/PathJob.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathJob.py b/src/Mod/Path/PathScripts/PathJob.py index 6ea5aa99b47e..a24675f9e7aa 100644 --- a/src/Mod/Path/PathScripts/PathJob.py +++ b/src/Mod/Path/PathScripts/PathJob.py @@ -50,7 +50,8 @@ def translate(context, text, disambig=None): class ObjectPathJob: - def __init__(self, obj): + @classmethod + def allPostProcessors(cls): path = FreeCAD.getHomePath() + ("Mod/Path/PathScripts/") posts = glob.glob(path + '/*_post.py') allposts = [ str(os.path.split(os.path.splitext(p)[0])[1][:-5]) for p in posts] @@ -61,14 +62,16 @@ def __init__(self, obj): allposts.extend([ str(os.path.split(os.path.splitext(p)[0])[1][:-5]) for p in posts]) allposts.sort() + return allposts + def __init__(self, obj): # obj.addProperty("App::PropertyFile", "PostProcessor", "CodeOutput", "Select the Post Processor file for this project") obj.addProperty("App::PropertyFile", "OutputFile", "CodeOutput", QtCore.QT_TRANSLATE_NOOP("App::Property","The NC output file for this project")) obj.setEditorMode("OutputFile", 0) # set to default mode obj.addProperty("App::PropertyString", "Description", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","An optional description for this job")) obj.addProperty("App::PropertyEnumeration", "PostProcessor", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Select the Post Processor")) - obj.PostProcessor = allposts + obj.PostProcessor = self.allPostProcessors() obj.PostProcessor = 'dumper' obj.addProperty("App::PropertyString", "PostProcessorArgs", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property", "Arguments for the Post Processor (specific to the script)")) obj.PostProcessorArgs = "" @@ -254,18 +257,8 @@ class TaskPanel: def __init__(self): self.form = FreeCADGui.PySideUic.loadUi(":/panels/JobEdit.ui") #self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/JobEdit.ui") - path = FreeCAD.getHomePath() + ("Mod/Path/PathScripts/") - posts = glob.glob(path + '/*_post.py') - allposts = [ str(os.path.split(os.path.splitext(p)[0])[1][:-5]) for p in posts] - - grp = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro") - path = grp.GetString("MacroPath", FreeCAD.getUserAppDataDir()) - posts = glob.glob(path + '/*_post.py') - - allposts.extend([ str(os.path.split(os.path.splitext(p)[0])[1][:-5]) for p in posts]) - allposts.sort() - for post in allposts: + for post in ObjectPathJob.allPostProcessors(): self.form.cboPostProcessor.addItem(post) self.updating = False