def group_device_names(devices, group_size):
    'Group device names into groups of group_size.\n\n  Args:\n    devices: a list of canonical device strings.\n    group_size: integer which is equal to or greater than 1.\n\n  Returns:\n    list of lists of devices, where each inner list is group_size long,\n      and each device appears at least once in an inner list.  If\n      len(devices) % group_size == 0 then each device will appear exactly once.\n\n  Raises:\n    ValueError: if group_size > len(devices)\n  '
    num_devices = len(devices)
    if (group_size > num_devices):
        raise ValueError(('only %d devices, but group_size=%d' % (num_devices, group_size)))
    num_groups = ((num_devices // group_size) + (1 if ((num_devices % group_size) != 0) else 0))
    groups = [[] for i in range(num_groups)]
    for i in range((num_groups * group_size)):
        groups[(i % num_groups)].append(devices[(i % num_devices)])
    return groups
Group device names into groups of group_size.

Args:
  devices: a list of canonical device strings.
  group_size: integer which is equal to or greater than 1.

Returns:
  list of lists of devices, where each inner list is group_size long,
    and each device appears at least once in an inner list.  If
    len(devices) % group_size == 0 then each device will appear exactly once.

Raises:
  ValueError: if group_size > len(devices)
def group_device_names(devices, group_size):
    'Group device names into groups of group_size.\n\n  Args:\n    devices: a list of canonical device strings.\n    group_size: integer which is equal to or greater than 1.\n\n  Returns:\n    list of lists of devices, where each inner list is group_size long,\n      and each device appears at least once in an inner list.  If\n      len(devices) % group_size == 0 then each device will appear exactly once.\n\n  Raises:\n    ValueError: if group_size > len(devices)\n  '
    num_devices = len(devices)
    if (group_size > num_devices):
        raise ValueError(('only %d devices, but group_size=%d' % (num_devices, group_size)))
    num_groups = ((num_devices // group_size) + (1 if ((num_devices % group_size) != 0) else 0))
    groups = [[] for i in range(num_groups)]
    for i in range((num_groups * group_size)):
        groups[(i % num_groups)].append(devices[(i % num_devices)])
    return groups