From cb35d9b96ebb1a61db1ce5356af9b13e0ef75998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Thu, 10 Nov 2005 12:20:07 +0000 Subject: [PATCH] * by default erase the doc, with keepDoc argument you can keep self.doc * try to make sure self.doc is deleted after self.unlink() --- pisi/xml/autoxml.py | 8 ++++---- pisi/xml/xmlfilemdom.py | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pisi/xml/autoxml.py b/pisi/xml/autoxml.py index 0eac3642..034fb5b4 100644 --- a/pisi/xml/autoxml.py +++ b/pisi/xml/autoxml.py @@ -378,7 +378,7 @@ class autoxml(oo.autosuper, oo.autoprop): cls.__ne__ = notequal if xmlfile_support: - def read(self, filename, eraseDoc = False): + def read(self, filename, keepDoc = False): "read XML file and decode it into a python object" self.readxml(filename) errs = [] @@ -389,7 +389,7 @@ class autoxml(oo.autosuper, oo.autoprop): errs.append(_("autoxml.read: File '%s' has errors") % filename) raise Error(*errs) - if eraseDoc: + if not keepDoc: self.unlink() # get rid of the tree errs = self.errors() @@ -397,7 +397,7 @@ class autoxml(oo.autosuper, oo.autoprop): errs.append(_("autoxml.read: File '%s' has errors") % filename) raise Error(*errs) - def write(self, filename, eraseDoc = False): + def write(self, filename, keepDoc = False): "encode the contents of the python object into an XML file" errs = self.errors() if errs: @@ -412,7 +412,7 @@ class autoxml(oo.autosuper, oo.autoprop): errs.append(_("autoxml.write: File encoding '%s' has errors") % filename) raise Error(*errs) self.writexml(filename) - if eraseDoc: + if not keepDoc: self.unlink() # get rid of the tree cls.read = read diff --git a/pisi/xml/xmlfilemdom.py b/pisi/xml/xmlfilemdom.py index 5e873b9f..6e4e7fb5 100644 --- a/pisi/xml/xmlfilemdom.py +++ b/pisi/xml/xmlfilemdom.py @@ -53,6 +53,7 @@ class XmlFile(object): def unlink(self): """deallocate DOM structure""" self.doc.unlink() + del self.doc def rootNode(self): """returns root document element"""