def _trace(self, frame, event, arg_unused):
cur_time = time.time()<EOL>lineno = frame.f_lineno<EOL>depth = self.depth<EOL>filename = inspect.getfile(frame)<EOL>if self.last_exc_back:<EOL><INDENT>if frame == self.last_exc_back:<EOL><INDENT>self.data['<STR_LIT>'] += (cur_time - self.start_time)<EOL>self.depth -= <NUM_LIT:1><EOL>self.data = self.data_stack.pop()<EOL><DEDENT>self.last_exc_back = None<EOL><DEDENT>if event == '<STR_LIT>':<EOL><INDENT>self.depth += <NUM_LIT:1><EOL>if self.log:<EOL><INDENT>print >> sys.stdout, '<STR_LIT>' % ('<STR_LIT:U+0020>' * (depth - <NUM_LIT:1>), filename, frame.f_code.co_name)<EOL><DEDENT>o_lineno = frame.f_back.f_lineno<EOL>if self.pause_until is not None:<EOL><INDENT>if depth == self.pause_until:<EOL><INDENT>self.pause_until = None<EOL><DEDENT>else:<EOL><INDENT>return self._trace<EOL><DEDENT><DEDENT>if o_lineno not in self.data['<STR_LIT>']:<EOL><INDENT>self.pause_until = depth<EOL>return self._trace<EOL><DEDENT>self.data_stack.append(self.data)<EOL>call_sig = '<STR_LIT>' % (inspect.getfile(frame), frame.f_code.co_name)<EOL>if call_sig not in self.data['<STR_LIT>']:<EOL><INDENT>self.data['<STR_LIT>'][o_lineno][call_sig] = self._get_struct(frame, event)<EOL><DEDENT>self.data = self.data['<STR_LIT>'][o_lineno][call_sig]<EOL>self.data['<STR_LIT>'] += <NUM_LIT:1><EOL><DEDENT>elif event == '<STR_LIT>':<EOL><INDENT>if self.pause_until is None and lineno in self.data['<STR_LIT>']:<EOL><INDENT>self.data['<STR_LIT>'][lineno]['<STR_LIT>'] += <NUM_LIT:1><EOL>self.data['<STR_LIT>'][lineno]['<STR_LIT>'] += (cur_time - self.start_time)<EOL><DEDENT>if self.log:<EOL><INDENT>print >> sys.stdout, '<STR_LIT>' % ('<STR_LIT:U+0020>' * (depth - <NUM_LIT:1>), filename, frame.f_code.co_name, lineno)<EOL><DEDENT><DEDENT>elif event == '<STR_LIT>':<EOL><INDENT>timing = (cur_time - self.start_time)<EOL>if self.pause_until is None:<EOL><INDENT>self.data['<STR_LIT>'] += timing<EOL>self.data = self.data_stack.pop()<EOL>self.data['<STR_LIT>'] += timing<EOL><DEDENT>if self.log:<EOL><INDENT>print >> sys.stdout, '<STR_LIT>' % ('<STR_LIT:U+0020>' * (depth - <NUM_LIT:1>), filename, frame.f_code.co_name, timing)<EOL><DEDENT>self.depth -= <NUM_LIT:1><EOL><DEDENT>elif event == '<STR_LIT>':<EOL><INDENT>self.last_exc_back = frame.f_back<EOL>self.last_exc_firstlineno = frame.f_code.co_firstlineno<EOL><DEDENT>return self._trace<EOL>
The trace function passed to sys.settrace.