From patchwork Tue Apr 14 22:48:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Wurmus X-Patchwork-Id: 21258 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 7662B27BBE4; Tue, 14 Apr 2020 23:49:13 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 0092A27BBE4 for ; Tue, 14 Apr 2020 23:49:13 +0100 (BST) Received: from localhost ([::1]:40006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOUMh-0005ep-8y for patchwork@mira.cbaines.net; Tue, 14 Apr 2020 18:49:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42481) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOUMY-0005eY-Vd for guix-patches@gnu.org; Tue, 14 Apr 2020 18:49:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jOUMX-0004ds-Un for guix-patches@gnu.org; Tue, 14 Apr 2020 18:49:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:51640) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jOUMX-0004dX-N9 for guix-patches@gnu.org; Tue, 14 Apr 2020 18:49:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jOUMX-0001nP-M2 for guix-patches@gnu.org; Tue, 14 Apr 2020 18:49:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#40629] [PATCH 6/9] import/json: Use json->code. References: <87y2qym5v8.fsf@elephly.net> In-Reply-To: <87y2qym5v8.fsf@elephly.net> Resent-From: Ricardo Wurmus Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 14 Apr 2020 22:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40629 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 40629@debbugs.gnu.org Cc: Ricardo Wurmus Received: via spool by 40629-submit@debbugs.gnu.org id=B40629.15869045096822 (code B ref 40629); Tue, 14 Apr 2020 22:49:01 +0000 Received: (at 40629) by debbugs.gnu.org; 14 Apr 2020 22:48:29 +0000 Received: from localhost ([127.0.0.1]:34944 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOUM1-0001ly-B5 for submit@debbugs.gnu.org; Tue, 14 Apr 2020 18:48:29 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21392) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOULz-0001lq-6R for 40629@debbugs.gnu.org; Tue, 14 Apr 2020 18:48:27 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1586904505; cv=none; d=zohomail.com; s=zohoarc; b=gnWd1ZJBrMcEqJ933n3B7y4LsXruI6H/emgLdDI97gYjiKE+QkXcjjOKadHTCHSnc+hA+RjjLZcc+aPeAx4AFMdKm2nwFA89Y0h4iDeQeobiNUxvduwMQ23CIW9Hl2dvqyV3FA+oLRpMbDxH1SZLv2/yMhoU2LCvsvYP8d7IsD8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586904505; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=dI1Fr0Zyxo6J8F7oQNR/fZdLnd03kVq/icYAObSyZ/g=; b=BARCOiNu1bQaRqzdqXHVNAqfc8sM8ZQJLR1mQH1f/EEnlcKmXeX8Z4hPSvhX0T5ys8l1I8rvbOdbukiQoYRAJM1il11ZeJWB29gLNSD5/GFfilmEj+bLLpTw1arsXrF45SwNA1EFhHKjkk6lYSJvIv1drESbOfzqqpI8HKUqmqw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1586904505; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=dI1Fr0Zyxo6J8F7oQNR/fZdLnd03kVq/icYAObSyZ/g=; b=aBfpSHOec16o2Wtbudz2DXsda2detnjlK08ZZwmweOMxx9TkAUMm/jUOkaAzAKJk T4qUQJu9RyQc2USCcnFGIBJGao/93s0+cx/TO1hQnA+gutpv/XM1YQldQACJ35LqOUm 5/KmCPfkhUxnJAdkFZlIua0B7E90Eo6+SsW7/23E= Received: from localhost (p54AD4D5F.dip0.t-ipconnect.de [84.173.77.95]) by mx.zohomail.com with SMTPS id 1586904502368542.4275580410043; Tue, 14 Apr 2020 15:48:22 -0700 (PDT) From: Ricardo Wurmus Message-ID: <20200414224817.3850-1-rekado@elephly.net> Date: Wed, 15 Apr 2020 00:48:14 +0200 X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-ZohoMailClient: External X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/import/json.scm (json->code): Export procedure. * guix/scripts/import/json.scm (guix-import-json): Use json->code. --- guix/import/json.scm | 1 + guix/scripts/import/json.scm | 12 +++--------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/guix/import/json.scm b/guix/import/json.scm index 16dc2ad5cb..8f8dbbd05d 100644 --- a/guix/import/json.scm +++ b/guix/import/json.scm @@ -28,6 +28,7 @@ #:use-module (srfi srfi-2) #:use-module (srfi srfi-34) #:export (json-fetch + json->code json->scheme-file)) (define* (json-fetch url diff --git a/guix/scripts/import/json.scm b/guix/scripts/import/json.scm index c9daf65479..778e5f4bc5 100644 --- a/guix/scripts/import/json.scm +++ b/guix/scripts/import/json.scm @@ -23,7 +23,7 @@ #:use-module (guix utils) #:use-module (guix scripts) #:use-module (guix import utils) - #:use-module (guix import print) + #:use-module (guix import json) #:use-module (guix scripts import) #:use-module (guix packages) #:use-module (srfi srfi-1) @@ -88,14 +88,8 @@ Import and convert the JSON package definition in PACKAGE-FILE.\n")) (reverse opts)))) (match args ((file-name) - (catch 'json-invalid - (lambda () - (let ((json (json-string->scm - (with-input-from-file file-name read-string)))) - ;; TODO: also print define-module boilerplate - (package->code (alist->package json)))) - (lambda _ - (leave (G_ "invalid JSON in file '~a'~%") file-name)))) + (or (json->code file-name) + (leave (G_ "invalid JSON in file '~a'~%") file-name))) (() (leave (G_ "too few arguments~%"))) ((many ...)