XMLStorageManager

class XMLStorageManager(*args)

Storage manager that drives a XML file.

Available constructors:

XMLStorageManager(filename)

XMLStorageManager(filename, compressionLevel)

Parameters
fileNamestr

Name of the file containing the study.

compressionLevelint

Compression level of the resulting XML file, in the range 0,…,9 (0=no compression, 9=best compression). The compression is done only if the XML lib has been compiled with zlib support. The default value is given by ‘XMLStorageManager-DefaultCompressionLevel’ in ResourceMap.

See also

StorageManager

Notes

XMLStorageManager enables to read and write OPENTURNS’ objects from a XML file.

Examples

>>> import openturns as ot
>>> # Create a study:
>>> myStudy = ot.Study()
>>> myStudy.setStorageManager(ot.XMLStorageManager('myStudy.xml'))  
>>> myStudy2 = ot.Study()  
>>> myStudy2.setStorageManager(ot.XMLStorageManager('myStudy2.xml.gz', 5))  
>>> # Add an object in the study:
>>> simulationResult = ot.ProbabilitySimulationResult(ot.ThresholdEvent(), 0.5, 0.01, 150, 4)  
>>> myStudy.add('simulationResult', simulationResult)  
>>> # Save the Study in the file myStudy.xml:
>>> myStudy.save()  

Methods

finalize(self, \*args)

Do some administrative tasks after saving/reloading.

getClassName(self)

Accessor to the object’s name.

getDefaultStudyVersion(self)

Return the version of the study that the manager can read/write.

getFileName(self)

Get the name of the file containing the study.

getStudy(self)

Get the study bound to the manager.

getStudyVersion(self)

Get the study version.

initialize(self, \*args)

Do some administrative tasks before saving/reloading.

isSavedObject(self, id)

Tell if an object is already saved.

load(self, study)

Reload the whole study from the medium.

markObjectAsSaved(self, id)

Tell that an object is saved.

read(self)

Read and create the internal representation.

save(self, obj, label[, fromStudy])

Save the object onto the medium.

setFileName(self, fileName)

Set the name of the file containing the study.

setStudy(self, p_study)

Set the study bound to the manager.

setStudyVersion(self, version)

Set the study version.

write(self)

Write the internal representation.

__init__(self, \*args)

Initialize self. See help(type(self)) for accurate signature.

finalize(self, \*args)

Do some administrative tasks after saving/reloading.

Available usages

finalize(ot.SaveAction())

finalize(ot.LoadAction())

getClassName(self)

Accessor to the object’s name.

Returns
class_namestr

The object class name (object.__class__.__name__).

getDefaultStudyVersion(self)

Return the version of the study that the manager can read/write.

Returns
versionpositive int

Version of the study that the manager can read/write.

getFileName(self)

Get the name of the file containing the study.

Returns
fileNamestr

Name of the file containing the study.

getStudy(self)

Get the study bound to the manager.

Returns
studyStudy

Study bound to the manager.

getStudyVersion(self)

Get the study version.

Returns
versionpositive int

Study version.

initialize(self, \*args)

Do some administrative tasks before saving/reloading.

Available usages

initialize(ot.SaveAction())

initialize(ot.LoadAction())

isSavedObject(self, id)

Tell if an object is already saved.

Returns
isSavedbool

True if an object is already saved.

load(self, study)

Reload the whole study from the medium.

Parameters
studyStudy

The study to reload objects from.

markObjectAsSaved(self, id)

Tell that an object is saved.

Parameters
Idint

Internal identifier of the object.

read(self)

Read and create the internal representation.

save(self, obj, label, fromStudy=False)

Save the object onto the medium.

Parameters
objectPersistentObject

Object to be saved.

labelstr

Name associate with the object to be saved.

fromStudybool, optional

Flag telling if the object was explicitely put in the study or not. By default, it is equal to False.

setFileName(self, fileName)

Set the name of the file containing the study.

Parameters
fileNamestr

Name of the file containing the study.

setStudy(self, p_study)

Set the study bound to the manager.

Parameters
studyStudy

Study bound to the manager.

setStudyVersion(self, version)

Set the study version.

Parameters
versionpositive int

Study version.

write(self)

Write the internal representation.