Package prompt :: Module state :: Class State
[hide private]
[frames] | no frames]

Class State

source code

Instance Methods [hide private]
 
__init__(self, relax) source code
 
load(self, file=None, dir=None)
Function for loading a saved program state.
source code
 
save(self, file=None, dir=None, force=0, compress_type=1)
Function for saving the program state.
source code
Method Details [hide private]

load(self, file=None, dir=None)

source code 
Function for loading a saved program state.

Keyword Arguments
~~~~~~~~~~~~~~~~~

file:  The file name, which must be a string, of a saved program state.

dir:  Directory which the file is found in.


Description
~~~~~~~~~~~

This function is able to handle uncompressed, bzip2 compressed files, or gzip compressed
files automatically.  The full file name including extension can be supplied, however, if
the file cannot be found, this function will search for the file name with '.bz2' appended
followed by the file name with '.gz' appended.


Examples
~~~~~~~~

The following commands will load the state saved in the file 'save'.

relax> state.load('save')
relax> state.load(file='save')


The following commands will load the state saved in the bzip2 compressed file 'save.bz2'.

relax> state.load('save')
relax> state.load(file='save')
relax> state.load('save.bz2')
relax> state.load(file='save.bz2')

save(self, file=None, dir=None, force=0, compress_type=1)

source code 
Function for saving the program state.

Keyword Arguments
~~~~~~~~~~~~~~~~~

file:  The file name, which must be a string, to save the current program state in.

dir:  The directory to place the file in.

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


Description
~~~~~~~~~~~

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 into the file 'save':

relax> state.save('save', compress_type=0)
relax> state.save(file='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(file='save')
relax> state.save('save.bz2')
relax> state.save(file='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', 1)
relax> state.save(file='save', force=1)