(data, limit, comment_header)
return '\n'.join(comment_header+line for line in newdata) + block_suffix
Return data reformatted to specified width with comment header.
Return data reformatted to specified width with comment header.
Return data reformatted to specified width with comment header .
def reformat_comment(data, limit, comment_header):
    """Return data reformatted to specified width with comment header."""

    # Remove header from the comment lines
    lc = len(comment_header)
    data = "\n".join(line[lc:] for line in data.split("\n"))
    # Reformat to maxformatwidth chars or a 20 char width,
    # whichever is greater.
    format_width = max(limit - len(comment_header), 20)
    newdata = reformat_paragraph(data, format_width)
    # re-split and re-insert the comment header.
    newdata = newdata.split("\n")
    # If the block ends in a \n, we don't want the comment prefix
    # inserted after it. (Im not sure it makes sense to reformat a
    # comment block that is not made of complete lines, but whatever!)
    # Can't think of a clean solution, so we hack away
    block_suffix = ""
    if not newdata[-1]:
        block_suffix = "\n"
        newdata = newdata[:-1]
    return '\n'.join(comment_header+line for line in newdata) + block_suffix
def reformat_comment ( data , limit , comment_header ) : # Remove header from the comment lines lc = len ( comment_header ) data = "\n" . join ( line [ lc : ] for line in data . split ( "\n" ) ) # Reformat to maxformatwidth chars or a 20 char width, # whichever is greater. format_width = max ( limit - len ( comment_header ) , 20 ) newdata = reformat_paragraph ( data , format_width ) # re-split and re-insert the comment header. newdata = newdata . split ( "\n" ) # If the block ends in a \n, we don't want the comment prefix # inserted after it. (Im not sure it makes sense to reformat a # comment block that is not made of complete lines, but whatever!) # Can't think of a clean solution, so we hack away block_suffix = "" if not newdata [ - 1 ] : block_suffix = "\n" newdata = newdata [ : - 1 ] return '\n' . join ( comment_header + line for line in newdata ) + block_suffix