def normalize_trace_output(output):
 output = re.sub('\\[[0-9]+ refs\\]', '', output)
 try:
  result = [row.split(' DCTB ') for row in output.splitlines() if (row and (not row.startswith('#')))]
  result.sort(key=(lambda row: int(row[0])))
  result = [row[1] for row in result]
  return '\n'.join(result)
 except (IndexError, ValueError):
  raise AssertionError('tracer produced unparseable output:\n{}'.format(output))

def normalize_trace_output ( output ) : output = re . sub ( '\\[[0-9]+ refs\\]' , '' , output ) try : result = [ row . split ( ' DCTB ' ) for row in output . splitlines ( ) if ( row and ( not row . startswith ( '#' ) ) ) ] result . sort ( key = ( lambda row : int ( row [ 0 ] ) ) ) result = [ row [ 1 ] for row in result ] return '\n' . join ( result ) except ( IndexError , ValueError ) : raise AssertionError ( 'tracer produced unparseable output:\n{}' . format ( output ) )
normalize dtrace output for comparison .