summaryrefslogtreecommitdiff
path: root/python/libxml.py
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2002-09-12 15:00:57 +0000
committerDaniel Veillard <veillard@src.gnome.org>2002-09-12 15:00:57 +0000
commitc6d4a933f017b17cacdf2a6f6505faf8d945b0b3 (patch)
treef098eca367b8e677dc3db552f0dc3a33c215e583 /python/libxml.py
parent353bf5822aa44f2335d839e8b6cbbf80cdab1ca8 (diff)
downloadlibxml2-c6d4a933f017b17cacdf2a6f6505faf8d945b0b3.tar.gz
updated the python bindings, added code for easier File I/O, and the
* python/generator.py python/libxml.c python/libxml.py python/libxml2-python-api.xml python/libxml2class.txt python/libxml_wrap.h python/types.c: updated the python bindings, added code for easier File I/O, and the ability to define a resolver from Python fixing bug #91635 * python/tests/Makefile.am python/tests/inbuf.py python/tests/outbuf.py python/tests/pushSAXhtml.py python/tests/resolver.py python/tests/serialize.py: updated and augmented the set of Python tests. Daniel
Diffstat (limited to 'python/libxml.py')
-rw-r--r--python/libxml.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/python/libxml.py b/python/libxml.py
index dd8cf770..73c54a6f 100644
--- a/python/libxml.py
+++ b/python/libxml.py
@@ -27,6 +27,74 @@ class xpathError:
def __str__(self):
return self.msg
+class ioWrapper:
+ def __init__(self, _obj):
+ self.__io = _obj
+ self._o = None
+
+ def io_close(self):
+ if self.__io == None:
+ return(-1)
+ self.__io.close()
+ self.__io = None
+ return(0)
+
+ def io_flush(self):
+ if self.__io == None:
+ return(-1)
+ self.__io.flush()
+ return(0)
+
+ def io_read(self, len = -1):
+ if self.__io == None:
+ return(-1)
+ if len < 0:
+ return(self.__io.read())
+ return(self.__io.read(len))
+
+ def io_write(self, str, len = -1):
+ if self.__io == None:
+ return(-1)
+ if len < 0:
+ return(self.__io.write(str))
+ return(self.__io.write(str, len))
+
+class ioReadWrapper(ioWrapper):
+ def __init__(self, _obj, enc = ""):
+ ioWrapper.__init__(self, _obj)
+ self._o = libxml2mod.xmlCreateInputBuffer(self, enc)
+
+ def __del__(self):
+ print "__del__"
+ self.io_close()
+ if self._o != None:
+ libxml2mod.xmlFreeParserInputBuffer(self._o)
+ self._o = None
+
+ def close(self):
+ self.io_close()
+ if self._o != None:
+ libxml2mod.xmlFreeParserInputBuffer(self._o)
+ self._o = None
+
+class ioWriteWrapper(ioWrapper):
+ def __init__(self, _obj, enc = ""):
+ ioWrapper.__init__(self, _obj)
+ self._o = libxml2mod.xmlCreateOutputBuffer(self, enc)
+
+ def __del__(self):
+ print "__del__"
+ self.io_close()
+ if self._o != None:
+ libxml2mod.xmlOutputBufferClose(self._o)
+ self._o = None
+
+ def close(self):
+ self.io_close()
+ if self._o != None:
+ libxml2mod.xmlOutputBufferClose(self._o)
+ self._o = None
+
#
# Example of a class to handle SAX events
#