diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2003-12-04 14:12:05 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2003-12-04 14:12:05 +0000 |
commit | 85bb5b08df98f19dfb4b23a5ee0b3596a0d8326b (patch) | |
tree | de9e7a0d09299169c8e5a95f0511c5ebb5e04194 /python/libxml.py | |
parent | 6cbd6c0738efb6c55d08f39c0731d46d678858fa (diff) | |
download | libxml2-85bb5b08df98f19dfb4b23a5ee0b3596a0d8326b.tar.gz |
oops forgot to modify/commit the new code. Daniel
* python/libxml.py: oops forgot to modify/commit the new code.
Daniel
Diffstat (limited to 'python/libxml.py')
-rw-r--r-- | python/libxml.py | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/python/libxml.py b/python/libxml.py index 16c24884..41103c66 100644 --- a/python/libxml.py +++ b/python/libxml.py @@ -1,4 +1,5 @@ import libxml2mod +import types # # Errors raised by the wrappers when some tree handling failed. @@ -79,18 +80,37 @@ class ioReadWrapper(ioWrapper): class ioWriteWrapper(ioWrapper): def __init__(self, _obj, enc = ""): - ioWrapper.__init__(self, _obj) - self._o = libxml2mod.xmlCreateOutputBuffer(self, enc) +# print "ioWriteWrapper.__init__", _obj + if type(_obj) == type(''): + print "write io from a string" + self.o = None + elif type(_obj) == types.InstanceType: + print "write io from instance of %s" % (_obj.__class__) + ioWrapper.__init__(self, _obj) + self._o = libxml2mod.xmlCreateOutputBuffer(self, enc) + else: + file = libxml2mod.outputBufferGetPythonFile(_obj) + if file != None: + ioWrapper.__init__(self, file) + else: + ioWrapper.__init__(self, _obj) + self._o = _obj def __del__(self): - print "__del__" +# print "__del__" self.io_close() if self._o != None: libxml2mod.xmlOutputBufferClose(self._o) self._o = None + def flush(self): + self.io_flush() + if self._o != None: + libxml2mod.xmlOutputBufferClose(self._o) + self._o = None + def close(self): - self.io_close() + self.io_flush() if self._o != None: libxml2mod.xmlOutputBufferClose(self._o) self._o = None |