code: def getcfg(args, config=None):
      """
      Search the list of arguments for a valid ini-file for pytest,
      and return a tuple of (rootdir, inifile, cfg-dict).
  
      note: config is optional and used only to issue warnings explicitly (#2891).
      """
      from _pytest.deprecated import CFG_PYTEST_SECTION
  
      inibasenames = ["pytest.ini", "tox.ini", "setup.cfg"]
      args = [x for x in args if not str(x).startswith("-")]
      if not args:
          args = [py.path.local()]
      for arg in args:
          arg = py.path.local(arg)
          for base in arg.parts(reverse=True):
              for inibasename in inibasenames:
                  p = base.join(inibasename)
                  if exists(p):
                      try:
                          iniconfig = py.iniconfig.IniConfig(p)
                      except py.iniconfig.ParseError as exc:
                          raise UsageError(str(exc))
  
                      if (
                          inibasename == "setup.cfg"
                          and "tool:pytest" in iniconfig.sections
                      ):
                          return base, p, iniconfig["tool:pytest"]
                      elif "pytest" in iniconfig.sections:
                          if (
                              inibasename == "setup.cfg"
                              and config is not None
                          ):
                              fail(
                                  CFG_PYTEST_SECTION.format(
                                      filename=inibasename
                                  ),
                                  pytrace=False,
                              )
                          return base, p, iniconfig["pytest"]
                      elif inibasename == "pytest.ini":
                          # allowed to be empty
                          return base, p, {}
      return None, None, None
  
file_path: catboost/contrib/python/pytest/py2/_pytest/config/findpaths.py
imports: import os
  import py
  from .exceptions import UsageError
  from _pytest.outcomes import fail
label_desc: Use image node_id 2 for calling a global function with example usage: getcfg(args, config) and returns: None,  None,  None, base,  p,  iniconfig, base,  p,  iniconfig, base,  p,  dict