diff options
author | Arun Isaac | 2025-03-18 14:13:06 +0000 |
---|---|---|
committer | Arun Isaac | 2025-03-18 14:14:40 +0000 |
commit | 9f3079e84a368e757021735c5b500ae34b38e11b (patch) | |
tree | 53a25e2ef1e0e07e695d49c53763d71223757a0b | |
parent | 25aaea60005d183aeb89c38c1983181cfd87a772 (diff) | |
download | ravanan-9f3079e84a368e757021735c5b500ae34b38e11b.tar.gz ravanan-9f3079e84a368e757021735c5b500ae34b38e11b.tar.lz ravanan-9f3079e84a368e757021735c5b500ae34b38e11b.zip |
reader: Spin off input normalization into separate function.
Separate functions are easier to test.
* ravanan/reader.scm (read-inputs): Spin off input normalization into
...
(normalize-input): ... new function.
-rw-r--r-- | ravanan/reader.scm | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/ravanan/reader.scm b/ravanan/reader.scm index 5d1644f..05dff6e 100644 --- a/ravanan/reader.scm +++ b/ravanan/reader.scm @@ -256,6 +256,19 @@ array of array of @code{File}s, etc. Else, return @code{#f}" (cut normalize-workflow (preprocess-include (read-yaml-file (basename workflow-file)))))) +(define (normalize-input input) + "Normalize actual @var{input}." + (cond + ((vector? input) + (vector-map normalize-input + input)) + ((eq? (object-type input) + 'File) + (assoc-set input + (cons "location" + (canonicalize-path (assoc-ref input "location"))))) + (else input))) + (define (read-inputs inputs-file) "Read @var{inputs-file} resolving file paths if any." (call-with-current-directory (dirname inputs-file) @@ -263,18 +276,7 @@ array of array of @code{File}s, etc. Else, return @code{#f}" (map (match-lambda ((input-id . input) (cons input-id - (let resolve-location ((input input)) - (cond - ((vector? input) - (vector-map resolve-location - input)) - ((eq? (object-type input) - 'File) - (assoc-set input - (cons "location" - (canonicalize-path - (assoc-ref input "location"))))) - (else input)))))) + (normalize-input input)))) ;; Even though YAML is a superset of JSON, use the JSON ;; reader if possible; it is simpler and less prone to type ;; ambiguities. |