| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
jupyter_option_defaults <- list( |
| 7 |
jupyter.rich_display = TRUE, |
| 8 |
jupyter.log_level = 1L, |
| 9 |
jupyter.logfile = NA, |
| 10 |
jupyter.pager_classes = c( |
| 11 |
'packageIQR', |
| 12 |
'help_files_with_topic'), |
| 13 |
jupyter.plot_mimetypes = c( |
| 14 |
'text/plain', |
| 15 |
'image/png'), |
| 16 |
jupyter.plot_scale = 2, |
| 17 |
jupyter.in_kernel = FALSE) |
| 18 |
|
| 19 |
from_env <- list( |
| 20 |
JUPYTER_LOG_LEVEL = as.integer, |
| 21 |
JUPYTER_LOGFILE = function(f) if (nchar(f) == 0) NA else f) |
| 22 |
|
| 23 |
|
| 24 |
opt_to_env <- function(nms) gsub('.', '_', toupper(nms), fixed = TRUE) |
| 25 |
|
| 26 |
|
| 27 |
init_options <- function() { |
| 28 |
for (opt_name in names(jupyter_option_defaults)) { |
| 29 |
|
| 30 |
if (is.null(getOption(opt_name))) { |
| 31 |
|
| 32 |
call_arg <- jupyter_option_defaults[opt_name] |
| 33 |
|
| 34 |
|
| 35 |
env_name <- opt_to_env(opt_name) |
| 36 |
convert <- from_env[[env_name]] |
| 37 |
env_val <- Sys.getenv(env_name, unset = NA) |
| 38 |
if (!is.null(convert) && !is.na(env_val)) |
| 39 |
call_arg[[opt_name]] <- convert(env_val) |
| 40 |
|
| 41 |
do.call(options, call_arg) |
| 42 |
} |
| 43 |
} |
| 44 |
} |