def print_queries(filter=None):
    """ Print all queries executed in this funnction. """
    def wrapper1(func):
        def wrapper2(*args, **kwargs):
            from django.db import connection
            sqltime, longest, numshown = 0.0, 0.0, 0
            initqueries = len(connection.queries)
            starttime = time.time()
            result = func(*args, **kwargs)
            for query in connection.queries[initqueries:]:
                sqltime += float(query['time'].strip('[]s'))
                longest = max(longest, float(query['time'].strip('[]s')))
                if not filter or filter in query['sql']:
                    numshown += 1
                    querystr = colored('\n[%ss] ' % query['time'], 'yellow')
                    querystr += colored(query['sql'], 'blue')
                    print querystr
            numqueries = len(connection.queries) - initqueries
            numhidden = numqueries - numshown
            runtime = round(time.time() - starttime, 3)
            proctime = round(runtime - sqltime, 3)
            print colored("------", 'blue')
            print colored('Total Time:  %ss' % runtime, 'yellow')
            print colored(proctime % 'Proc Time:   %ss', 'yellow')
            print colored('Query Time:  %ss (longest: %ss)' % (sqltime, longest), 'yellow')
            print colored('Num Queries: %s (%s hidden)\n' % (numqueries, numhidden), 'yellow')
            return result
        return wrapper2
    return wrapper1
dataset/ETHPy150Open mozilla/inventory/decorators/printqueries.py/print_queries/swapped operands of `%`