import adulib.utils as this_moduleutils
General utility functions.
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
set_func_defaults
set_func_defaults(func, target_dict)Set default values of a function’s parameters into a target dictionary.
Meant to be used with function notebooks in nblite to set up test arguments.
Arguments: - func (callable): The function whose defaults are to be set. - target_dict (dict): The dictionary where defaults will be set.
def foo(my_variable1="hello", my_variable2="world"):
pass
set_func_defaults(foo, locals())
print(my_variable1, my_variable2)hello world