class_docstr: Clean up after DataLad (possible temporary files etc.)
  
  Removes temporary files and directories left behind by DataLad and
  git-annex in a dataset.
class_docstr_tok: ["Clean","up","after","DataLad","(","possible","temporary","files","etc",".",")","Removes","temporary","files","and","directories","left","behind","by","DataLad","and","git-annex","in","a","dataset","."]
code: def custom_result_renderer(res, **kwargs):  # pragma: more cover
      # Don't render things like 'status' for clean-info messages -
      # seems rather meaningless.
  
      from os import getcwd
  
      import datalad.support.ansi_colors as ac
      from datalad.interface.utils import generic_result_renderer
      from datalad.utils import Path
  
      if res["action"] == "clean":
          # default renderer is just fine
          return generic_result_renderer(res)
      elif res["action"] != "clean [dry-run]":
          # Result didn't come from within `clean`.
          # Should be handled elsewhere.
          return
  
      assert res["action"] == "clean [dry-run]"
  
      if res.get("status", None) == "ok":
          from datalad.ui import ui
  
          # when to render relative paths:
          #  1) if a dataset arg was given
          #  2) if CWD is the refds
  
          refds = res.get("refds", None)
          refds = (
              refds
              if kwargs.get("dataset", None) is not None
              or refds == getcwd()
              else None
          )
          path = (
              res["path"]
              if refds is None
              else str(Path(res["path"]).relative_to(refds))
          )
  
          ui.message(
              "{path}: {message}".format(
                  path=ac.color_word(path, ac.BOLD),
                  message=(
                      res["message"][0] % res["message"][1:]
                      if isinstance(res["message"], tuple)
                      else res["message"]
                  )
                  if res.get("message", None)
                  else "",
              )
          )
  
      else:
          # Any other status than 'ok' is reported the default way.
          return generic_result_renderer(res)
  
file_path: datalad/datalad/local/clean.py
imports: import itertools
  from logging import getLogger
  from datalad.consts import ANNEX_TEMP_DIR, ANNEX_TRANSFER_DIR, ARCHIVES_TEMP_DIR, SEARCH_INDEX_DOTGITDIR
  from datalad.distribution.dataset import EnsureDataset, datasetmethod, require_dataset
  from datalad.interface.base import Interface, build_doc, eval_results
  from datalad.interface.common_opts import recursion_flag, recursion_limit
  from datalad.interface.results import get_status_dict
  from datalad.support.constraints import EnsureChoice, EnsureNone
  from datalad.support.param import Parameter
  from datalad.utils import Path, rmtree
label_desc: Use image node_id 2 for calling the Clean obj's underlying member method code with example usage: obj.custom_result_renderer(res) and returns: generic_result_renderer, generic_result_renderer