def formatwarning(message, category, filename, lineno, line=None):
 s = ('%s:%s: %s: %s\n' % (filename, lineno, category.__name__, message))
 line = (linecache.getline(filename, lineno) if (line is None) else line)
 if line:
  line = line.strip()
  s += ('  %s\n' % line)
 return s

def formatwarning ( message , category , filename , lineno , line = None ) : s = ( '%s:%s: %s: %s\n' % ( filename , lineno , category . __name__ , message ) ) line = ( linecache . getline ( filename , lineno ) if ( line is None ) else line ) if line : line = line . strip ( ) s += ( '  %s\n' % line ) return s
function to format a warning the standard way .