diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-11-12 12:18:55 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-11-12 12:18:55 -0500 |
commit | 32fba82f1953bd5f26b5e1e2e9ac9ff7ff4758fc (patch) | |
tree | 2880917ce8d26dd1fff78febc9ea29faf91a802e /mako/exceptions.py | |
parent | 650fbdcac19ea1654b7a3856836fbda4115b4ed1 (diff) | |
download | external_python_mako-32fba82f1953bd5f26b5e1e2e9ac9ff7ff4758fc.tar.gz external_python_mako-32fba82f1953bd5f26b5e1e2e9ac9ff7ff4758fc.tar.bz2 external_python_mako-32fba82f1953bd5f26b5e1e2e9ac9ff7ff4758fc.zip |
- get the pygments install to be easily switched on/off
- fix test_exceptions to always call non-pygments tests
- update test for py3k transition
Diffstat (limited to 'mako/exceptions.py')
-rw-r--r-- | mako/exceptions.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/mako/exceptions.py b/mako/exceptions.py index fb9b3e6..583f874 100644 --- a/mako/exceptions.py +++ b/mako/exceptions.py @@ -235,15 +235,25 @@ ${tback.errorname}: ${tback.message} """) -try: +def _install_pygments(): + global syntax_highlight, pygments_html_formatter from mako.ext.pygmentplugin import syntax_highlight,\ pygments_html_formatter -except ImportError: + +def _install_fallback(): + global syntax_highlight, pygments_html_formatter from mako.filters import html_escape pygments_html_formatter = None def syntax_highlight(filename='', language=None): return html_escape +def _install_highlighting(): + try: + _install_pygments() + except ImportError: + _install_fallback() +_install_highlighting() + def html_error_template(): """Provides a template that renders a stack trace in an HTML format, providing an excerpt of code as well as substituting source template |