Package pipe_control :: Module result_files
[hide private]
[frames] | no frames]

Source Code for Module pipe_control.result_files

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2012 Edward d'Auvergne                                        # 
 4  #                                                                             # 
 5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
 6  #                                                                             # 
 7  # This program 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 3 of the License, or           # 
10  # (at your option) any later version.                                         # 
11  #                                                                             # 
12  # This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.       # 
19  #                                                                             # 
20  ############################################################################### 
21   
22  # Module docstring. 
23  """Module for handling result files.""" 
24   
25  # relax module imports. 
26  from status import Status; status = Status() 
27   
28   
29 -def add_result_file(type=None, label=None, file=None):
30 """Add a results file to the current data pipe. 31 32 @keyword type: The mimetype of the result file, for example 'text', 'grace', 'molmol' or 'pymol'. 33 @type type: str 34 @keyword label: The label to attach to the file. For example a BMRB file can have the label 'BMRB' and type 'text'. 35 @type label: str 36 @keyword file: The path of the file. 37 @type file: str 38 """ 39 40 # First check if the structure exists, creating it if needed. 41 if not hasattr(cdp, 'result_files'): 42 cdp.result_files = [] 43 44 # Check if the file already exists. 45 for i in range(len(cdp.result_files)): 46 if cdp.result_files[i][2] == file: 47 # Overwrite the settings. 48 cdp.result_files[i][0] = type 49 cdp.result_files[i][1] = label 50 51 # Nothing left to do. 52 return True 53 54 # Add the file. 55 cdp.result_files.append([type, label, file]) 56 57 # Notify all observers. 58 status.observers.result_file.notify()
59