save(self,
state=None,
dir=None,
compress_type=1,
force=False,
pickle=False)
| source code
|
Function for saving the program state.
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.
pickle: A flag which if true will cause the state file to be a pickled object rather than
the default XML format.
Description
~~~~~~~~~~~
This user function 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, but this can be
changed to a Python pickled object through the pickle flag. Note, the pickle format is not
human readable and often is not compatible with newer relax versions.
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 compress_type argument which can be set to
0: No compression (no file extension).
1: bzip2 compression ('.bz2' file extension).
2: gzip compression ('.gz' file extension).
Examples
~~~~~~~~
The following commands will save the current program state, uncompressed, into the file 'save':
relax> state.save('save', compress_type=0)
relax> state.save(state='save', compress_type=0)
The following commands will save the current program state into the bzip2 compressed file
'save.bz2':
relax> state.save('save')
relax> state.save(state='save')
relax> state.save('save.bz2')
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.
relax> state.save('save', force=True)
relax> state.save(state='save', force=True)
|