code: def get_config():
      """
      Get ipdb config file settings.
      All available config files are read.  If settings are in multiple configs,
      the last value encountered wins.  Values specified on the command-line take
      precedence over all config file settings.
      Returns: A ConfigParser object.
      """
      parser = configparser.ConfigParser()
  
      filepaths = []
  
      # Low priority goes first in the list
      for cfg_file in ("setup.cfg", ".ipdb", "pyproject.toml"):
          cwd_filepath = os.path.join(os.getcwd(), cfg_file)
          if os.path.isfile(cwd_filepath):
              filepaths.append(cwd_filepath)
  
      # Medium priority (whenever user wants to set a specific path to config file)
      home = os.getenv("HOME")
      if home:
          default_filepath = os.path.join(home, ".ipdb")
          if os.path.isfile(default_filepath):
              filepaths.append(default_filepath)
  
      # High priority (default files)
      env_filepath = os.getenv("IPDB_CONFIG")
      if env_filepath and os.path.isfile(env_filepath):
          filepaths.append(env_filepath)
  
      if filepaths:
          # Python 3 has parser.read_file(iterator) while Python2 has
          # parser.readfp(obj_with_readline)
          try:
              read_func = parser.read_file
          except AttributeError:
              read_func = parser.readfp
          for filepath in filepaths:
              parser.filepath = filepath
              # Users are expected to put an [ipdb] section
              # only if they use setup.cfg
              if filepath.endswith("setup.cfg"):
                  with open(filepath) as f:
                      parser.remove_section("ipdb")
                      read_func(f)
              # To use on pyproject.toml, put [tool.ipdb] section
              elif filepath.endswith("pyproject.toml"):
                  try:
                      import tomllib
  
                      file_mode = "rb"
                  except ImportError:
                      try:
                          import tomli as tomllib
  
                          file_mode = "rb"
                      except ImportError:
                          import toml as tomllib
  
                          file_mode = "r"
                  with open(filepath, file_mode) as f:
                      toml_file = tomllib.load(f)
                      if (
                          "tool" in toml_file
                          and "ipdb" in toml_file["tool"]
                      ):
                          if not parser.has_section("ipdb"):
                              parser.add_section("ipdb")
                          for key, value in toml_file["tool"][
                              "ipdb"
                          ].items():
                              parser.set("ipdb", key, str(value))
              else:
                  read_func(ConfigFile(filepath))
      return parser
  
imports: from __future__ import print_function
  import os
  import sys
  from decorator import contextmanager
  from IPython import get_ipython
  from IPython.core.debugger import BdbQuit_excepthook
  from IPython.terminal.ipapp import TerminalIPythonApp
  from IPython.terminal.embed import InteractiveShellEmbed
label_desc: Use image node_id 6 for calling a global function with example usage: get_config() and returns: parser