(trace_data)
return trace_data
Fixes new-lines and decompresses trace data.

  Args:
    trace_data: The trace data returned by atrace.
  Returns:
    The decompressed trace data.
Fixes new-lines and decompresses trace data.
Fixes new - lines and decompresses trace data .
def strip_and_decompress_trace(trace_data):
  """Fixes new-lines and decompresses trace data.

  Args:
    trace_data: The trace data returned by atrace.
  Returns:
    The decompressed trace data.
  """
  # Collapse CRLFs that are added by adb shell.
  if trace_data.startswith('\r\n'):
    trace_data = trace_data.replace('\r\n', '\n')
  elif trace_data.startswith('\r\r\n'):
    # On windows, adb adds an extra '\r' character for each line.
    trace_data = trace_data.replace('\r\r\n', '\n')

  # Skip the initial newline.
  if trace_data[0] == '\n':
    trace_data = trace_data[1:]

  if not trace_data.startswith(TRACE_TEXT_HEADER):
    # No header found, so assume the data is compressed.
    trace_data = zlib.decompress(trace_data)

  # Enforce Unix line-endings.
  trace_data = trace_data.replace('\r', '')

  # Skip any initial newlines.
  while trace_data and trace_data[0] == '\n':
    trace_data = trace_data[1:]

  return trace_data
def strip_and_decompress_trace ( trace_data ) : # Collapse CRLFs that are added by adb shell. if trace_data . startswith ( '\r\n' ) : trace_data = trace_data . replace ( '\r\n' , '\n' ) elif trace_data . startswith ( '\r\r\n' ) : # On windows, adb adds an extra '\r' character for each line. trace_data = trace_data . replace ( '\r\r\n' , '\n' ) # Skip the initial newline. if trace_data [ 0 ] == '\n' : trace_data = trace_data [ 1 : ] if not trace_data . startswith ( TRACE_TEXT_HEADER ) : # No header found, so assume the data is compressed. trace_data = zlib . decompress ( trace_data ) # Enforce Unix line-endings. trace_data = trace_data . replace ( '\r' , '' ) # Skip any initial newlines. while trace_data and trace_data [ 0 ] == '\n' : trace_data = trace_data [ 1 : ] return trace_data