tools/metrics/common/pretty_print_xml.py
def SplitParagraphs(text):
  """Split a block of text into paragraphs.

  Args:
    text: The text to split.

  Returns:
    A list of paragraphs as strings.
  """
  text = textwrap.dedent(text.strip('\n'))
  lines = text.split('\n')
  # Split the text into paragraphs at blank line boundaries.
  paragraphs = [[]]
  for l in lines:
    if paragraphs[-1] and not l.strip():
      paragraphs.append([])
    else:
      # Replace runs of repeated whitespace with a single space.
      transformed_line = ' '.join(l.split())
      paragraphs[-1].append(transformed_line)
  # Remove trailing empty paragraph if present.
  if paragraphs and not paragraphs[-1]:
    paragraphs = paragraphs[:-1]
  return ['\n'.join(p) for p in paragraphs]
Split a block of text into paragraphs.

  Args:
    text: The text to split.

  Returns:
    A list of paragraphs as strings.
  
Split a block of text into paragraphs.
Split a block of text into paragraphs .
def SplitParagraphs(text):
  text = textwrap.dedent(text.strip('\n'))
  lines = text.split('\n')
  paragraphs = [[]]
  for l in lines:
    if paragraphs[-1] and not l.strip():
      paragraphs.append([])
    else:
      transformed_line = ' '.join(l.split())
      paragraphs[-1].append(transformed_line)
  if paragraphs and not paragraphs[-1]:
    paragraphs = paragraphs[:-1]
  return ['\n'.join(p) for p in paragraphs]
def SplitParagraphs ( text ) : text = textwrap . dedent ( text . strip ( '\n' ) ) lines = text . split ( '\n' ) paragraphs = [ [ ] ] for l in lines : if paragraphs [ - 1 ] and not l . strip ( ) : paragraphs . append ( [ ] ) else : transformed_line = ' ' . join ( l . split ( ) ) paragraphs [ - 1 ] . append ( transformed_line ) if paragraphs and not paragraphs [ - 1 ] : paragraphs = paragraphs [ : - 1 ] return [ '\n' . join ( p ) for p in paragraphs ]
Split a block of text into paragraphs.
Split a block of text into paragraphs .
"""Split a block of text into paragraphs.

  Args:
    text: The text to split.

  Returns:
    A list of paragraphs as strings.
  """ # Split the text into paragraphs at blank line boundaries. # Replace runs of repeated whitespace with a single space. # Remove trailing empty paragraph if present.
A list of paragraphs as strings.
A list of paragraphs as strings .
text
The text to split.
The text to split .