Trees | Indices | Help |
|
---|
|
1 ############################################################################### 2 # # 3 # Copyright (C) 2003-2012 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 all of the RelaxWarning objects.""" 25 26 # Python module imports. 27 import inspect 28 import sys 29 import warnings 30 31 # relax module imports. 32 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 pedantic mode. 44 if status.pedantic: 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.pedantic: 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 XH bond vector.120 121 122 # The atom is missing from the PDB file.119 self.text = "The XH bond vector for residue " + repr(res) + " is of zero length."126 127 128 # The PDB file is missing. 132 133 134 # File warnings. 135 ################ 136 137 # No data in file. 141 142 143 # Misc. 144 ####### 145 146 # Deselection warnings 150125 self.text = "The atom %s could not be found for residue %i" % (atom, res)
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Apr 10 14:16:36 2013 | http://epydoc.sourceforge.net |