code: def color_text(text, color=None, method=None):
      if not (isinstance(color, str) or isinstance(color, tuple)):
          raise TypeError(
              f"Cannot color text with provided color of type {type(color)}"
          )
      if isinstance(color, tuple):
          if len(color) > 1:
              text = color_text(text, color[1:], method)
          color = color[0]
  
      if method is None:
          return text
      if method == "html":
          return f"<font color = {color}>{text}</font>"
      elif method == "ansi":
          if color == "green":
              color = ANSI_ESCAPE_CODES.OKGREEN
          elif color == "red":
              color = ANSI_ESCAPE_CODES.FAIL
          elif color == "blue":
              color = ANSI_ESCAPE_CODES.OKBLUE
          elif color == "purple":
              color = ANSI_ESCAPE_CODES.PURPLE
          elif color == "yellow":
              color = ANSI_ESCAPE_CODES.YELLOW
          elif color == "orange":
              color = ANSI_ESCAPE_CODES.ORANGE
          elif color == "pink":
              color = ANSI_ESCAPE_CODES.PINK
          elif color == "cyan":
              color = ANSI_ESCAPE_CODES.CYAN
          elif color == "gray":
              color = ANSI_ESCAPE_CODES.GRAY
          elif color == "brown":
              color = ANSI_ESCAPE_CODES.BROWN
          elif color == "bold":
              color = ANSI_ESCAPE_CODES.BOLD
          elif color == "underline":
              color = ANSI_ESCAPE_CODES.UNDERLINE
          elif color == "warning":
              color = ANSI_ESCAPE_CODES.WARNING
          else:
              raise ValueError(f"unknown text color {color}")
  
          return color + text + ANSI_ESCAPE_CODES.STOP
      elif method == "file":
          return "[[" + text + "]]"
  
imports: import re
  import string
  import flair
  import jieba
  from .importing import LazyLoader
label_desc: Use image node_id 9 for calling a global function with example usage: color_text(text, color, method) and returns: text, str, color, str, text, str, unknown, unknown