Trees | Indices | Help |
|
---|
|
1 from __future__ import absolute_import 2 ############################################################################### 3 # # 4 # Copyright (C) 2003-2013 Edward d'Auvergne # 5 # Copyright (C) 2014 Troels E. Linnet # 6 # # 7 # This file is part of the program relax (http://www.nmr-relax.com). # 8 # # 9 # This program is free software: you can redistribute it and/or modify # 10 # it under the terms of the GNU General Public License as published by # 11 # the Free Software Foundation, either version 3 of the License, or # 12 # (at your option) any later version. # 13 # # 14 # This program is distributed in the hope that it will be useful, # 15 # but WITHOUT ANY WARRANTY; without even the implied warranty of # 16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 17 # GNU General Public License for more details. # 18 # # 19 # You should have received a copy of the GNU General Public License # 20 # along with this program. If not, see <http://www.gnu.org/licenses/>. # 21 # # 22 ############################################################################### 23 24 # Module docstring. 25 """Module containing all of the RelaxWarning objects.""" 26 27 # Python module imports. 28 import inspect 29 import warnings 30 31 # relax module imports. 32 from lib import ansi 33 from status import Status; status = Status() 34 35 36 # The warning formatting function.38 """ Replacement for warnings.formatwarning to customise output format.""" 39 40 # Add the text 'RelaxWarning: ' to the start of the warning message. 41 message = "RelaxWarning: %s\n" % message 42 43 # Print stack-trace in escalate mode. 44 if status.escalate: 45 tb = "" 46 for frame in inspect.stack()[4:]: 47 file = frame[1] 48 lineNo = frame[2] 49 func = frame[3] 50 tb_frame = ' File "%s", line %i, in %s\n' % (file, lineNo, func) 51 try: 52 context = frame[4][frame[5]] 53 except TypeError: 54 pass 55 else: 56 tb_frame = '%s %s\n' % (tb_frame, context.strip()) 57 tb = tb_frame + tb 58 tb = "Traceback (most recent call last):\n%s" % tb 59 message = tb + message 60 61 # Text colouring 62 if ansi.enable_control_chars(stream=2): 63 # Strip the last newline, if it exists. 64 if message[-1] == '\n': 65 message = message[:-1] 66 67 # Reformat. 68 message = "%s%s%s\n" % (ansi.relax_warning, message, ansi.end) 69 70 # Return the warning message. 71 return message72 7375 """Set up the warning system.""" 76 77 # Format warning messages. 78 warnings.formatwarning = format 79 80 # Set warning filters. 81 if status.escalate: 82 warnings.filterwarnings('error', category=BaseWarning) 83 else: 84 warnings.filterwarnings('always', category=BaseWarning)85 86 87 88 # Base class for all warnings. 89 ############################## 90 94 95 96 # Standard warnings. 97 #################### 98 102 103 104 # Sequence errors. 105 ################## 106 107 # Cannot find the spin in the sequence. 111 112 113 # PDB warnings. 114 ############### 115 116 # Zero length interactomic vector.120 121 122 # The atom is missing from the PDB file. 126 127 128 # The PDB file is missing. 132 133 134 # Nuclear warnings. 135 ################### 136 137 # Nucleus not set. 144 145 # Spin type not set.119 self.text = "The interatomic vector between the spins '%s' and '%s' is of zero length." % (spin_id1, spin_id2)152 153 # File warnings. 154 ################ 155 156 # No data in file. 160 161 162 # Misc. 163 ####### 164 165 # Deselection warnings 169148 if spin_id != None: 149 self.text = "The nuclear isotope type for the spin '%s' has not yet been set. Please use the spin.isotope user function to set the type." % spin_id 150 else: 151 self.text = "The nuclear isotope type has not yet been set. Please use the spin.isotope user function to set the type."
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Mar 17 15:12:17 2014 | http://epydoc.sourceforge.net |