<s> from __future__ import absolute_import <EOL> from debug_toolbar . panels import Panel <EOL> from django . utils . translation import ungettext <EOL> from . . utils . thread_collector import ThreadCollector <EOL> class CallRecordingPanel ( Panel ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( CallRecordingPanel , self ) . __init__ ( * args , ** kwargs ) <EOL> cls = type ( self ) <EOL> if getattr ( cls , '<STR_LIT>' , None ) is None : <EOL> self . collector = ThreadCollector ( ) <EOL> for context in cls . get_context ( self . collector ) : <EOL> context . patch ( ) <EOL> @ classmethod <EOL> def get_context ( cls ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> def enable_instrumentation ( self ) : <EOL> self . calls = self . collector . enable ( ) <EOL> def disable_instrumentation ( self ) : <EOL> self . collector . disable ( ) <EOL> @ property <EOL> def nav_subtitle ( self ) : <EOL> calls = len ( self . calls ) <EOL> duration = int ( sum ( ( ( c [ '<STR_LIT:end>' ] - c [ '<STR_LIT:start>' ] ) for c in self . calls ) ) * <NUM_LIT:1000> ) <EOL> return ungettext ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> calls ) % { '<STR_LIT>' : calls , '<STR_LIT>' : duration } </s>
