1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-06-13 19:21:37 +03:00

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
This commit is contained in:
Daniel Veillard
2002-09-12 15:00:57 +00:00
parent 353bf5822a
commit c6d4a933f0
14 changed files with 677 additions and 12 deletions

View File

@ -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
#