class_docstr: Object for wrapping/filling text.  The public interface consists of
  the wrap() and fill() methods; the other methods are just there for
  subclasses to override in order to tweak the default behaviour.
  If you want to completely replace the main wrapping algorithm,
  you'll probably have to override _wrap_chunks().
  
  Several instance attributes control various aspects of wrapping:
    width (default: 70)
      the maximum width of wrapped lines (unless break_long_words
      is false)
    initial_indent (default: "")
      string that will be prepended to the first line of wrapped
      output.  Counts towards the line's width.
    subsequent_indent (default: "")
      string that will be prepended to all lines save the first
      of wrapped output; also counts towards each line's width.
    expand_tabs (default: true)
      Expand tabs in input text to spaces before further processing.
      Each tab will become 0 .. 'tabsize' spaces, depending on its position
      in its line.  If false, each tab is treated as a single character.
    tabsize (default: 8)
      Expand tabs in input text to 0 .. 'tabsize' spaces, unless
      'expand_tabs' is false.
    replace_whitespace (default: true)
      Replace all whitespace characters in the input text by spaces
      after tab expansion.  Note that if expand_tabs is false and
      replace_whitespace is true, every tab will be converted to a
      single space!
    fix_sentence_endings (default: false)
      Ensure that sentence-ending punctuation is always followed
      by two spaces.  Off by default because the algorithm is
      (unavoidably) imperfect.
    break_long_words (default: true)
      Break words longer than 'width'.  If false, those words will not
      be broken, and some lines might be longer than 'width'.
    break_on_hyphens (default: true)
      Allow breaking hyphenated words. If true, wrapping will occur
      preferably on whitespaces and right after hyphens part of
      compound words.
    drop_whitespace (default: true)
      Drop leading and trailing whitespace from lines.
    max_lines (default: None)
      Truncate wrapped lines.
    placeholder (default: ' [...]')
      Append to the last line of truncated text.
docstr: _wrap_chunks(chunks : [string]) -> [string]
  
  Wrap a sequence of text chunks and return a list of lines of
  length 'self.width' or less.  (If 'break_long_words' is false,
  some lines may be longer than this.)  Chunks correspond roughly
  to words and the whitespace between them: each chunk is
  indivisible (modulo 'break_long_words'), but a line break can
  come between any two chunks.  Chunks should not have internal
  whitespace; ie. a chunk is either all whitespace or a "word".
  Whitespace chunks will be removed from the beginning and end of
  lines, but apart from that whitespace is preserved.
docstr_tok: ["_wrap_chunks","(","chunks",":","[","string","]",")","-",">","[","string","]","Wrap","a","sequence","of","text","chunks","and","return","a","list","of","lines","of","length","'self.width","'","or","less",".","(","If","'break_long_words","'","is","false",",","some","lines","may","be","longer","than","this",".",")","Chunks","correspond","roughly","to","words","and","the","whitespace","between","them",":","each","chunk","is","indivisible","(","modulo","'break_long_words","'",")",",","but","a","line","break","can","come","between","any","two","chunks",".","Chunks","should","not","have","internal","whitespace",";","ie",".","a","chunk","is","either","all","whitespace","or","a","``","word","''",".","Whitespace","chunks","will","be","removed","from","the","beginning","and","end","of","lines",",","but","apart","from","that","whitespace","is","preserved","."]
code: def _wrap_chunks(self, chunks):
      """_wrap_chunks(chunks : [string]) -> [string]
  
      Wrap a sequence of text chunks and return a list of lines of
      length 'self.width' or less.  (If 'break_long_words' is false,
      some lines may be longer than this.)  Chunks correspond roughly
      to words and the whitespace between them: each chunk is
      indivisible (modulo 'break_long_words'), but a line break can
      come between any two chunks.  Chunks should not have internal
      whitespace; ie. a chunk is either all whitespace or a "word".
      Whitespace chunks will be removed from the beginning and end of
      lines, but apart from that whitespace is preserved.
      """
      lines = []
      if self.width <= 0:
          raise ValueError(
              "invalid width %r (must be > 0)" % self.width
          )
      if self.max_lines is not None:
          if self.max_lines > 1:
              indent = self.subsequent_indent
          else:
              indent = self.initial_indent
          if len(indent) + len(self.placeholder.lstrip()) > self.width:
              raise ValueError("placeholder too large for max width")
  
      # Arrange in reverse order so items can be efficiently popped
      # from a stack of chucks.
      chunks.reverse()
  
      while chunks:
          # Start the list of chunks that will make up the current line.
          # cur_len is just the length of all the chunks in cur_line.
          cur_line = []
          cur_len = 0
  
          # Figure out which static string will prefix this line.
          if lines:
              indent = self.subsequent_indent
          else:
              indent = self.initial_indent
  
          # Maximum width for this line.
          width = self.width - len(indent)
  
          # First chunk on line is whitespace -- drop it, unless this
          # is the very beginning of the text (ie. no lines started yet).
          if (
              self.drop_whitespace
              and chunks[-1].strip() == ""
              and lines
          ):
              del chunks[-1]
  
          while chunks:
              l = len(chunks[-1])
  
              # Can at least squeeze this chunk onto the current line.
              if cur_len + l <= width:
                  cur_line.append(chunks.pop())
                  cur_len += l
  
              # Nope, this line is full.
              else:
                  break
  
          # The current line is full, and the next chunk is too big to
          # fit on *any* line (not just this one).
          if chunks and len(chunks[-1]) > width:
              self._handle_long_word(chunks, cur_line, cur_len, width)
              cur_len = sum(map(len, cur_line))
  
          # If the last chunk on this line is all whitespace, drop it.
          if (
              self.drop_whitespace
              and cur_line
              and cur_line[-1].strip() == ""
          ):
              cur_len -= len(cur_line[-1])
              del cur_line[-1]
  
          if cur_line:
              if (
                  self.max_lines is None
                  or len(lines) + 1 < self.max_lines
                  or (
                      not chunks
                      or self.drop_whitespace
                      and len(chunks) == 1
                      and not chunks[0].strip()
                  )
                  and cur_len <= width
              ):
                  # Convert current line back to a string and store it in
                  # list of all lines (return value).
                  lines.append(indent + "".join(cur_line))
              else:
                  while cur_line:
                      if (
                          cur_line[-1].strip()
                          and cur_len + len(self.placeholder) <= width
                      ):
                          cur_line.append(self.placeholder)
                          lines.append(indent + "".join(cur_line))
                          break
                      cur_len -= len(cur_line[-1])
                      del cur_line[-1]
                  else:
                      if lines:
                          prev_line = lines[-1].rstrip()
                          if (
                              len(prev_line) + len(self.placeholder)
                              <= self.width
                          ):
                              lines[-1] = prev_line + self.placeholder
                              break
                      lines.append(indent + self.placeholder.lstrip())
                  break
  
      return lines
  
file_path: catboost/contrib/tools/python3/src/Lib/textwrap.py
imports: import re
label_desc: Use image node_id 6 for calling the TextWrapper obj's underlying member method code with example usage: obj._wrap_chunks(chunks) and returns: lines