April 12th, 2008 @ 08:24

Ever heard of Gogh? This is a really nice drawing tool for graphic tablets owner (such as those by Wacom). However it stopped working on my Hardy system after some recent update. After some investigation, it appeared that it was due to python-xml being moved away of Python path because it interfered with stuff in Python core ; the whole python-xml package being scheduled for deprecation as soon as the reverse depends would be cleared. I figured it out and dropped the reference to python-xml package in gogh/settingsmanager.py, using a method provided by Python core xml stuff instead. It seems that quite a bunch of people are currently using xml.doc.ext.PrettyPrint from pyxml to output an XML document to a file, so I figured that posting this little tip might help someone :)

So, let’s say you currently have something like this to output your xml document “doc” to a file at path “path”, doc being an xml.dom.minidom.Document object (or similar):

        f = open(path, "w")
        xml.dom.ext.PrettyPrint(doc, f)
        f.close()

All you need to change is PrettyPrint call to make use of the .toxml() method of your document object instead:

        f = open(path, "w")
        f.write(doc.toxml())
        f.close()

Here you go, hope this might save someone’s day someday :)