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