<s> """<STR_LIT>""" <EOL> import os , time <EOL> COLORS = { '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT:32> , '<STR_LIT>' : <NUM_LIT:30> , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> } <EOL> RESET = '<STR_LIT>' <EOL> def print_queries ( filter = None ) : <EOL> """<STR_LIT>""" <EOL> def wrapper1 ( func ) : <EOL> def wrapper2 ( * args , ** kwargs ) : <EOL> from django . db import connection <EOL> sqltime , longest , numshown = <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT:0> <EOL> initqueries = len ( connection . queries ) <EOL> starttime = time . time ( ) <EOL> result = func ( * args , ** kwargs ) <EOL> for query in connection . queries [ initqueries : ] : <EOL> sqltime += float ( query [ '<STR_LIT:time>' ] . strip ( '<STR_LIT>' ) ) <EOL> longest = max ( longest , float ( query [ '<STR_LIT:time>' ] . strip ( '<STR_LIT>' ) ) ) <EOL> if not filter or filter in query [ '<STR_LIT>' ] : <EOL> numshown += <NUM_LIT:1> <EOL> querystr = colored ( '<STR_LIT>' % query [ '<STR_LIT:time>' ] , '<STR_LIT>' ) <EOL> querystr += colored ( query [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> print querystr <EOL> numqueries = len ( connection . queries ) - initqueries <EOL> numhidden = numqueries - numshown <EOL> runtime = round ( time . time ( ) - starttime , <NUM_LIT:3> ) <EOL> proctime = round ( runtime - sqltime , <NUM_LIT:3> ) <EOL> print colored ( "<STR_LIT>" , '<STR_LIT>' ) <EOL> print colored ( '<STR_LIT>' % runtime , '<STR_LIT>' ) <EOL> print colored ( '<STR_LIT>' % proctime , '<STR_LIT>' ) <EOL> print colored ( '<STR_LIT>' % ( sqltime , longest ) , '<STR_LIT>' ) <EOL> print colored ( '<STR_LIT>' % ( numqueries , numhidden ) , '<STR_LIT>' ) <EOL> return result <EOL> return wrapper2 <EOL> return wrapper1 <EOL> def colored ( text , color = None ) : <EOL> """<STR_LIT>""" <EOL> if os . getenv ( '<STR_LIT>' ) is None and <NUM_LIT:1> == <NUM_LIT:2> : <EOL> fmt_str = '<STR_LIT>' <EOL> if color is not None : <EOL> text = fmt_str % ( COLORS [ color ] , text ) <EOL> text += RESET <EOL> return text </s>
