Package prompt :: Module results
[hide private]
[frames] | no frames]

Source Code for Module prompt.results

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003-2011 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Module docstring. 
 24  """Module containing the 'results' user function class.""" 
 25  __docformat__ = 'plaintext' 
 26   
 27  # relax module imports. 
 28  from base_class import User_fn_class, _build_doc 
 29  import arg_check 
 30  from generic_fns import results 
 31   
 32   
33 -class Results(User_fn_class):
34 """Class for manipulating results.""" 35
36 - def display(self):
37 # Function intro text. 38 if self._exec_info.intro: 39 text = self._exec_info.ps3 + "results.display()" 40 print(text) 41 42 # Execute the functional code. 43 results.display()
44 45 # The function doc info. 46 display._doc_title = "Display the results." 47 display._doc_title_short = "Results display." 48 display._doc_desc = """ 49 This will print to screen (STDOUT) the results contained within the current data pipe. 50 """ 51 _build_doc(display) 52 53
54 - def read(self, file='results', dir=None):
55 # Function intro text. 56 if self._exec_info.intro: 57 text = self._exec_info.ps3 + "results.read(" 58 text = text + "file=" + repr(file) 59 text = text + ", dir=" + repr(dir) + ")" 60 print(text) 61 62 # The argument checks. 63 arg_check.is_str(file, 'file name') 64 arg_check.is_str(dir, 'directory name', can_be_none=True) 65 66 # Execute the functional code. 67 results.read(file=file, directory=dir)
68 69 # The function doc info. 70 read._doc_title = "Read results from a file." 71 read._doc_title_short = "Results reading." 72 read._doc_args = [ 73 ["file", "The name of the file to read results from."], 74 ["dir", "The directory where the file is located."] 75 ] 76 read._doc_desc = """ 77 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 the file with '.bz2' appended followed by the file name with '.gz' appended will be searched for. 78 """ 79 _build_doc(read) 80 81
82 - def write(self, file='results', dir='pipe_name', compress_type=1, force=False):
83 # Function intro text. 84 if self._exec_info.intro: 85 text = self._exec_info.ps3 + "results.write(" 86 text = text + "file=" + repr(file) 87 text = text + ", dir=" + repr(dir) 88 text = text + ", compress_type=" + repr(compress_type) 89 text = text + ", force=" + repr(force) + ")" 90 print(text) 91 92 # The argument checks. 93 arg_check.is_str_or_inst(file, 'file name') 94 arg_check.is_str(dir, 'directory name', can_be_none=True) 95 arg_check.is_int(compress_type, 'compression type') 96 arg_check.is_bool(force, 'force flag') 97 98 # Execute the functional code. 99 results.write(file=file, directory=dir, force=force, compress_type=compress_type)
100 101 # The function doc info. 102 write._doc_title = "Write the results to a file." 103 write._doc_title_short = "Results writing." 104 write._doc_args = [ 105 ["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."], 106 ["dir", "The directory name."], 107 ["compress_type", "The type of compression to use when creating the file."], 108 ["force", "A flag which if True will cause the results file to be overwritten."] 109 ] 110 write._doc_desc = """ 111 To place the results file in the current working directory in the prompt and scripting modes, set dir to None. If dir is set to the special name 'pipe_name', then the results file will be placed into a directory with the same name as the current data pipe. 112 113 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 114 115 0: No compression (no file extension), 116 1: bzip2 compression ('.bz2' file extension), 117 2: gzip compression ('.gz' file extension). 118 119 The complementary read function will automatically handle the compressed files. 120 """ 121 _build_doc(write)
122