aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2025-04-22 21:48:39 +0100
committerArun Isaac2025-04-22 22:17:22 +0100
commit6a21604aefd2bfdc86aa3d5c968880270b88853c (patch)
tree3194cefda08f4a44fe9987f60765ac9db99f30df
parent9bf0dad2f40807f4fec673670cd40ba4107bc069 (diff)
downloadravanan-6a21604aefd2bfdc86aa3d5c968880270b88853c.tar.gz
ravanan-6a21604aefd2bfdc86aa3d5c968880270b88853c.tar.lz
ravanan-6a21604aefd2bfdc86aa3d5c968880270b88853c.zip
command-line-tool: Move canonicalize-file-value to work module.
* ravanan/command-line-tool.scm (build-command-line-tool-script): Move canonicalize-file-value to ... * ravanan/work/command-line-tool.scm (canonicalize-file-value): ... here.
-rw-r--r--ravanan/command-line-tool.scm14
-rw-r--r--ravanan/work/command-line-tool.scm17
2 files changed, 17 insertions, 14 deletions
diff --git a/ravanan/command-line-tool.scm b/ravanan/command-line-tool.scm
index cb309a0..edcaaab 100644
--- a/ravanan/command-line-tool.scm
+++ b/ravanan/command-line-tool.scm
@@ -876,20 +876,6 @@ same as in @code{run-workflow} from @code{(ravanan workflow)}."
(cons "location" (string-append "file://" destination-path))
(cons "path" destination-path))))
- (define (canonicalize-file-value value)
- (let ((path (or (assoc-ref value "location")
- (assoc-ref value "path"))))
- ;; Populate all fields of the File type value.
- `(("class" . "File")
- ("location" . ,(string-append "file://" path))
- ("path" . ,path)
- ("basename" . ,(basename path))
- ("nameroot" . ,(file-name-stem path))
- ("nameext" . ,(file-name-extension path))
- ("size" . ,(stat:size (stat path)))
- ("checksum" . ,(or (assoc-ref value "checksum")
- (checksum path))))))
-
(define (secondary-path path secondary-file)
"Derive path to @var{secondary-file} from primary @var{path}."
(let ((pattern (assoc-ref* secondary-file "pattern")))
diff --git a/ravanan/work/command-line-tool.scm b/ravanan/work/command-line-tool.scm
index 9e5c8a1..ec8a8a3 100644
--- a/ravanan/work/command-line-tool.scm
+++ b/ravanan/work/command-line-tool.scm
@@ -20,6 +20,7 @@
#:use-module (rnrs exceptions)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
+ #:use-module (ice-9 filesystem)
#:use-module (ice-9 format)
#:use-module (ice-9 match)
#:use-module (gcrypt base16)
@@ -36,6 +37,7 @@
run-command
sha1-hash
checksum
+ canonicalize-file-value
evaluate-javascript))
(define (value->string x)
@@ -205,6 +207,21 @@ status in @var{success-codes} as success. Error out otherwise."
"Return the checksum of @var{file} as defined in the CWL specification."
(string-append "sha1$" (sha1-hash file)))
+(define (canonicalize-file-value value)
+ "Canonicalize @code{File} type @var{value} adding missing fields."
+ (let ((path (or (assoc-ref value "location")
+ (assoc-ref value "path"))))
+ ;; Populate all fields of the File type value.
+ `(("class" . "File")
+ ("location" . ,(string-append "file://" path))
+ ("path" . ,path)
+ ("basename" . ,(basename path))
+ ("nameroot" . ,(file-name-stem path))
+ ("nameext" . ,(file-name-extension path))
+ ("size" . ,(stat:size (stat path)))
+ ("checksum" . ,(or (assoc-ref value "checksum")
+ (checksum path))))))
+
(define* (evaluate-javascript node expression #:optional (preamble ""))
"Evaluate javascript @var{expression} using @var{node}. Evaluate
@var{preamble} before evaluating @var{expression}."