From a195b9bf6ca1713305f95a3db9d2c3352f568eba Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Tue, 6 Feb 2007 21:44:17 +0000 Subject: Fix reports system traceback (Resolves Ticket #387) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2794 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Reports/reports/templatetags/syntax_coloring.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/lib/Server/Reports/reports/templatetags/syntax_coloring.py b/src/lib/Server/Reports/reports/templatetags/syntax_coloring.py index 14827b3c6..083b83a73 100644 --- a/src/lib/Server/Reports/reports/templatetags/syntax_coloring.py +++ b/src/lib/Server/Reports/reports/templatetags/syntax_coloring.py @@ -1,25 +1,25 @@ from django import template +register = template.Library() + try: from pygments import highlight from pygments.lexers import get_lexer_by_name from pygments.formatters import HtmlFormatter colorize = True + except: colorize = False - -register = template.Library() def syntaxhilight(value, arg="diff"): - '''Returns a syntax-hilighted version of Code; requires code and language arguments''' - lexer = get_lexer_by_name(arg) + '''Returns a syntax-hilighted version of Code; requires code/language arguments''' if colorize: try: + lexer = get_lexer_by_name(arg) return highlight(value, lexer, HtmlFormatter()) except: return value else: return value - register.filter('syntaxhilight', syntaxhilight) -- cgit v1.2.3-1-g7c22