-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add/xml-upgrades/v11
- Loading branch information
Showing
8 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#' @title Generate STICS general parameters xml file(s) from a template | ||
#' file according to a STICS version | ||
#' | ||
# @param param_df A table (df, tibble) containing the values of the parameters | ||
# to use (see details) | ||
# @param file Path of a sta xml file to be used as a template. Optional, | ||
# if not provided, the function will use a standard template depending | ||
# on the STICS version. | ||
#' @param out_dir Path of the directory where to generate the file(s). | ||
#' @param stics_version Name of the STICS version. Optional, the latest one | ||
#' is used as default | ||
#' @param overwrite Optional logical, TRUE for overwriting files, | ||
#' FALSE otherwise (default) | ||
#' | ||
#' @details Please see `get_stics_versions_compat()` for the full list of | ||
#' STICS versions that can be used for the argument `stics_version`. | ||
#' | ||
#' @return None | ||
#' | ||
#' @examples | ||
#' gen_general_param_xml(out_dir = tempdir()) | ||
#' | ||
#' gen_general_param_xml(out_dir = tempdir(), | ||
#' stics_version = "V10.0", | ||
#' overwrite = TRUE) | ||
#' | ||
#' @export | ||
#' | ||
gen_general_param_xml <- function(out_dir, | ||
stics_version = "latest", | ||
overwrite = FALSE) { | ||
|
||
|
||
# check/get version | ||
stics_version <- get_xml_stics_version( | ||
stics_version = stics_version | ||
) | ||
|
||
# getting dir path of templates | ||
files_dir <- get_examples_path(file_type = "xml", | ||
stics_version = stics_version) | ||
|
||
# Copying files to out_dir | ||
files_name <- c("param_gen.xml", "param_newform.xml") | ||
xml_files <- file.path(files_dir, files_name) | ||
|
||
copy_status <- file.copy(xml_files, out_dir, overwrite = overwrite) | ||
|
||
if (!all(copy_status)) | ||
stop("Some error occured while copying files: \n", | ||
paste(files_name[!copy_status], collapse = ", \n"), | ||
"\nConsider setting overwrite to TRUE as function additional input") | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
context("Generating xml general parameters files") | ||
|
||
gen_general_param_xml(out_dir = tempdir()) | ||
|
||
files <- c("param_gen.xml", "param_newform.xml") | ||
|
||
test_that("latest version", { | ||
expect_true(all(file.exists(file.path(tempdir(), files)))) | ||
expect_error(gen_general_param_xml(out_dir = tempdir())) | ||
expect_no_error(gen_general_param_xml(out_dir = tempdir(), overwrite = TRUE)) | ||
}) | ||
|
||
|
||
|
||
test_that("other version", { | ||
expect_no_error(gen_general_param_xml(out_dir = tempdir(), | ||
stics_version = "V10.0", | ||
overwrite = TRUE)) | ||
expect_true(all(file.exists(file.path(tempdir(), files)))) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters