From 69669720f4ef3b3258364059f22ccf31d75418d6 Mon Sep 17 00:00:00 2001 From: florisvdh Date: Wed, 2 Sep 2020 09:09:07 +0200 Subject: [PATCH] Drop assertthat and dplyr dependencies --- DESCRIPTION | 2 +- NAMESPACE | 2 -- R/ZenodoRecord.R | 4 ++-- R/zen4R.R | 2 -- R/zen4R_downloader.R | 9 ++------- 5 files changed, 5 insertions(+), 14 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 297c807..26dd8b7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -10,7 +10,7 @@ Authors@R: c( person("Floris", "Vanderhaeghe", role = c("ctb"), comment = c(ORCID = "0000-0002-6378-6229"))) Maintainer: Emmanuel Blondel Depends: R (>= 3.3.0), methods -Imports: R6, httr, jsonlite, xml2, keyring, tools, assertthat, dplyr, parallel +Imports: R6, httr, jsonlite, xml2, keyring, tools, parallel Suggests: testthat Description: Provides an Interface to 'Zenodo' () REST API, including management of depositions, attribution of DOIs by 'Zenodo' and diff --git a/NAMESPACE b/NAMESPACE index 6f1333c..ffb0212 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -12,8 +12,6 @@ import(keyring) import(methods) import(xml2) importFrom(R6,R6Class) -importFrom(assertthat,assert_that) -importFrom(dplyr,"%>%") importFrom(parallel,mclapply) importFrom(tools,file_path_as_absolute) importFrom(tools,md5sum) diff --git a/R/ZenodoRecord.R b/R/ZenodoRecord.R index 0557e70..1a74144 100644 --- a/R/ZenodoRecord.R +++ b/R/ZenodoRecord.R @@ -1158,13 +1158,13 @@ ZenodoRecord <- R6Class("ZenodoRecord", }else{ files_summary <- sprintf("Will download %s file%s from record '%s' (doi: '%s') - total size: %s", length(self$files), ifelse(length(self$files)>1,"s",""), self$id, self$doi, - sum(sapply(self$files, function(x){x$filesize})) %>% human_filesize()) + human_filesize(sum(sapply(self$files, function(x){x$filesize})))) #download_file util download_file <- function(file){ file$filename <- gsub("/", "_", file$filename) if (!quiet) cat(sprintf("[zen4R][INFO] Downloading file '%s' - size: %s\n", - file$filename, file$filesize %>% human_filesize())) + file$filename, human_filesize(file$filesize))) target_file <-file.path(path, file$filename) download.file(url = file$links$download, destfile = target_file, quiet = quiet, mode = "wb") diff --git a/R/zen4R.R b/R/zen4R.R index 2ea0339..02517f6 100644 --- a/R/zen4R.R +++ b/R/zen4R.R @@ -11,8 +11,6 @@ #' @import keyring #' @importFrom tools file_path_as_absolute #' @importFrom tools md5sum -#' @importFrom assertthat assert_that -#' @importFrom dplyr %>% #' @importFrom parallel mclapply #' #' @title Interface to 'Zenodo' REST API diff --git a/R/zen4R_downloader.R b/R/zen4R_downloader.R index bad22f7..057e552 100644 --- a/R/zen4R_downloader.R +++ b/R/zen4R_downloader.R @@ -63,12 +63,7 @@ download_zenodo = function(doi, path = ".", logger = NULL, quiet = FALSE, ...){ #' @keywords internal #' human_filesize <- function(x) { - assert_that(is.numeric(x)) - assert_that(all(x %% 1 == 0 & x >= 0)) - magnitude <- - log(x, base = 1024) %>% - floor %>% - pmin(8) + magnitude <- pmin(floor(log(x, base = 1024)), 8) unit <- factor(magnitude, levels = 0:8, labels = c( @@ -82,6 +77,6 @@ human_filesize <- function(x) { "ZiB", "YiB") ) - size <- (x / 1024^magnitude) %>% round(1) + size <- round(x / 1024^magnitude, 1) return(paste(size, unit)) } \ No newline at end of file