Skip to content

Commit

Permalink
explain checkFixCfg()
Browse files Browse the repository at this point in the history
  • Loading branch information
orichters committed Jul 21, 2023
1 parent 1b9d214 commit 9e196c6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scripts/start/checkFixCfg.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
#' take a REMIND cfg, runs some consistency checks and automatically fix some wrong settings
#' The regexp check loads the code from main.gms and looks for 'regexp = ' patterns.
#' It then checks whether the current cfg matches those patterns.
#'
#' @param cfg list with REMIND setting
#' @param remindPath path to REMIND directory containing the main.gms
#' @param testmode boolean. Default is FALSE which fails on errors, in testmode only raise warnings
#' @author Oliver Richters
#' @return updated cfg
checkFixCfg <- function(cfg, remindPath = ".", testmode = FALSE) {
refcfg <- gms::readDefaultConfig(remindPath)
gms::check_config(cfg, reference_file = refcfg, modulepath = file.path(remindPath, "modules"),
Expand All @@ -8,6 +17,7 @@ checkFixCfg <- function(cfg, remindPath = ".", testmode = FALSE) {

errorsfound <- 0

## regexp check
# extract all instances of 'regexp' from main.gms
code <- system(paste0("grep regexp ", file.path(remindPath, "main.gms")), intern = TRUE)
# this is used to replace all 'regexp = is.numeric'
Expand Down

0 comments on commit 9e196c6

Please sign in to comment.