Package logilab-common-0 :: Package 39 :: Package 0 :: Module html
[frames] | no frames]

Source Code for Module logilab-common-0.39.0.html

 1  """Print traceback in HTML. 
 2   
 3  :copyright: 2000-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 
 4  :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr 
 5  :license: General Public License version 2 - http://www.gnu.org/licenses 
 6  """ 
 7  __docformat__ = "restructuredtext en" 
 8   
 9  from warnings import warn 
10  warn('html module is deprecated and will disappear in a near release', 
11       DeprecationWarning, stacklevel=2) 
12   
13  import traceback 
14  from xml.sax.saxutils import escape   
15   
16  # mk html traceback error ##################################################### 
17   
18 -def html_traceback(info, exception, 19 title='', encoding='ISO-8859-1', body=''):
20 """Return an html formatted traceback from python exception infos. 21 """ 22 #typ, value, tbck = info 23 stacktb = traceback.extract_tb(info[2]) #tbck) 24 strings = [] 25 if body: 26 strings.append('<div class="error_body">') 27 strings.append(body) 28 strings.append('</div>') 29 if title: 30 strings.append('<h1 class="error">%s</h1>'% escape(title)) 31 strings.append('<p class="error">%s</p>' % escape(str(exception))) 32 strings.append('<div class="error_traceback">') 33 for stackentry in stacktb : 34 strings.append('<b>File</b> <b class="file">%s</b>, <b>line</b> ' 35 '<b class="line">%s</b>, <b>function</b> ' 36 '<b class="function">%s</b>:<br/>'%( 37 escape(stackentry[0]), stackentry[1], stackentry[2])) 38 if stackentry[3]: 39 string = escape(repr(stackentry[3])[1:-1])#.encode(encoding) 40 strings.append('&nbsp;&nbsp;%s<br/>\n' % string) 41 strings.append('</div>') 42 return '\n'.join(strings)
43