From 59d53f0e4d97c60142fd7553ba5011855228dd9b Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 5 May 2022 20:38:57 -0700 Subject: [PATCH] Functions that take multiple files are auto-quoted by default #55 --- PY2R/automation.py | 13 ++++++++++++- PY2R/scripts/image_analysis.R | 2 +- PY2R/scripts/lidar_analysis.R | 4 ++-- R/image_analysis.R | 2 +- R/lidar_analysis.R | 4 ++-- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/PY2R/automation.py b/PY2R/automation.py index c7f28f455..95b4a5044 100644 --- a/PY2R/automation.py +++ b/PY2R/automation.py @@ -99,7 +99,7 @@ def function_block(line, ff): + "\n" ) ff.write(" }" + "\n") - elif '"' not in para and ("wd" in para or "inputs" in para): + elif '"' not in para and "wd" in para: ff.write(" if (!missing(" + para + ")) {" + "\n") ff.write( ' args <- paste(args, paste0("--' @@ -110,6 +110,17 @@ def function_block(line, ff): + "\n" ) ff.write(" }" + "\n") + elif '"' not in para and "inputs" in para: + ff.write(" if (!is.null(" + para + ")) {" + "\n") + ff.write( + ' args <- paste(args, paste0("--' + + para + + '=", wbt_file_path(' + + para + + ")))" + + "\n" + ) + ff.write(" }" + "\n") elif '"' not in para: ff.write(" if (!is.null(" + para + ")) {" + "\n") ff.write( diff --git a/PY2R/scripts/image_analysis.R b/PY2R/scripts/image_analysis.R index 7a3d6d3f6..84767020a 100644 --- a/PY2R/scripts/image_analysis.R +++ b/PY2R/scripts/image_analysis.R @@ -360,7 +360,7 @@ wbt_mosaic <- function(output, inputs=NULL, method="nn", wd=NULL, verbose_mode=F args <- "" args <- paste(args, paste0("--output=", wbt_file_path(output))) if (!is.null(inputs)) { - args <- paste(args, paste0("--inputs=", inputs)) + args <- paste(args, paste0("--inputs=", wbt_file_path(inputs))) } if (!is.null(method)) { args <- paste(args, paste0("--method=", method)) diff --git a/PY2R/scripts/lidar_analysis.R b/PY2R/scripts/lidar_analysis.R index 1ce64eeef..4292f27d1 100644 --- a/PY2R/scripts/lidar_analysis.R +++ b/PY2R/scripts/lidar_analysis.R @@ -451,7 +451,7 @@ wbt_las_to_zlidar <- function(inputs=NULL, outdir=NULL, compress="brotli", level wbt_init() args <- "" if (!is.null(inputs)) { - args <- paste(args, paste0("--inputs=", inputs)) + args <- paste(args, paste0("--inputs=", wbt_file_path(inputs))) } if (!is.null(outdir)) { args <- paste(args, paste0("--outdir=", outdir)) @@ -2194,7 +2194,7 @@ wbt_zlidar_to_las <- function(inputs=NULL, outdir=NULL, wd=NULL, verbose_mode=FA wbt_init() args <- "" if (!is.null(inputs)) { - args <- paste(args, paste0("--inputs=", inputs)) + args <- paste(args, paste0("--inputs=", wbt_file_path(inputs))) } if (!is.null(outdir)) { args <- paste(args, paste0("--outdir=", outdir)) diff --git a/R/image_analysis.R b/R/image_analysis.R index 7a3d6d3f6..84767020a 100644 --- a/R/image_analysis.R +++ b/R/image_analysis.R @@ -360,7 +360,7 @@ wbt_mosaic <- function(output, inputs=NULL, method="nn", wd=NULL, verbose_mode=F args <- "" args <- paste(args, paste0("--output=", wbt_file_path(output))) if (!is.null(inputs)) { - args <- paste(args, paste0("--inputs=", inputs)) + args <- paste(args, paste0("--inputs=", wbt_file_path(inputs))) } if (!is.null(method)) { args <- paste(args, paste0("--method=", method)) diff --git a/R/lidar_analysis.R b/R/lidar_analysis.R index 1ce64eeef..4292f27d1 100644 --- a/R/lidar_analysis.R +++ b/R/lidar_analysis.R @@ -451,7 +451,7 @@ wbt_las_to_zlidar <- function(inputs=NULL, outdir=NULL, compress="brotli", level wbt_init() args <- "" if (!is.null(inputs)) { - args <- paste(args, paste0("--inputs=", inputs)) + args <- paste(args, paste0("--inputs=", wbt_file_path(inputs))) } if (!is.null(outdir)) { args <- paste(args, paste0("--outdir=", outdir)) @@ -2194,7 +2194,7 @@ wbt_zlidar_to_las <- function(inputs=NULL, outdir=NULL, wd=NULL, verbose_mode=FA wbt_init() args <- "" if (!is.null(inputs)) { - args <- paste(args, paste0("--inputs=", inputs)) + args <- paste(args, paste0("--inputs=", wbt_file_path(inputs))) } if (!is.null(outdir)) { args <- paste(args, paste0("--outdir=", outdir))