icat.dumpfile_xml — XML data file backend

This module provides the XML backend for icat.dumpfile. See the documentation of that module on how to read and write ICAT data files.

class icat.dumpfile_xml.XMLDumpFileReader(client, infile)

Bases: icat.dumpfile.DumpFileReader

Backend for reading ICAT data from a XML file.

This backend accepts a file object, a filename, or a XML tree object (lxml.etree._ElementTree) as input. Note that the latter case requires by definition the complete input to be at once in memory. This is only useful if the input is small enough.

mode = 'rb'

File mode suitable for this backend.

getdata_file()

Iterate over the chunks in the data file.

getdata_etree()

Iterate over the chunks from a XML tree object.

getobjs_from_data(data, objindex)

Iterate over the objects in a data chunk.

Yield a new entity object in each iteration. The object is initialized from the data, but not yet created at the client.

class icat.dumpfile_xml.XMLDumpFileWriter(client, outfile)

Bases: icat.dumpfile.DumpFileWriter

Backend for writing ICAT data to a XML file.

mode = 'wb'

File mode suitable for this backend.

head()

Write a header with some meta information to the data file.

startdata()

Start a new data chunk.

If the current chunk contains any data, write it to the data file.

writeobj(key, obj, keyindex)

Add an entity object to the current data chunk.

finalize()

Finalize the data file.