1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-09 12:21:59 +02:00

(v1.7.1.9070) Better WHONET support

This commit is contained in:
2021-12-13 10:18:28 +01:00
parent f90e27c1b0
commit 578e7dfee9
74 changed files with 20758 additions and 47402 deletions

View File

@ -1096,14 +1096,30 @@ progress_ticker <- function(n = 1, n_min = 0, print = TRUE, ...) {
}
set_clean_class(pb, new_class = "txtProgressBar")
} else if (n >= n_min) {
pb <- utils::txtProgressBar(max = n, style = 3)
pb$tick <- function() {
pb$up(pb$getVal() + 1)
# rely on the progress package if it is available - it has a more verbose output
progress_bar <- import_fn("progress_bar", "progress", error_on_fail = FALSE)
if (!is.null(progress_bar)) {
# so we use progress::progress_bar
# a close() method was also added, see below this function
pb <- progress_bar$new(format = "[:bar] :percent (:current/:total)",
total = n)
} else {
pb <- utils::txtProgressBar(max = n, style = 3)
pb$tick <- function() {
pb$up(pb$getVal() + 1)
}
}
pb
}
}
#' @method close progress_bar
#' @export
#' @noRd
close.progress_bar <- function(con, ...) {
con$terminate()
}
set_clean_class <- function(x, new_class) {
# return the object with only the new class and no additional attributes where possible
if (is.null(x)) {