require 'formula' class Libmusicbrainz < Formula homepage 'http://musicbrainz.org' url 'http://ftp.musicbrainz.org/pub/musicbrainz/libmusicbrainz-3.0.3.tar.gz' md5 'f4824d0a75bdeeef1e45cc88de7bb58a' devel do url 'ftp://ftp.musicbrainz.org/pub/musicbrainz/libmusicbrainz-4.0.0beta1.tar.gz' md5 '7dffa8fa08e4c0bc8119b8f48a15da41' version '4.0.0beta1' end depends_on 'neon' depends_on 'cmake' => :build def install neon = Formula.factory("neon") neon_args = "-DNEON_LIBRARIES:FILEPATH=#{neon.lib}/libneon.dylib -DNEON_INCLUDE_DIR:PATH=#{neon.include}/neon" system "cmake #{std_cmake_parameters} #{neon_args} ." system "make install" end end index : django-debug-toolbar
A configurable set of panels that display various debug information about the current request/response.
aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar/utils/sql.py
blob: 28106994395a3949fb7751595f05d46d9f5d60b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from __future__ import unicode_literals

import re

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):
    stack = sqlparse.engine.FilterStack()
    stack.preprocess.append(BoldKeywordFilter())  # add our custom filter
    stack.postprocess.append(sqlparse.filters.SerializerUnicode())  # tokens -> strings
    return swap_fields(''.join(stack.run(sql)))


def swap_fields(sql):
    return re.sub('SELECT</strong> (.*?) <strong>FROM', 'SELECT</strong> <a class="djDebugUncollapsed djDebugToggle" href="#">&#8226;&#8226;&#8226;</a> ' +
        '<a class="djDebugCollapsed djDebugToggle" href="#">\g<1></a> <strong>FROM', sql)