class_docstr: Format colored Python source.
      
class_docstr_tok: ["Format","colored","Python","source","."]
docstr: Token handler, with syntax highlighting.
docstr_tok: ["Token","handler",",","with","syntax","highlighting","."]
code: def __call__(self, toktype, toktext, start_pos, end_pos, line):
      """Token handler, with syntax highlighting."""
      (srow, scol) = start_pos
      (erow, ecol) = end_pos
      colors = self.colors
      owrite = self.out.write
  
      # line separator, so this works across platforms
      linesep = os.linesep
  
      # calculate new positions
      oldpos = self.pos
      newpos = self.lines[srow] + scol
      self.pos = newpos + len(toktext)
  
      # send the original whitespace, if needed
      if newpos > oldpos:
          owrite(self.raw[oldpos:newpos])
  
      # skip indenting tokens
      if toktype in [token.INDENT, token.DEDENT]:
          self.pos = newpos
          return
  
      # map token type to a color group
      if token.LPAR <= toktype <= token.OP:
          toktype = token.OP
      elif toktype == token.NAME and keyword.iskeyword(toktext):
          toktype = _KEYWORD
      color = colors.get(toktype, colors[_TEXT])
  
      # print '<%s>' % toktext,    # dbg
  
      # Triple quoted strings must be handled carefully so that backtracking
      # in pagers works correctly. We need color terminators on _each_ line.
      if linesep in toktext:
          toktext = toktext.replace(
              linesep, "%s%s%s" % (colors.normal, linesep, color)
          )
  
      # send text
      owrite("%s%s%s" % (color, toktext, colors.normal))
  
file_path: catboost/contrib/python/ipython/py2/IPython/utils/PyColorize.py
imports: from __future__ import print_function
  from __future__ import absolute_import
  from __future__ import unicode_literals
  import keyword
  import os
  import sys
  import token
  import tokenize
  from IPython.utils.coloransi import TermColors, InputTermColors, ColorScheme, ColorSchemeTable
  from IPython.utils.py3compat import PY3
  from .colorable import Colorable
label_desc: Use image node_id 4 for calling the Parser obj's underlying member method code with example usage: obj.__call__(toktype, toktext, start_pos, end_pos, line) without return types