def name_to_args(namestring):
  """Takes a script name which may contain CLI args
  and splits out the args.

  Assumes string is generically of the form
  '<script name>.py -arg --arg'
  """
  namestring = namestring.rstrip().lstrip()
  if namestring[-3:] == '.py':
    return [namestring]
  args = namestring.split('.py ')
  args = ([args[0].lstrip().rstrip() + '.py']
          + [s.lstrip().rstrip() for s in args[1].split()])
  return args