From fcb98e428ea9967f8de0c953e2e400bb81d26c4f Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 20 Sep 2024 17:19:22 +0100 Subject: utils: Move json-ref to (ravanan work utils). * ravanan/utils.scm: Move to ... * ravanan/work/utils.scm (json-ref): ... here. * ravanan/slurm-api.scm: Import (ravanan work utils) instead of (ravanan utils). --- ravanan/slurm-api.scm | 2 +- ravanan/utils.scm | 10 ---------- ravanan/work/utils.scm | 10 ++++++++++ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ravanan/slurm-api.scm b/ravanan/slurm-api.scm index 4ed02b5..fdc89fc 100644 --- a/ravanan/slurm-api.scm +++ b/ravanan/slurm-api.scm @@ -25,7 +25,7 @@ #:use-module (web client) #:use-module (web uri) #:use-module (json) - #:use-module (ravanan utils) + #:use-module (ravanan work utils) #:export (submit-job job-state)) diff --git a/ravanan/utils.scm b/ravanan/utils.scm index 5ae3c20..b2c3c94 100644 --- a/ravanan/utils.scm +++ b/ravanan/utils.scm @@ -21,7 +21,6 @@ #:use-module (srfi srfi-26) #:use-module (ice-9 match) #:export (string-trim-prefix - json-ref call-with-temporary-file)) (define (string-trim-prefix prefix str) @@ -30,15 +29,6 @@ (substring str (string-length prefix)) str)) -(define (json-ref scm . keys) - "Extract subtree of JSON @var{scm} that is addressed by @var{keys}." - (match keys - ((key other-keys ...) - (apply json-ref - ((if (list? scm) assoc-ref vector-ref) scm key) - other-keys)) - (() scm))) - (define* (call-with-temporary-file proc #:optional (parent-directory (getcwd))) "Call @var{proc} with an output port to a new temporary file in @var{parent-directory}, and delete it when @var{proc} returns or exits diff --git a/ravanan/work/utils.scm b/ravanan/work/utils.scm index 1323352..15349b2 100644 --- a/ravanan/work/utils.scm +++ b/ravanan/work/utils.scm @@ -27,6 +27,7 @@ alist=? assoc-ref* assoc-set + json-ref call-with-temporary-directory call-with-input-pipe)) @@ -62,6 +63,15 @@ mutated." tail)) (() alist))) +(define (json-ref scm . keys) + "Extract subtree of JSON @var{scm} that is addressed by @var{keys}." + (match keys + ((key other-keys ...) + (apply json-ref + ((if (list? scm) assoc-ref vector-ref) scm key) + other-keys)) + (() scm))) + (define* (call-with-temporary-directory proc #:optional (parent-directory (getcwd))) "Call @var{proc} with a new temporary directory in -- cgit v1.2.3