about summary refs log tree commit diff
diff options
context:
space:
mode:
-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}."