Trees | Indices | Help |
|
---|
|
1 ############################################################################### 2 # # 3 # Copyright (C) 2003-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 containing all of the RelaxWarning objects.""" 24 25 # Python module imports. 26 import inspect 27 import sys 28 import warnings 29 30 # relax module imports. 31 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 XH bond vector.119 120 121 # The atom is missing from the PDB file. 125 126 127 # The PDB file is missing. 131 132 133 # File warnings. 134 ################ 135 136 # No data in file. 140 141 142 # Misc. 143 ####### 144 145 # Deselection warnings 149118 self.text = "The XH bond vector for residue " + repr(res) + " is of zero length."
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Apr 10 15:06:15 2013 | http://epydoc.sourceforge.net |