def word_wrap(text, tabwidth, limit, break_on_hyphens=False):
 lines = []
 special_tag_rgx = re.compile(u"^(((Acked-by|Ack'd-by|Based-on-patch-by|Cheered-on-by|Co-authored-by|Comments-by|Confirmed-by|Contributions-by|Debugged-by|Discovered-by|Explained-by|Backtraced-by|Helped-by|Liked-by|Link|Improved-by|Inspired-by|Initial-patch-by|Noticed-by|Original-patch-by|Originally-by|Mentored-by|Patch-by|Proposed-by|References|Related-to|Reported-by|Requested-by|Reviewed-by|See-also|Signed-off-by|Signed-Off-by|Spotted-by|Suggested-by|Tested-by|Tested-on-([a-zA-Z-_]+)-by|With-suggestions-by):)|([Cc]\\.\\s*[Ff]\\.\\s+))")
 w = TextWrapper(width=limit, tabwidth=tabwidth, break_on_hyphens=break_on_hyphens, drop_whitespace=True)
 for line in text.split(u'\n'):
  if special_tag_rgx.match(line):
   lines.append(line)
  else:
   lines.append(w.fill(line))
 return u'\n'.join(lines)

def word_wrap ( text , tabwidth , limit , break_on_hyphens = False ) : lines = [ ] special_tag_rgx = re . compile ( u"^(((Acked-by|Ack'd-by|Based-on-patch-by|Cheered-on-by|Co-authored-by|Comments-by|Confirmed-by|Contributions-by|Debugged-by|Discovered-by|Explained-by|Backtraced-by|Helped-by|Liked-by|Link|Improved-by|Inspired-by|Initial-patch-by|Noticed-by|Original-patch-by|Originally-by|Mentored-by|Patch-by|Proposed-by|References|Related-to|Reported-by|Requested-by|Reviewed-by|See-also|Signed-off-by|Signed-Off-by|Spotted-by|Suggested-by|Tested-by|Tested-on-([a-zA-Z-_]+)-by|With-suggestions-by):)|([Cc]\\.\\s*[Ff]\\.\\s+))" ) w = TextWrapper ( width = limit , tabwidth = tabwidth , break_on_hyphens = break_on_hyphens , drop_whitespace = True ) for line in text . split ( u'\n' ) : if special_tag_rgx . match ( line ) : lines . append ( line ) else : lines . append ( w . fill ( line ) ) return u'\n' . join ( lines )
wrap long lines to the specified limit .