code: def configuration(action, scope, specs, res_kwargs, ds=None):
      if scope == "global" or (action == "dump" and ds is None):
          cfg = dlcfg
      else:
          cfg = ds.config
  
      if action not in config_actions:
          raise ValueError("Unsupported action '{}'".format(action))
  
      if action == "dump":
          if not specs:
              # dumping is querying for all known keys
              specs = [
                  (n,)
                  for n in sorted(
                      set(cfg_defs.keys()).union(cfg.keys())
                  )
              ]
          scope = None
  
      for spec in specs:
          if "." not in spec[0]:
              yield get_status_dict(
                  ds=ds,
                  status="error",
                  message=(
                      "Configuration key without a section: '%s'",
                      spec[0],
                  ),
                  **res_kwargs,
              )
              continue
          # TODO without get-all there is little sense in having add
          # if action == 'add':
          #    res = _add(cfg, scope, spec)
          if action == "get":
              res = _get(cfg, scope, spec[0])
          elif action == "dump":
              res = _dump(cfg, spec[0])
          # TODO this should be there, if we want to be comprehensive
          # however, we turned this off by default in the config manager
          # because we hardly use it, and the handling in ConfigManager
          # is not really well done.
          # elif action == 'get-all':
          #    res = _get_all(cfg, scope, spec)
          elif action == "set":
              res = _set(cfg, scope, *spec)
          elif action == "unset":
              res = _unset(cfg, scope, spec[0])
  
          if ds:
              res["path"] = ds.path
  
          if "status" not in res:
              res["status"] = "ok"
  
          yield dict(res_kwargs, **res)
  
      if action in ("add", "set", "unset"):
          # we perform a single reload, rather than one for each modification
          # TODO: can we detect a call from cmdline? We could skip the reload.
          cfg.reload(force=True)
  
imports: import logging
  from textwrap import wrap
  import datalad.support.ansi_colors
  from datalad import cfg
  from datalad.distribution.dataset import Dataset, EnsureDataset, datasetmethod, require_dataset
  from datalad.interface.base import Interface, build_doc, eval_results
  from datalad.interface.common_cfg import definitions
  from datalad.interface.common_opts import recursion_flag, recursion_limit
  from datalad.interface.results import get_status_dict
  from datalad.interface.utils import default_result_renderer
  from datalad.support.constraints import EnsureChoice, EnsureNone
  from datalad.support.exceptions import CommandError, NoDatasetFound
  from datalad.support.param import Parameter
  from datalad.utils import Path, ensure_list
label_desc: Use image node_id 1 for calling a global function with example usage: configuration(action, scope, specs, res_kwargs, ds) without return types