def optwrap(self, text):
    'Wrap all paragraphs in the provided text.'
    if (not self.body_width):
        return text
    assert wrap, 'Requires Python 2.3.'
    result = ''
    newlines = 0
    for para in text.split('\n'):
        if (len(para) > 0):
            if (not skipwrap(para)):
                result += '\n'.join(wrap(para, self.body_width))
                if para.endswith('  '):
                    result += '  \n'
                    newlines = 1
                else:
                    result += '\n\n'
                    newlines = 2
            elif (not onlywhite(para)):
                result += (para + '\n')
                newlines = 1
        elif (newlines < 2):
            result += '\n'
            newlines += 1
    return result
Wrap all paragraphs in the provided text.
def optwrap(self, text):
    
    if (not self.body_width):
        return text
    assert wrap, 'Requires Python 2.3.'
    result = 
    newlines = 0
    for para in text.split('\n'):
        if (len(para) > 0):
            if (not skipwrap(para)):
                result += '\n'.join(wrap(para, self.body_width))
                if para.endswith('  '):
                    result += '  \n'
                    newlines = 1
                else:
                    result += '\n\n'
                    newlines = 2
            elif (not onlywhite(para)):
                result += (para + '\n')
                newlines = 1
        elif (newlines < 2):
            result += '\n'
            newlines += 1
    return result