class_docstr: Minimal Runner with support for online command output processing
  
  It aims to be as simple as possible, providing only essential
  functionality.
class_docstr_tok: ["Minimal","Runner","with","support","for","online","command","output","processing","It","aims","to","be","as","simple","as","possible",",","providing","only","essential","functionality","."]
docstr: Return an adjusted execution environment
  
  This method adjusts the environment provided in `env` to
  reflect the configuration of the runner. It returns
  an altered copy or an altered original, if `copy` is
  `False`.
  
  Parameters
  ----------
  env
    The environment that should be adjusted
  
  cwd: str | PathLike | None (default: None)
    If not None, the content of this variable will be
    put into the environment variable 'PWD'.
  
  copy: bool (default: True)
    if True, the returned environment will be a
    copy of `env`. Else the passed in environment
    is modified. Note: if `env` is not `None` and
    `cwd` is `None` and `copy` is `True`, the
    returned dictionary is still a copy
docstr_tok: ["Return","an","adjusted","execution","environment","This","method","adjusts","the","environment","provided","in","`","env","`","to","reflect","the","configuration","of","the","runner",".","It","returns","an","altered","copy","or","an","altered","original",",","if","`","copy","`","is","`","False","`",".","Parameters","--","--","--","--","--","env","The","environment","that","should","be","adjusted","cwd",":","str","|","PathLike","|","None","(","default",":","None",")","If","not","None",",","the","content","of","this","variable","will","be","put","into","the","environment","variable","'PWD","'",".","copy",":","bool","(","default",":","True",")","if","True",",","the","returned","environment","will","be","a","copy","of","`","env","`",".","Else","the","passed","in","environment","is","modified",".","Note",":","if","`","env","`","is","not","`","None","`","and","`","cwd","`","is","`","None","`","and","`","copy","`","is","`","True","`",",","the","returned","dictionary","is","still","a","copy"]
code: def _get_adjusted_env(
      self,
      env: dict | None = None,
      cwd: str | PathLike | None = None,
      copy: bool = True,
  ) -> dict | None:
      """Return an adjusted execution environment
  
      This method adjusts the environment provided in `env` to
      reflect the configuration of the runner. It returns
      an altered copy or an altered original, if `copy` is
      `False`.
  
      Parameters
      ----------
      env
        The environment that should be adjusted
  
      cwd: str | PathLike | None (default: None)
        If not None, the content of this variable will be
        put into the environment variable 'PWD'.
  
      copy: bool (default: True)
        if True, the returned environment will be a
        copy of `env`. Else the passed in environment
        is modified. Note: if `env` is not `None` and
        `cwd` is `None` and `copy` is `True`, the
        returned dictionary is still a copy
      """
      env = env.copy() if env is not None and copy is True else env
      if cwd is not None and env is not None:
          # If an environment and 'cwd' is provided, ensure the 'PWD' in the
          # environment is set to the value of 'cwd'.
          env["PWD"] = str(cwd)
      return env
  
file_path: datalad/datalad/runner/runner.py
imports: from __future__ import annotations
  import logging
  from os import PathLike
  from queue import Queue
  from typing import IO, cast
  from .protocol import WitlessProtocol
  from .coreprotocols import NoCapture
  from .exception import CommandError
  from .nonasyncrunner import ThreadedRunner, _ResultGenerator
  from .protocol import GeneratorMixIn
label_desc: Use image node_id 2 for calling the WitlessRunner obj's underlying member method code with example usage: obj._get_adjusted_env(env, cwd, copy) and returns: env