Splits strings into space-separated components.

  The difference between SplitIntoComponents and .split(" ") is that
  the former tries to respect single and double quotes and strip them
  using lexical rules typically used in command line interpreters.

  Args:
    str_in: Source string to be split into components.

  Returns:
    str_in represented as a list of components. Components is effectively a
    space-separated representation of a source string. " ".join(components)
    should produce the original string (with pairs of single/double quotes
    stripped).

def SplitIntoComponents(str_in):
  """Splits strings into space-separated components.

  The difference between SplitIntoComponents and .split(" ") is that
  the former tries to respect single and double quotes and strip them
  using lexical rules typically used in command line interpreters.

  Args:
    str_in: Source string to be split into components.

  Returns:
    str_in represented as a list of components. Components is effectively a
    space-separated representation of a source string. " ".join(components)
    should produce the original string (with pairs of single/double quotes
    stripped).
  """

  if str_in.startswith(("\"", "'")):
    return shlex.split(str_in)
  else:
    components = str_in.split(" ", 1)
    if len(components) > 1:
      return [components[0]] + SplitIntoComponents(components[1])
    else:
      return components