GNU bug report logs -
#36948
[PATCH 0/2] Fix the CPAN importer
Previous Next
Reported by: Christopher Baines <mail <at> cbaines.net>
Date: Tue, 6 Aug 2019 19:08:02 UTC
Severity: normal
Tags: patch
Done: Christopher Baines <mail <at> cbaines.net>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 36948 <at> debbugs.gnu.org (full text, mbox):
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.
---
guix/import/utils.scm | 10 ++++++++++
1 file changed, 10 insertions(+)
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)))
--
2.22.0
This bug report was last modified 5 years and 357 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.