1 from __future__ import absolute_import
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """Module containing all of the RelaxWarning objects."""
25
26
27 import inspect
28 import sys
29 import warnings
30
31
32 from lib import ansi
33
34
35
36 ESCALATE = False
37 TRACEBACK = False
38
39
40
58
59
60 -def showwarning_tb(message, category, filename, lineno, file=None, line=None):
61 """Replacement for warnings.showwarning to show tracebacks."""
62
63
64 if file is None:
65 file = sys.stderr
66
67
68 tb = ""
69 for frame in inspect.stack()[1:]:
70 file_name = frame[1]
71 lineNo = frame[2]
72 func = frame[3]
73 tb_frame = ' File "%s", line %i, in %s\n' % (file_name, lineNo, func)
74 try:
75 context = frame[4][frame[5]]
76 except TypeError:
77 pass
78 else:
79 tb_frame = '%s %s\n' % (tb_frame, context.strip())
80 tb = tb_frame + tb
81 tb = "Traceback (most recent call last):\n%s" % tb
82 file.write(tb)
83
84
85 try:
86 file.write(format(message, category, filename, lineno, line))
87 except IOError:
88 pass
89
90
106
107
108
109
110
111
114 return str(self.text)
115
116
117
118
119
123
124
125
126
127
128
131 self.text = "Cannot find the spin %s within the sequence." % spin_id
132
133
134
135
136
137
139 - def __init__(self, spin_id1, spin_id2):
140 self.text = "The interatomic vector between the spins '%s' and '%s' is of zero length." % (spin_id1, spin_id2)
141
142
143
146 self.text = "The atom %s could not be found for residue %i" % (atom, res)
147
148
149
152 self.text = "The PDB file %s cannot be found, no structures will be loaded." % file
153
154
155
156
157
158
161 if spin_id != None:
162 self.text = "The type of nucleus for the spin '%s' has not yet been set." % spin_id
163 else:
164 self.text = "The type of nucleus has not yet been set."
165
166
169 if spin_id != None:
170 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
171 else:
172 self.text = "The nuclear isotope type has not yet been set. Please use the spin.isotope user function to set the type."
173
174
175
176
177
180 self.text = "The file '%s' contains no data." % file
181
182
183
184
185
186
189 self.text = "The spin '%s' has been deselected because of %s." % (spin_id, reason)
190
191
192
193
194
195
197 - def __init__(self, pipe_name=None, id=None):
198 self.text = "No spectrometer frequency information"
199 if id != None:
200 self.text += " for the '%s' experiment ID" % id
201 self.text += " is present"
202 if pipe_name != None:
203 self.text += " in the '%s' data pipe" % pipe_name
204 self.text += "."
205