code: def _align_header(header, alignment, width, visible_width, is_multiline=False,
                    width_fn=None):
      "Pad string header to width chars given known visible_width of the header."
      if is_multiline:
          header_lines = re.split(_multiline_codes, header)
          padded_lines = [_align_header(h, alignment, width, width_fn(h))
                          for h in header_lines]
          return "\n".join(padded_lines)
      # else: not multiline
      ninvisible = len(header) - visible_width
      width += ninvisible
      if alignment == "left":
          return _padright(width, header)
      elif alignment == "center":
          return _padboth(width, header)
      elif not alignment:
          return "{0}".format(header)
      else:
          return _padleft(width, headerf _align_header(header, alignment, width, visible_width, is_multiline=False,
                    width_fn=None):
      "Pad string header to width chars given known visible_width of the header."
      if is_multiline:
          header_lines = re.split(_multiline_codes, header)
          padded_lines = [_align_header(h, alignment, width, width_fn(h))
                          for h in header_lines]
          return "\n".join(padded_lines)
      # else: not multiline
      ninvisible = len(header) - visible_width
      width += ninvisible
      if alignment == "left":
          return _padright(width, header)
      elif alignment == "center":
          return _padboth(width, header)
      elif not alignment:
          return "{0}".format(header)
      else:
          return _padleft(width, header)
docs: Pad string header to width chars given known visible_width of the header.