Skip to content

Commit

Permalink
fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pfuehrlich-pik committed Jul 20, 2023
1 parent 88164ef commit ccebf7c
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '8712610'
ValidationKey: '8742426'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'lucode2: Code Manipulation and Analysis Tools'
version: 0.44.6
date-released: '2023-06-27'
version: 0.44.7
date-released: '2023-07-20'
abstract: A collection of tools which allow to manipulate and analyze code.
authors:
- family-names: Dietrich
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: lucode2
Title: Code Manipulation and Analysis Tools
Version: 0.44.6
Date: 2023-06-27
Version: 0.44.7
Date: 2023-07-20
Authors@R: c(
person("Jan Philipp", "Dietrich", , "[email protected]", role = c("aut", "cre")),
person("Pascal", "Führlich", role = "aut"),
Expand Down
22 changes: 11 additions & 11 deletions R/buildLibrary.R
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,17 @@ handleUpdateType <- function(updateType = NULL, title = "Please choose an update
if (!is.null(updateType)) {
# convert character updateType parameters to numbers
updateType <- switch(as.character(updateType),
"major" = 1,
"1" = 1,
"minor" = 2,
"2" = 2,
"patch" = 3,
"3" = 3,
"development" = 4,
"4" = 4,
"none" = 0,
"0" = 0,
handleUpdateType(title = title))
"major" = 1,
"1" = 1,
"minor" = 2,
"2" = 2,
"patch" = 3,
"3" = 3,
"development" = 4,
"4" = 4,
"none" = 0,
"0" = 0,
handleUpdateType(title = title))
return(updateType)
}
updateType <- c("major revision (for major rewrite of the whole package)",
Expand Down
4 changes: 2 additions & 2 deletions R/checkRepoUpToDate.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ checkRepoUpToDate <- function(pathToRepo = ".", autoCheckRepoUpToDate = TRUE) {
# check whether we are merging
gitStatus <- system2("git", "status", stdout = TRUE)
if ("You have unmerged paths." %in% gitStatus ||
"All conflicts fixed but you are still merging." %in% gitStatus) {
"All conflicts fixed but you are still merging." %in% gitStatus) {
# gert::git_ahead_behind will say we are behind during merge, so cannot use auto check
message("Automatic repo up-to-date check does not work during merge.")
askUpToDate()
Expand Down Expand Up @@ -69,7 +69,7 @@ checkRepoUpToDate <- function(pathToRepo = ".", autoCheckRepoUpToDate = TRUE) {
}
if (behindUpstream > 0) {
errorMessage <- paste0(errorMessage, "\nYou are ", behindUpstream, " commits behind upstream. ",
"Please run:\ngit pull upstream ", usethis::git_default_branch())
"Please run:\ngit pull upstream ", usethis::git_default_branch())
}
stop(errorMessage)
} else {
Expand Down
6 changes: 2 additions & 4 deletions R/citationDoi.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ citationDoi <- function(meta) {
tmp <- strsplit(cit$note, ",[ \n]*")[[1]]
urls <- grep("http", tmp, value = TRUE)
cit$note <- paste0(grep("http", tmp, value = TRUE, invert = TRUE), collapse = ", ")
cit$doi <- gsub(
"\n", "", gsub(
"https://doi.org/", "", grep(
"doi.org", urls, fixed = TRUE, value = TRUE), fixed = TRUE))
cit$doi <- gsub("\n", "", gsub("https://doi.org/", "",
grep("doi.org", urls, fixed = TRUE, value = TRUE), fixed = TRUE))
cit$url <- c(cit$url, grep("doi.org", urls, fixed = TRUE, value = TRUE, invert = TRUE))
if (cit$note == "") cit$note <- paste("R package version", meta$Version)
if (!length(cit$url)) cit$url <- NULL
Expand Down
4 changes: 2 additions & 2 deletions R/conditionalCopy.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ conditionalCopy <- function(relativePath, nameInInstExtdata = basename(relativeP
dir.create(dirname(relativePath), recursive = TRUE, showWarnings = FALSE)
if (desc("DESCRIPTION")$get("Package") == "lucode2") {
if (file.exists(instExtdataPath) && md5sum(relativePath) != md5sum(instExtdataPath) &&
(!interactive() || (requireNamespace("testthat", quietly = TRUE) && testthat::is_testing()) ||
!askYesNo(paste0("Replace ", instExtdataPath, " with ", relativePath, "?")))) {
(!interactive() || (requireNamespace("testthat", quietly = TRUE) && testthat::is_testing()) ||
!askYesNo(paste0("Replace ", instExtdataPath, " with ", relativePath, "?")))) {
stop(relativePath, " != ", instExtdataPath)
}
file.copy(relativePath, instExtdataPath, overwrite = TRUE)
Expand Down
2 changes: 1 addition & 1 deletion R/extract_arguments.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extract_arguments <- function(inputArg) { # nolint
}
if (length(strsplit(inputArg, ":")[[1]]) == 2) {
if (suppressWarnings(is.na(as.integer(strsplit(inputArg, ":")[[1]][1])) |
is.na(as.integer(strsplit(inputArg, ":")[[1]][2])))) {
is.na(as.integer(strsplit(inputArg, ":")[[1]][2])))) {
extractedArguments <- inputArg
} else {
extractedArguments <- as.integer(strsplit(inputArg, ":")[[1]][1]):as.integer(strsplit(inputArg, ":")[[1]][2])
Expand Down
23 changes: 10 additions & 13 deletions R/manipulateConfig.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,16 @@ manipulateConfig <- function(configFile, ...) {
rpl <- tmp[[i]]
}

m[[paste(i, "_pattern1", sep = "")]][1] <- paste(
"(\\$[sS][eE][tT][gG][lL][oO][bB][aA][lL][\\t ]*", i, "[\\t ]).*?( *!!|\\n|$)", sep = "")
m[[paste(i, "_pattern1", sep = "")]][2] <- paste(
"\\1 ", rpl, "\\2", sep = "")
m[[paste(i, "_pattern2", sep = "")]][1] <- paste(
"((\\n|^)[\\t ]*(scalar|parameter|set|)s?[\\t ]*", i, "(|\\([^\\)]*\\))(/|[\\t ]+(\"[^\"]*\"|)[^\"/;]*/))[^/]*",
sep = "")
m[[paste(i, "_pattern2", sep = "")]][2] <- paste(
"\\1 ", rpl, " ", sep = "")
m[[paste(i, "_pattern3", sep = "")]][1] <- paste(
"((^|[\\n\\t ])", i, "[ \\t]*=[ \\t]*[\"\']?)[^\"\';]*", sep = "")
m[[paste(i, "_pattern3", sep = "")]][2] <- paste(
"\\1", rpl, sep = "")
m[[paste(i, "_pattern1", sep = "")]][1] <- paste("(\\$[sS][eE][tT][gG][lL][oO][bB][aA][lL][\\t ]*",
i, "[\\t ]).*?( *!!|\\n|$)", sep = "")
m[[paste(i, "_pattern1", sep = "")]][2] <- paste("\\1 ", rpl, "\\2", sep = "")
m[[paste(i, "_pattern2", sep = "")]][1] <- paste("((\\n|^)[\\t ]*(scalar|parameter|set|)s?[\\t ]*",
i, "(|\\([^\\)]*\\))(/|[\\t ]+(\"[^\"]*\"|)[^\"/;]*/))[^/]*",
sep = "")
m[[paste(i, "_pattern2", sep = "")]][2] <- paste("\\1 ", rpl, " ", sep = "")
m[[paste(i, "_pattern3", sep = "")]][1] <- paste("((^|[\\n\\t ])", i, "[ \\t]*=[ \\t]*[\"\']?)[^\"\';]*",
sep = "")
m[[paste(i, "_pattern3", sep = "")]][2] <- paste("\\1", rpl, sep = "")
}
} else if (type %in% c("cfg", "R", "r")) {
for (i in names(tmp)) {
Expand Down
8 changes: 4 additions & 4 deletions R/mergestatistics.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ mergestatistics <- function(dir = ".", file = NULL, renew = FALSE, quickcheck =
}
stats$solution <- modelstat
stats$id <- gsub("\\.[rR]da", "", f)
outlist[[stats$id]] <- as.data.table(t(unlist(c(
stats[c("user", "date", "version_management", "revision", "revision_date", "solution")],
runtime = as.numeric(stats[["runtime"]], units = "hours"),
stats$config[!(names(stats$config) %in% removeCols)]))))
outlist[[stats$id]] <- as.data.table(t(unlist(c(stats[c("user", "date", "version_management",
"revision", "revision_date", "solution")],
runtime = as.numeric(stats[["runtime"]], units = "hours"),
stats$config[!(names(stats$config) %in% removeCols)]))))
}
out <- rbind(out, rbindlist(outlist, fill = TRUE, idcol = TRUE), fill = TRUE)
out <- as.data.table(lapply(out, function(x) return(type.convert(as.character(x), as.is = TRUE))))
Expand Down
4 changes: 1 addition & 3 deletions R/package2readme.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ package2readme <- function(package = ".", add = NULL, logo = NULL) { # nolint
if (!is.null(folder)) {
try({
projectPath <- normalizePath(folder, mustWork = TRUE, winslash = "/")
ci <- citationDoi(packageDescription(
basename(projectPath),
lib.loc = dirname(projectPath)))
ci <- citationDoi(packageDescription(basename(projectPath), lib.loc = dirname(projectPath)))
})
}
# If previous code did not work or folder is not set, get citation from installed package.
Expand Down
11 changes: 5 additions & 6 deletions R/packageInfo.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ packageInfo <- function(package, repos = c("https://cran.rstudio.com/",
installed <- "<never>"
} else {
version <- as.character(version)
installed <- paste(
as.integer(difftime(Sys.time(), file.mtime(system.file("DESCRIPTION", package = package)), units = "mins")),
"minutes ago")
installed <- paste(as.integer(difftime(Sys.time(),
file.mtime(system.file("DESCRIPTION", package = package)), units = "mins")),
"minutes ago")
}

cat("\nPackage:", package, "\n")
Expand All @@ -31,9 +31,8 @@ packageInfo <- function(package, repos = c("https://cran.rstudio.com/",
cat("Availability in repositories:\n")
v <- list()
for (r in repos) {
v$r <- tryCatch(
available.packages(file.path(r, "src", "contrib"))[package, "Version"],
error = function(e) return("<not available>"))
v$r <- tryCatch(available.packages(file.path(r, "src", "contrib"))[package, "Version"],
error = function(e) return("<not available>"))
cat(v$r, "|", r, "\n")
}
cat("\n")
Expand Down
8 changes: 4 additions & 4 deletions R/readArgs.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@
#'
#' ### function that reads all allowed arguments from command line ###
readArgs <- function(..., .argv = commandArgs(trailingOnly = TRUE),
.envir = parent.frame(), .flags = NULL, .silent = FALSE) {
.envir = parent.frame(), .flags = NULL, .silent = FALSE) {
allowedArgs <- c(...)
# search for strings that look like -i1asrR and transform them into long flags
oneDashFlags <- unlist(strsplit(paste0(.argv[grepl("^-[a-zA-Z0-9]*$", .argv)], collapse = ""), split = ""))
twoDashFlags <- .argv[grepl("^--[a-zA-Z0-9]*$", .argv) & .argv %in% .flags]
knownFlags <- sort(unique(c(twoDashFlags, unlist(.flags[names(.flags) %in% oneDashFlags]))))
unknownFlags <- c(sort(paste0("-", oneDashFlags)[! oneDashFlags %in% c(names(.flags), "-")]),
.argv[grepl("^--[a-zA-Z0-9]*$", .argv) & ! .argv %in% .flags])
.argv <- .argv[! grepl("^-", .argv)]
unknownFlags <- c(sort(paste0("-", oneDashFlags)[!oneDashFlags %in% c(names(.flags), "-")]),
.argv[grepl("^--[a-zA-Z0-9]*$", .argv) & !.argv %in% .flags])
.argv <- .argv[!grepl("^-", .argv)]
if (length(.argv) > 0) {
### apply additional command line arguments ###
for (argnr in seq_along(.argv)) {
Expand Down
8 changes: 4 additions & 4 deletions R/readRuntime.R
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ readRuntime <- function(path, plot = FALSE, types = NULL, coupled = FALSE, outfn
}

pSorted <- ggplot2::ggplot(data = runtime,
ggplot2::aes_string(x = "run",
y = "value",
fill = ifelse(is.null(types), "NULL", "type"))) +
ggplot2::aes_string(x = "run",
y = "value",
fill = ifelse(is.null(types), "NULL", "type"))) +
ggplot2::geom_bar(colour = "black", stat = "identity") +
ggplot2::coord_flip() +
ggplot2::ylab(yUnit) +
Expand All @@ -225,7 +225,7 @@ readRuntime <- function(path, plot = FALSE, types = NULL, coupled = FALSE, outfn
section = factor(.data$section, levels = c("total", "prep", "GAMS", "output"), ordered = TRUE))

pTimeline <- ggplot2::ggplot(dat, ggplot2::aes_string(color = ifelse(is.null(types), "NULL", "type"),
alpha = "section")) +
alpha = "section")) +
ggplot2::geom_segment(ggplot2::aes_string(x = "start", xend = "end", y = "run", yend = "run"), size = 6) +
ggplot2::scale_alpha_manual(values = c("total" = 1, "prep" = 0.5, "GAMS" = 1, "output" = 0.5)) +
ggplot2::scale_color_manual(values = c("rem" = "royalblue3", "mag" = "seagreen")) +
Expand Down
10 changes: 5 additions & 5 deletions R/updateRepo.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ updateRepo <- function(path = ".", check = TRUE, forceRebuild = FALSE, clean = T
repoPaths <- list.dirs(path, recursive = FALSE)
packageNames <- basename(repoPaths)
repoPaths <- repoPaths[!startsWith(packageNames, ".") &
!(packageNames %in% skipFolders) &
dir.exists(file.path(repoPaths, ".git"))]
!(packageNames %in% skipFolders) &
dir.exists(file.path(repoPaths, ".git"))]
repoPaths <- repoPaths[order(tolower(repoPaths))]

collectedErrors <- lapply(repoPaths, function(repoPath) {
Expand Down Expand Up @@ -87,8 +87,8 @@ updateRepo <- function(path = ".", check = TRUE, forceRebuild = FALSE, clean = T

# add metadata such as remote url to DESCRIPTION e.g. for renv
remoteUrl <- sub("git@github\\.com:(.+)\\.git",
"https://github.com/\\1",
gert::git_remote_info(repo = repoPath)$url)
"https://github.com/\\1",
gert::git_remote_info(repo = repoPath)$url)
cat("Repository: ", repoUrl, "\n",
"RemoteUrl: ", remoteUrl, "\n",
"RemoteRef: HEAD\n",
Expand Down Expand Up @@ -125,7 +125,7 @@ updateRepo <- function(path = ".", check = TRUE, forceRebuild = FALSE, clean = T
if (cranversion > currentVersion && cranversion > newVersion) {
message(" .::WARNING! CRAN: ", availablePackagesOnCran[packageName, "Version"], " !WARNING::.")
stop("Package version of package \"", packageName, "\" is newer on CRAN (", cranversion,
") compared to PIK-CRAN (", currentVersion, ")! Check version on CRAN immediatly!")
") compared to PIK-CRAN (", currentVersion, ")! Check version on CRAN immediatly!")
} else {
message(" .::CRAN: ", availablePackagesOnCran[packageName, "Version"], "::.")
}
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Code Manipulation and Analysis Tools

R package **lucode2**, version **0.44.6**
R package **lucode2**, version **0.44.7**

[![CRAN status](https://www.r-pkg.org/badges/version/lucode2)](https://cran.r-project.org/package=lucode2) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4389418.svg)](https://doi.org/10.5281/zenodo.4389418) [![R build status](https://github.com/pik-piam/lucode2/workflows/check/badge.svg)](https://github.com/pik-piam/lucode2/actions) [![codecov](https://codecov.io/gh/pik-piam/lucode2/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/lucode2) [![r-universe](https://pik-piam.r-universe.dev/badges/lucode2)](https://pik-piam.r-universe.dev/builds)

Expand Down Expand Up @@ -39,7 +39,7 @@ In case of questions / problems please contact Jan Philipp Dietrich <dietrich@pi

To cite package **lucode2** in publications use:

Dietrich J, Führlich P, Klein D, Giannousakis A, Bonsch M, Bodirsky B, Baumstark L, Richters O, Pflüger M (2023). _lucode2: Code Manipulation and Analysis Tools_. doi:10.5281/zenodo.4389418 <https://doi.org/10.5281/zenodo.4389418>, R package version 0.44.6, <https://github.com/pik-piam/lucode2>.
Dietrich J, Führlich P, Klein D, Giannousakis A, Bonsch M, Bodirsky B, Baumstark L, Richters O, Pflüger M (2023). _lucode2: Code Manipulation and Analysis Tools_. doi:10.5281/zenodo.4389418 <https://doi.org/10.5281/zenodo.4389418>, R package version 0.44.7, <https://github.com/pik-piam/lucode2>.

A BibTeX entry for LaTeX users is

Expand All @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is
title = {lucode2: Code Manipulation and Analysis Tools},
author = {Jan Philipp Dietrich and Pascal Führlich and David Klein and Anastasis Giannousakis and Markus Bonsch and Benjamin Leon Bodirsky and Lavinia Baumstark and Oliver Richters and Mika Pflüger},
year = {2023},
note = {R package version 0.44.6},
note = {R package version 0.44.7},
doi = {10.5281/zenodo.4389418},
url = {https://github.com/pik-piam/lucode2},
}
Expand Down
Loading

0 comments on commit ccebf7c

Please sign in to comment.