def wrap_text(text, width=<NUM_LIT>, initial_indent='<STR_LIT>', subsequent_indent='<STR_LIT>',<EOL>preserve_paragraphs=False):
from ._textwrap import TextWrapper<EOL>text = text.expandtabs()<EOL>wrapper = TextWrapper(width, initial_indent=initial_indent,<EOL>subsequent_indent=subsequent_indent,<EOL>replace_whitespace=False)<EOL>if not preserve_paragraphs:<EOL><INDENT>return wrapper.fill(text)<EOL><DEDENT>p = []<EOL>buf = []<EOL>indent = None<EOL>def _flush_par():<EOL><INDENT>if not buf:<EOL><INDENT>return<EOL><DEDENT>if buf[<NUM_LIT:0>].strip() == '<STR_LIT>':<EOL><INDENT>p.append((indent or <NUM_LIT:0>, True, '<STR_LIT:\n>'.join(buf[<NUM_LIT:1>:])))<EOL><DEDENT>else:<EOL><INDENT>p.append((indent or <NUM_LIT:0>, False, '<STR_LIT:U+0020>'.join(buf)))<EOL><DEDENT>del buf[:]<EOL><DEDENT>for line in text.splitlines():<EOL><INDENT>if not line:<EOL><INDENT>_flush_par()<EOL>indent = None<EOL><DEDENT>else:<EOL><INDENT>if indent is None:<EOL><INDENT>orig_len = term_len(line)<EOL>line = line.lstrip()<EOL>indent = orig_len - term_len(line)<EOL><DEDENT>buf.append(line)<EOL><DEDENT><DEDENT>_flush_par()<EOL>rv = []<EOL>for indent, raw, text in p:<EOL><INDENT>with wrapper.extra_indent('<STR_LIT:U+0020>' * indent):<EOL><INDENT>if raw:<EOL><INDENT>rv.append(wrapper.indent_only(text))<EOL><DEDENT>else:<EOL><INDENT>rv.append(wrapper.fill(text))<EOL><DEDENT><DEDENT><DEDENT>return '<STR_LIT>'.join(rv)<EOL>
A helper function that intelligently wraps text.  By default, it
    assumes that it operates on a single paragraph of text but if the
    `preserve_paragraphs` parameter is provided it will intelligently
    handle paragraphs (defined by two empty lines).

    If paragraphs are handled, a paragraph can be prefixed with an empty
    line containing the ``\\b`` character (``\\x08``) to indicate that
    no rewrapping should happen in that block.

    :param text: the text that should be rewrapped.
    :param width: the maximum width for the text.
    :param initial_indent: the initial indent that should be placed on the
                           first line as a string.
    :param subsequent_indent: the indent string that should be placed on
                              each consecutive line.
    :param preserve_paragraphs: if this flag is set then the wrapping will
                                intelligently handle paragraphs.