Author: bugman Date: Sat Jun 28 17:43:49 2008 New Revision: 6509 URL: http://svn.gna.org/viewcvs/relax?rev=6509&view=rev Log: Modified results.write() to allow any object with a write() method to be used as the output file. Modified: 1.3/prompt/results.py Modified: 1.3/prompt/results.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/results.py?rev=6509&r1=6508&r2=6509&view=diff ============================================================================== --- 1.3/prompt/results.py (original) +++ 1.3/prompt/results.py Sat Jun 28 17:43:49 2008 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2003-2005 Edward d'Auvergne # +# Copyright (C) 2003-2005,2008 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -26,7 +26,7 @@ # relax module imports. import help from generic_fns import results -from relax_errors import RelaxBoolError, RelaxIntError, RelaxNoneStrError, RelaxStrError +from relax_errors import RelaxBoolError, RelaxIntError, RelaxNoneStrError, RelaxStrError, RelaxStrFileError class Results: @@ -108,7 +108,8 @@ Keyword Arguments ~~~~~~~~~~~~~~~~~ - file: The name of the file to output results to. The default is 'results'. + file: The name of the file to output results to. The default is 'results'. Optionally + this can be a file object, or any object with a write() method. dir: The directory name. @@ -149,8 +150,8 @@ print text # File. - if type(file) != str: - raise RelaxStrError, ('file name', file) + if type(file) != str and not hasattr(file, 'write'): + raise RelaxStrFileError, ('file name', file) # Directory. if dir != None and type(dir) != str: