Subsections


state.save

Image relax Image document-save

Synopsis

Save the program state.

Defaults

state.save(state=`state.bz2', dir=None, compress_type=1, force=False)

Keyword arguments

state: The file name, which can be a string or a file descriptor object, to save the current program state in.

dir: The name of the directory in which to place the file.

compress_type: The type of compression to use when creating the file.

force: A boolean flag which if set to True will cause the file to be overwritten.

Description

This will place the program state - the relax data store - into a file for later reloading or reference. The default format is an XML formatted file.

The default behaviour of this function is to compress the file using bzip2 compression. If the extension `.bz2' is not included in the file name, it will be added. The compression can, however, be changed to either no compression or gzip compression. This is controlled by the compression type which can be set to

0 -
No compression (no file extension).
1 -
bzip2 compression (`.bz2' file extension).
2 -
gzip compression (`.gz' file extension).

Prompt examples

The following commands will save the current program state, uncompressed, into the file `save':

[numbers=none]
relax> state.save('save', compress_type=0)

[numbers=none]
relax> state.save(state='save', compress_type=0)

The following commands will save the current program state into the bzip2 compressed file `save.bz2':

[numbers=none]
relax> state.save('save')

[numbers=none]
relax> state.save(state='save')

[numbers=none]
relax> state.save('save.bz2')

[numbers=none]
relax> state.save(state='save.bz2')

If the file `save' already exists, the following commands will save the current program state by overwriting the file.

[numbers=none]
relax> state.save('save', force=True)

[numbers=none]
relax> state.save(state='save', force=True)


The relax user manual (PDF), created 2020-08-26.