<s> import pprint <EOL> import pygments <EOL> from pygments import formatters , lexers <EOL> import resource <EOL> from watson . framework . debug import abc <EOL> from watson . framework import events <EOL> TEMPLATE = """<STR_LIT>""" <EOL> class Panel ( abc . Panel ) : <EOL> title = '<STR_LIT>' <EOL> route_match = None <EOL> @ property <EOL> def route_name ( self ) : <EOL> return self . route_match . route . name if self . route_match else None <EOL> @ property <EOL> def controller ( self ) : <EOL> return self . route_match . route . options [ '<STR_LIT>' ] if self . route_match else '<STR_LIT>' <EOL> @ property <EOL> def template ( self ) : <EOL> return self . view_model . template <EOL> @ property <EOL> def usage ( self ) : <EOL> return round ( resource . getrusage ( resource . RUSAGE_SELF ) . ru_maxrss / <NUM_LIT:1000> / <NUM_LIT> , <NUM_LIT:2> ) <EOL> def register_listeners ( self ) : <EOL> self . application . dispatcher . add ( events . DISPATCH_EXECUTE , self . route_match_listener ) <EOL> self . application . dispatcher . add ( events . RENDER_VIEW , self . render_listener , <NUM_LIT:1000> ) <EOL> def route_match_listener ( self , event ) : <EOL> self . route_match = event . params [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> def render_listener ( self , event ) : <EOL> self . view_model = event . params [ '<STR_LIT>' ] <EOL> def render ( self ) : <EOL> return self . renderer . env . from_string ( TEMPLATE ) . render ( <EOL> route_name = self . route_name , <EOL> controller = self . controller , <EOL> template = self . template , <EOL> usage = self . usage , <EOL> config = pygments . highlight ( pprint . pformat ( self . application . config ) , lexers . PythonLexer ( ) , formatters . HtmlFormatter ( ) ) ) <EOL> def render_key_stat ( self ) : <EOL> return '<STR_LIT>' . format ( self . usage ) </s>
