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: DumpFileReader

Backend for reading ICAT data from a XML file.

Parameters:
  • client (icat.client.Client) – a client object configured to connect to the ICAT server that the objects in the data file belong to.

  • infile – the data source to read the objects from. This backend accepts a file object, a file name, 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: DumpFileWriter

Backend for writing ICAT data to a XML file.

Parameters:
  • client (icat.client.Client) – a client object configured to connect to the ICAT server to search the data objects from.

  • outfile – the data file to write the objects to. This backend accepts a file object or a file name.

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.