utils

General utility functions.

import adulib.utils as this_module

as_dict

as_dict(**kwargs)

Convert keyword arguments to a dictionary.


check_mutual_exclusivity

check_mutual_exclusivity(*args)

Check if only one of the arguments is falsy (or truthy, if check_falsy is False).


run_script

run_script(
   script_path: Path,
   cwd: Path,
   env: dict,
   interactive: bool,
   raise_on_error: bool
)

Execute a Python or Bash script with specified parameters and environment variables.

Arguments: - script_path (Path): Path to the script file to execute (.py or .sh) - cwd (Path): Working directory for script execution. Defaults to None. - env (dict): Additional environment variables to pass to the script. Defaults to None. - interactive (bool): Whether to run the script in interactive mode. Defaults to False. - raise_on_error (bool): Whether to raise an exception on non-zero exit code. Defaults to True.

Returns: tuple: A tuple containing: - int: Return code from the script execution - str or None: Standard output (None if interactive mode) - bytes: Contents of the temporary output file