'_wrap_chunks(chunks : [string]) -> [string]
Wrap a sequence of text chunks and return a list of lines of length
\'self.width\' or less.  Some lines may be longer than this.  Chunks
correspond roughly to words and the whitespace between them: each
chunk is indivisible, but a line break can come between any two
chunks.  Chunks should not have internal whitespace; ie. a chunk is
either all whitespace or a "word".  Whitespace chunks will be removed
from the beginning and end of lines, but apart from that whitespace is
preserved.'

def _wrap_chunks(self, chunks):

    lines = []
    chunks = list(reversed(chunks))
    while chunks:
        cur_line = []
        cur_len = 0
        width = self.width
        if (self.drop_whitespace and (chunks[(-1)] == u'    ') and lines):
            chunks.pop()
        while chunks:
            l = self.chunklen(chunks[(-1)])
            if ((cur_len + l) <= width):
                cur_line.append(chunks.pop())
                cur_len += l
            else:
                break
        if (chunks and (self.chunklen(chunks[(-1)]) > width)):
            if (not cur_line):
                cur_line.append(chunks.pop())
        if (self.drop_whitespace and cur_line and (cur_line[(-1)] == u'    ')):
            cur_line.pop()
        if (self.drop_whitespace and cur_line and (cur_line[0] in (u'    ',))):
            cur_line.pop(0)
        if cur_line:
            lines.append(u''.join(cur_line))
    return lines
