write_fileobj

igwn_ligolw.utils.write_fileobj(xmldoc, fileobj, compress=None, compresslevel=3, **kwargs)

Writes the LIGO Light Weight document tree rooted at xmldoc to the given file object. Internally, the .write() method of the xmldoc object is invoked and any additional keyword arguments are passed to that method. The file object need not be seekable. The file object must be in binary mode.

The compress parameter selects the file compression format to use. Valid values are: False to disable compression; one of “bz2”, “gz”, or “xz” to select bzip2, gzip, or lzma compression, respectively; or None to select the default behaviour (which is to disable compression). When bzip2 or gzip compression is selected, the compresslevel parameter sets the compression level (the default is 3).

Example:

>>> xmldoc = load_filename("test/demo.xml")
>>> write_fileobj(xmldoc, open("/dev/null","wb"))