1.1 --- a/README.txt Sat Sep 10 21:59:28 2005 +0000
1.2 +++ b/README.txt Mon Oct 10 10:30:03 2005 +0000
1.3 @@ -50,6 +50,7 @@
1.4 * Moved libxml2macro script to the tools directory.
1.5 * Added getElementsByTagNameNS.
1.6 * Added HTML parsing support.
1.7 + * Added prettyprinting support.
1.8 * Fixed parseURI.
1.9 * Introduced better testing for Unicode objects, especially since things
1.10 like rdflib like to subclass the unicode type, and it might be more
2.1 --- a/libxml2dom/__init__.py Sat Sep 10 21:59:28 2005 +0000
2.2 +++ b/libxml2dom/__init__.py Mon Oct 10 10:30:03 2005 +0000
2.3 @@ -299,14 +299,14 @@
2.4
2.5 # Convenience methods.
2.6
2.7 - def toString(self, encoding=None):
2.8 - return toString(self, encoding)
2.9 + def toString(self, encoding=None, prettyprint=0):
2.10 + return toString(self, encoding, prettyprint)
2.11
2.12 - def toStream(self, stream, encoding=None):
2.13 - toStream(self, stream, encoding)
2.14 + def toStream(self, stream, encoding=None, prettyprint=0):
2.15 + toStream(self, stream, encoding, prettyprint)
2.16
2.17 - def toFile(self, f, encoding=None):
2.18 - toFile(self, f, encoding)
2.19 + def toFile(self, f, encoding=None, prettyprint=0):
2.20 + toFile(self, f, encoding, prettyprint)
2.21
2.22 # Attribute nodes.
2.23
2.24 @@ -413,35 +413,41 @@
2.25
2.26 return Document(Node_parseURI(uri, html))
2.27
2.28 -def toString(node, encoding=None):
2.29 +def toString(node, encoding=None, prettyprint=0):
2.30
2.31 """
2.32 Return a string containing the serialised form of the given 'node' and its
2.33 children. The optional 'encoding' can be used to override the default
2.34 - character encoding used in the serialisation.
2.35 + character encoding used in the serialisation. The optional 'prettyprint'
2.36 + indicates whether the serialised form is prettyprinted or not (the default
2.37 + setting).
2.38 """
2.39
2.40 - return Node_toString(node.as_native_node(), encoding)
2.41 + return Node_toString(node.as_native_node(), encoding, prettyprint)
2.42
2.43 -def toStream(node, stream, encoding=None):
2.44 +def toStream(node, stream, encoding=None, prettyprint=0):
2.45
2.46 """
2.47 Write the serialised form of the given 'node' and its children to the given
2.48 'stream'. The optional 'encoding' can be used to override the default
2.49 - character encoding used in the serialisation.
2.50 + character encoding used in the serialisation. The optional 'prettyprint'
2.51 + indicates whether the serialised form is prettyprinted or not (the default
2.52 + setting).
2.53 """
2.54
2.55 - Node_toStream(node.as_native_node(), stream, encoding)
2.56 + Node_toStream(node.as_native_node(), stream, encoding, prettyprint)
2.57
2.58 -def toFile(node, filename, encoding=None):
2.59 +def toFile(node, filename, encoding=None, prettyprint=0):
2.60
2.61 """
2.62 Write the serialised form of the given 'node' and its children to a file
2.63 having the given 'filename'. The optional 'encoding' can be used to override
2.64 - the default character encoding used in the serialisation.
2.65 + the default character encoding used in the serialisation. The optional
2.66 + 'prettyprint' indicates whether the serialised form is prettyprinted or not
2.67 + (the default setting).
2.68 """
2.69
2.70 - Node_toFile(node.as_native_node(), filename, encoding)
2.71 + Node_toFile(node.as_native_node(), filename, encoding, prettyprint)
2.72
2.73 def adoptNodes(nodes):
2.74
3.1 --- a/libxml2dom/macrolib/macrolib.py Sat Sep 10 21:59:28 2005 +0000
3.2 +++ b/libxml2dom/macrolib/macrolib.py Mon Oct 10 10:30:03 2005 +0000
3.3 @@ -380,14 +380,14 @@
3.4 else:
3.5 raise NotSupportedError, "parseURI does not yet support HTML"
3.6
3.7 -def toString(node, encoding=None):
3.8 - return libxml2mod.serializeNode(node, encoding, 0)
3.9 +def toString(node, encoding=None, prettyprint=0):
3.10 + return libxml2mod.serializeNode(node, encoding, prettyprint)
3.11
3.12 -def toStream(node, stream, encoding=None):
3.13 - stream.write(toString(node, encoding))
3.14 +def toStream(node, stream, encoding=None, prettyprint=0):
3.15 + stream.write(toString(node, encoding, prettyprint))
3.16
3.17 -def toFile(node, f, encoding=None):
3.18 - libxml2mod.saveNodeTo(node, f, encoding, 0)
3.19 +def toFile(node, f, encoding=None, prettyprint=0):
3.20 + libxml2mod.saveNodeTo(node, f, encoding, prettyprint)
3.21
3.22 # libxml2mod constants.
3.23