diff options
| author | Aymeric Augustin | 2013-10-16 22:29:51 +0200 |
|---|---|---|
| committer | Aymeric Augustin | 2013-10-17 18:24:57 +0200 |
| commit | eacf116d61f0e3f47a7c581275a18b3aec8548b1 (patch) | |
| tree | 87674c6ea964f9404eb3d646c518a3ecd54cce4b /debug_toolbar/utils/sql.py | |
| parent | c1f39b1a168d535e0b90d3c69273e391adf22637 (diff) | |
| download | django-debug-toolbar-eacf116d61f0e3f47a7c581275a18b3aec8548b1.tar.bz2 | |
Switch to an external version of sqlparse.
Diffstat (limited to 'debug_toolbar/utils/sql.py')
| -rw-r--r-- | debug_toolbar/utils/sql.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/debug_toolbar/utils/sql.py b/debug_toolbar/utils/sql.py index 909edf7..5de7da5 100644 --- a/debug_toolbar/utils/sql.py +++ b/debug_toolbar/utils/sql.py @@ -1,6 +1,22 @@ import re -from debug_toolbar.utils import sqlparse -from debug_toolbar.utils.sqlparse.filters import BoldKeywordFilter + +from django.utils.html import escape + +import sqlparse +from sqlparse import tokens as T + + +class BoldKeywordFilter: + """sqlparse filter to bold SQL keywords""" + def process(self, stack, stream): + """Process the token stream""" + for token_type, value in stream: + is_keyword = token_type in T.Keyword + if is_keyword: + yield T.Text, '<strong>' + yield token_type, escape(value) + if is_keyword: + yield T.Text, '</strong>' def reformat_sql(sql): |
