aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guix/import/utils.scm10
1 files changed, 10 insertions, 0 deletions
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 2a3b7341fb..ed6c3ce6af 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -47,6 +47,7 @@
flatten
assoc-ref*
+ hash-ref*
url-fetch
guix-hash-url
@@ -116,6 +117,15 @@ recursively apply the procedure to the sub-list."
(assoc-ref alist key)
(apply assoc-ref* (assoc-ref alist key) rest)))
+(define (hash-ref* hash-table key . rest)
+ "Return the value for KEY from HASH-TABLE. For each additional key specified,
+recursively apply the procedure to the sub-hash-table."
+ (if (hash-table? hash-table)
+ (if (null? rest)
+ (hash-ref hash-table key)
+ (apply hash-ref* (hash-ref hash-table key) rest))
+ #f)) ; For consistency with assoc-ref*
+
(define (url-fetch url file-name)
"Save the contents of URL to FILE-NAME. Return #f on failure."
(parameterize ((current-output-port (current-error-port)))