@staticmethod
def _word_wrap(text, width):
    """Returns lengths of lines that can be printed without wrapping."""
    lengths = []
    while len(text) > width:
        try:
            end = text[:width + 1].rindex(' ')
        except ValueError:
            break
        if end == -1:
            return [len(text)]
        lengths.append(end)
        text = text[end + 1:]
    if text:
        lengths.append(len(text))
    return lengths
