From 9e196c69f22c58286560fa65cb667721518ca2f7 Mon Sep 17 00:00:00 2001 From: orichters Date: Fri, 21 Jul 2023 14:26:35 +0200 Subject: [PATCH] explain checkFixCfg() --- scripts/start/checkFixCfg.R | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/start/checkFixCfg.R b/scripts/start/checkFixCfg.R index dfa0e7f58..d8293e693 100644 --- a/scripts/start/checkFixCfg.R +++ b/scripts/start/checkFixCfg.R @@ -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"), @@ -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'