import re


def _RemoveDevOnlyLines(data, build_type):
  """Remove dev-only lines.

  Args:
    data: the original data string
    build_type: build type ("dev" or "stable")

  Returns:
    if build_type == "dev"
      the data string including dev-only lines.
    else:
      the data string excluding dev-only lines.
  """
  pat = re.compile('<!--DEV_ONLY_START-->\n(.*)<!--DEV_ONLY_END-->\n',
                   re.DOTALL)
  if build_type == 'dev':
    return re.sub(pat, r'\1', data)
  else:
    return re.sub(pat, '', data)