Improved handling of comments
This commit is contained in:
sliptonic
2016-07-03 10:27:12 -05:00
committed by Yorik van Havre
parent 14f1f6fed8
commit 7ab026ea5e
8 changed files with 104 additions and 106 deletions

View File

@@ -1,37 +1,37 @@
#***************************************************************************
#* (c) sliptonic (shopinthewoods@gmail.com) 2014 *
#* *
#* This file is part of the FreeCAD CAx development system. *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* FreeCAD is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Lesser General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with FreeCAD; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************/
# ***************************************************************************
# * (c) sliptonic (shopinthewoods@gmail.com) 2014 *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with FreeCAD; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************/
'''
Dumper is an extremely simple postprocessor file for the Path workbench. It is used
Dumper is an extremely simple postprocessor file for the Path workbench. It is used
to dump the command list from one or more Path objects for simple inspection. This post
doesn't do any manipulation of the path and doesn't write anything to disk. It just
shows the dialog so you can see it. Useful for debugging, but not much else.
doesn't do any manipulation of the path and doesn't write anything to disk. It just
shows the dialog so you can see it. Useful for debugging, but not much else.
'''
import datetime
now = datetime.datetime.now()
from PathScripts import PostUtils
now = datetime.datetime.now()
SHOW_EDITOR = True
# to distinguish python built-in open function from the one declared below
@@ -39,7 +39,7 @@ if open.__module__ == '__builtin__':
pythonopen = open
def export(objectslist,filename):
def export(objectslist, filename):
output = '''(This ouput produced with the dump post processor)
(Dump is useful for inspecting the raw commands in your paths)
(but is not useful for driving machines.)
@@ -50,8 +50,8 @@ def export(objectslist,filename):
"called when freecad exports a list of objects"
for obj in objectslist:
if not hasattr(obj,"Path"):
if not hasattr(obj, "Path"):
print "the object " + obj.Name + " is not a path. Please select only path and Compounds."
return
print "postprocessing..."
@@ -70,17 +70,18 @@ def export(objectslist,filename):
print "done postprocessing."
def parse(pathobj):
out = ""
if hasattr(pathobj,"Group"): #We have a compound or project.
out += "(compound: " + pathobj.Label + ")\n"
if hasattr(pathobj, "Group"): # We have a compound or project.
out += "(Group: " + pathobj.Label + ")\n"
for p in pathobj.Group:
out += parse(p)
return out
else: #parsing simple path
return out
else: # parsing simple path
if not hasattr(pathobj,"Path"): #groups might contain non-path things like stock.
if not hasattr(pathobj, "Path"): # groups might contain non-path things like stock.
return out
out += "(Path: " + pathobj.Label + ")\n"
@@ -90,4 +91,3 @@ def parse(pathobj):
return out
print __name__ + " gcode postprocessor loaded."