import: utils: Add hash-ref*.
With the change to guile-json version 3, JSON objects are represented as hash tables, rather than alists. The cpan importer uses assoc-ref* on a hash table, so add an equivalent function for hash tables. * guix/import/utils.scm (hash-ref*): New procedure.
This commit is contained in:
parent
cad875350b
commit
8a3b11d1eb
|
@ -47,6 +47,7 @@
|
||||||
|
|
||||||
flatten
|
flatten
|
||||||
assoc-ref*
|
assoc-ref*
|
||||||
|
hash-ref*
|
||||||
|
|
||||||
url-fetch
|
url-fetch
|
||||||
guix-hash-url
|
guix-hash-url
|
||||||
|
@ -116,6 +117,15 @@ recursively apply the procedure to the sub-list."
|
||||||
(assoc-ref alist key)
|
(assoc-ref alist key)
|
||||||
(apply assoc-ref* (assoc-ref alist key) rest)))
|
(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)
|
(define (url-fetch url file-name)
|
||||||
"Save the contents of URL to FILE-NAME. Return #f on failure."
|
"Save the contents of URL to FILE-NAME. Return #f on failure."
|
||||||
(parameterize ((current-output-port (current-error-port)))
|
(parameterize ((current-output-port (current-error-port)))
|
||||||
|
|
Loading…
Reference in New Issue