#NEWLINE# def report( statistics , filename = None , template = 'html.mako' , **kwargs ) : #NEWLINE# #INDENT# ' Generate an HTML report of query statistics.\n\n    :param statistics: An iterable of :class:`QueryStats` objects over\n        which to prepare a report. This is typically a list returned by\n        a call to :func:`collect`.\n\n    :param filename: If present, additionally write the report out to a file at\n        the specified path.\n\n    :param template: The name of the file in the sqltap/templates directory to\n        render for the report. This is mostly intended for extensions to sqltap\n        (like the wsgi extension). Not working when :param:`report_format`\n        specified.\n\n    :param report_format: (Optional) Choose the format for SQLTap report,\n        candidates are ["html", "wsgi", "text"]\n\n    :return: The generated SQLTap Report.\n    ' #NEWLINE# REPORTER_MAPPING = { #NEWLINE# #INDENT# REPORT_HTML : HTMLReporter , #NEWLINE# REPORT_WSGI : WSGIReporter , #NEWLINE# REPORT_TEXT : TextReporter , #NEWLINE# #UNINDENT# } #NEWLINE# report_format = kwargs . get ( 'report_format' ) #NEWLINE# if report_format : #NEWLINE# #INDENT# report_format = report_format . lower ( ) #NEWLINE# if ( report_format not in REPORTER_MAPPING . keys ( ) ) : #NEWLINE# #INDENT# raise Exception ( 'Format |%s| is not valid! formats supported: %s ' , ( report_format , REPORTER_MAPPING . keys ( ) ) ) #NEWLINE# #UNINDENT# reporter = REPORTER_MAPPING [ report_format ] ( statistics , report_file = filename , ** kwargs ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# reporter = HTMLReporter ( statistics , report_file = filename , template_file = template , ** kwargs ) #NEWLINE# #UNINDENT# result = reporter . report ( ) #NEWLINE# return result