root / logilab.pylintinstaller / logilab / common / html.py

Revision 202:d67e86292521, 2.2 kB (checked in by tziade@…, 9 months ago)

added logilab.pylintinstaller

Line 
1# This program is free software; you can redistribute it and/or modify it under
2# the terms of the GNU General Public License as published by the Free Software
3# Foundation; either version 2 of the License, or (at your option) any later
4# version.
5#
6# This program is distributed in the hope that it will be useful, but WITHOUT
7# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
9#
10# You should have received a copy of the GNU General Public License along with
11# this program; if not, write to the Free Software Foundation, Inc.,
12# 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
13""" Copyright (c) 2002-2006 LOGILAB S.A. (Paris, FRANCE).
14 http://www.logilab.fr/ -- mailto:contact@logilab.fr
15"""
16
17from warnings import warn
18warn('html module is deprecated and will disappear in a near release',
19     DeprecationWarning, stacklevel=2)
20
21__revision__ = "$Id: html.py,v 1.5 2003-09-12 11:54:47 syt Exp $"
22
23import traceback
24from xml.sax.saxutils import escape 
25
26# mk html traceback error #####################################################
27
28def html_traceback(info, exception,
29                   title='', encoding='ISO-8859-1', body=''):
30    """ return an html formatted traceback from python exception infos.
31    """
32    #typ, value, tbck = info
33    stacktb = traceback.extract_tb(info[2]) #tbck)
34    strings = []
35    if body:
36        strings.append('<div class="error_body">')
37        strings.append(body)
38        strings.append('</div>')
39    if title:
40        strings.append('<h1 class="error">%s</h1>'% escape(title))
41    strings.append('<p class="error">%s</p>' % escape(str(exception)))
42    strings.append('<div class="error_traceback">')
43    for stackentry in stacktb :
44        strings.append('<b>File</b> <b class="file">%s</b>, <b>line</b> '
45                      '<b class="line">%s</b>, <b>function</b> '
46                      '<b class="function">%s</b>:<br/>'%(
47            escape(stackentry[0]), stackentry[1], stackentry[2]))
48        if stackentry[3]:
49            string = escape(repr(stackentry[3])[1:-1])#.encode(encoding)
50            strings.append('&nbsp;&nbsp;%s<br/>\n' % string)
51    strings.append('</div>')
52    return '\n'.join(strings)
Note: See TracBrowser for help on using the browser.