(command_list)
return final_cmds
Adds missing cmd tags to the given command list.
Adds missing cmd tags to the given command list.
Adds missing cmd tags to the given command list .
def add_missing_cmd(command_list):
  """Adds missing cmd tags to the given command list."""
  # E.g.: given:
  #   ['a', '0', '0', '0', '0', '0', '0', '0',
  #         '0', '0', '0', '0', '0', '0', '0']
  # Converts to:
  #   [['a', '0', '0', '0', '0', '0', '0', '0'],
  #    ['a', '0', '0', '0', '0', '0', '0', '0']]
  # And returns a string that joins these elements with spaces.
  cmd_tag = command_list[0]
  args = command_list[1:]

  final_cmds = []
  for arg_batch in grouper(args, NUM_ARGS[cmd_tag]):
    final_cmds.append([cmd_tag] + list(arg_batch))

  if not final_cmds:
    # command has no args (e.g.: 'z')
    final_cmds = [[cmd_tag]]

  return final_cmds
def add_missing_cmd ( command_list ) : # E.g.: given: #   ['a', '0', '0', '0', '0', '0', '0', '0', #         '0', '0', '0', '0', '0', '0', '0'] # Converts to: #   [['a', '0', '0', '0', '0', '0', '0', '0'], #    ['a', '0', '0', '0', '0', '0', '0', '0']] # And returns a string that joins these elements with spaces. cmd_tag = command_list [ 0 ] args = command_list [ 1 : ] final_cmds = [ ] for arg_batch in grouper ( args , NUM_ARGS [ cmd_tag ] ) : final_cmds . append ( [ cmd_tag ] + list ( arg_batch ) ) if not final_cmds : # command has no args (e.g.: 'z') final_cmds = [ [ cmd_tag ] ] return final_cmds