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   
 25  """Module containing all of the RelaxWarning objects.""" 
 26   
 27   
 28  import inspect 
 29  import sys 
 30  import warnings 
 31   
 32   
 33  from lib import ansi 
 34   
 35   
 36   
 37  ESCALATE = False     
 38  TRACEBACK = False     
 39   
 40   
 41   
 59   
 60   
 61 -def showwarning_tb(message, category, filename, lineno, file=None, line=None): 
  62      """Replacement for warnings.showwarning to show tracebacks.""" 
 63   
 64       
 65      if file is None: 
 66          file = sys.stderr 
 67   
 68       
 69      tb = "" 
 70      for frame in inspect.stack()[1:]: 
 71          file_name = frame[1] 
 72          lineNo = frame[2] 
 73          func = frame[3] 
 74          tb_frame = '  File "%s", line %i, in %s\n' % (file_name, lineNo, func) 
 75          try: 
 76              context = frame[4][frame[5]] 
 77          except TypeError: 
 78              pass 
 79          else: 
 80              tb_frame = '%s    %s\n' % (tb_frame, context.strip()) 
 81          tb = tb_frame + tb 
 82      tb = "Traceback (most recent call last):\n%s" % tb 
 83      file.write(tb) 
 84   
 85       
 86      try: 
 87          file.write(format(message, category, filename, lineno, line)) 
 88      except IOError: 
 89          pass 
  90   
 91   
107   
108   
109   
110   
111   
112   
115          return str(self.text) 
 132          self.text = "Cannot find the spin %s within the sequence." % spin_id 
 140 -    def __init__(self, spin_id1, spin_id2): 
 141          self.text = "The interatomic vector between the spins '%s' and '%s' is of zero length." % (spin_id1, spin_id2) 
 147          self.text = "The atom %s could not be found for residue %i" % (atom, res) 
 153          self.text = "The PDB file %s cannot be found, no structures will be loaded." % file 
 162          if spin_id != None: 
163              self.text = "The type of nucleus for the spin '%s' has not yet been set." % spin_id 
164          else: 
165              self.text = "The type of nucleus has not yet been set." 
 170          if spin_id != None: 
171              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 
172          else: 
173              self.text = "The nuclear isotope type has not yet been set.  Please use the spin.isotope user function to set the type." 
 181          self.text = "The file '%s' contains no data." % file 
 190          self.text = "The spin '%s' has been deselected because of %s." % (spin_id, reason) 
 198 -    def __init__(self, pipe_name=None, id=None): 
 199          self.text = "No spectrometer frequency information" 
200          if id != None: 
201              self.text += " for the '%s' experiment ID" % id 
202          self.text += " is present" 
203          if pipe_name != None: 
204              self.text += " in the '%s' data pipe" % pipe_name 
205          self.text += "."