From: Christopher Baines <mail@cbaines.net>
To: 36948@debbugs.gnu.org
Subject: [bug#36948] [PATCH 1/2] import: utils: Add hash-ref*.
Date: Tue, 6 Aug 2019 20:17:27 +0100 [thread overview]
Message-ID: <20190806191728.22923-1-mail@cbaines.net> (raw)
In-Reply-To: <87k1bq864w.fsf@cbaines.net>
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
next prev parent reply other threads:[~2019-08-06 19:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-06 19:07 [bug#36948] [PATCH 0/2] Fix the CPAN importer Christopher Baines
2019-08-06 19:17 ` Christopher Baines [this message]
2019-08-06 19:17 ` [bug#36948] [PATCH 2/2] import: cpan: Adapt for the change to guile-json version 3 Christopher Baines
2019-08-22 12:04 ` [bug#36948] [PATCH 1/2] import: utils: Add hash-ref* Ludovic Courtès
2019-08-21 17:30 ` bug#36948: [PATCH 0/2] Fix the CPAN importer Christopher Baines
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190806191728.22923-1-mail@cbaines.net \
--to=mail@cbaines.net \
--cc=36948@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).