Removing dependency on lxml - fixed some bugs on deleting a job and all it's sub components.

This commit is contained in:
Markus Lampert
2017-06-20 15:40:39 -07:00
parent e399785a97
commit 6a3a102964
5 changed files with 30 additions and 22 deletions

View File

@@ -1422,7 +1422,10 @@ class ViewProviderDressup:
group.remove(g)
i.Group = group
#print i.Group
FreeCADGui.ActiveDocument.getObject(self.obj.Base.Name).Visibility = False
if self.obj.Base:
obj = FreeCADGui.ActiveDocument.getObject(self.obj.Base.Name)
if obj:
obj.Visibility = False
return [self.obj.Base]
return []
@@ -1457,7 +1460,10 @@ class ViewProviderDressup:
def onDelete(self, arg1=None, arg2=None):
'''this makes sure that the base operation is added back to the project and visible'''
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
if arg1.Object.Base:
obj = FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name)
if obj:
obj.Visibility = True
PathUtils.addToJob(arg1.Object.Base)
return True

View File

@@ -30,7 +30,7 @@ import PathScripts.PathLog as PathLog
import PathScripts.PathToolController as PathToolController
import PathScripts.PathUtil as PathUtil
import glob
import lxml.etree as xml
import xml.etree.ElementTree as xml
import os
import sys
@@ -132,6 +132,7 @@ class ObjectPathJob:
attrs[JobTemplate.GeometryTolerance] = str(obj.GeometryTolerance.Value)
if obj.Description:
attrs[JobTemplate.Description] = obj.Description
return attrs
def __getstate__(self):
return None
@@ -487,7 +488,7 @@ class CommandJobExportTemplate:
if hasattr(obj, 'Tool') and hasattr(obj, 'SpindleDir'):
tc = xml.SubElement(root, JobTemplate.ToolController, obj.Proxy.templateAttrs(obj))
tc.append(xml.fromstring(obj.Tool.Content))
xml.ElementTree(root).write(path, pretty_print=True)
xml.ElementTree(root).write(path)
if FreeCAD.GuiUp:
# register the FreeCAD command

View File

@@ -30,7 +30,7 @@ import Path
import PathScripts
import PathScripts.PathLog as PathLog
import PathUtils
import lxml.etree as xml
import xml.etree.ElementTree as xml
from FreeCAD import Units
from PySide import QtCore, QtGui

View File

@@ -438,9 +438,10 @@ def addToJob(obj, jobname=None):
print(form.cboProject.currentText())
job = [i for i in jobs if i.Name == form.cboProject.currentText()][0]
g = job.Group
g.append(obj)
job.Group = g
if obj:
g = job.Group
g.append(obj)
job.Group = g
return job

View File

@@ -34,24 +34,24 @@ import unittest
def tryLoadingTest(testName):
"Loads and returns testName, or a failing TestCase if unsuccessful."
#try:
return unittest.defaultTestLoader.loadTestsFromName(testName)
try:
return unittest.defaultTestLoader.loadTestsFromName(testName)
#except ImportError as err:
# class LoadFailed(unittest.TestCase):
# def __init__(self, testName):
# # setattr() first, because TestCase ctor checks for methodName.
# setattr(self, "failed_to_load_" + testName, self._runTest)
# super(LoadFailed, self).__init__("failed_to_load_" + testName)
# self.testName = testName
except ImportError:
class LoadFailed(unittest.TestCase):
def __init__(self, testName):
# setattr() first, because TestCase ctor checks for methodName.
setattr(self, "failed_to_load_" + testName, self._runTest)
super(LoadFailed, self).__init__("failed_to_load_" + testName)
self.testName = testName
# def __name__(self):
# return "Loading " + self.testName
def __name__(self):
return "Loading " + self.testName
# def _runTest(self):
# self.fail("Couldn't load " + self.testName)
def _runTest(self):
self.fail("Couldn't load " + self.testName)
# return LoadFailed(testName)
return LoadFailed(testName)
def All():
# Base system tests