From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id SHqbGp7AK2JGagEAgWs5BA (envelope-from ) for ; Fri, 11 Mar 2022 22:35:26 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id cC7+F57AK2IlUAEA9RJhRA (envelope-from ) for ; Fri, 11 Mar 2022 22:35:26 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D87A6130AA for ; Fri, 11 Mar 2022 22:35:25 +0100 (CET) Received: from localhost ([::1]:58708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSmuy-0006bO-Np for larch@yhetil.org; Fri, 11 Mar 2022 16:35:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSmud-0006at-Cj for guix-patches@gnu.org; Fri, 11 Mar 2022 16:35:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:44629) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSmud-0000zG-4m for guix-patches@gnu.org; Fri, 11 Mar 2022 16:35:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nSmud-00043v-0G for guix-patches@gnu.org; Fri, 11 Mar 2022 16:35:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#54344] [PATCH 1/3] graph: Factorize 'lookup-backend'. References: <20220311213233.12415-1-ludo@gnu.org> In-Reply-To: <20220311213233.12415-1-ludo@gnu.org> Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 11 Mar 2022 21:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54344 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54344@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 54344-submit@debbugs.gnu.org id=B54344.164703447315548 (code B ref 54344); Fri, 11 Mar 2022 21:35:02 +0000 Received: (at 54344) by debbugs.gnu.org; 11 Mar 2022 21:34:33 +0000 Received: from localhost ([127.0.0.1]:38519 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nSmu8-00042g-KJ for submit@debbugs.gnu.org; Fri, 11 Mar 2022 16:34:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42810) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nSmu7-00042O-Ij for 54344@debbugs.gnu.org; Fri, 11 Mar 2022 16:34:32 -0500 Received: from [2001:470:142:3::e] (port=33216 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSmu2-0000ov-A7; Fri, 11 Mar 2022 16:34:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=MXM8oyYtSLL9FSzjt0xCobYF969sfKjV50Q+9x4wJ2U=; b=dZQeVWSrR1gXt9 laOTTWUDiWMMCk1l69cxu5VKG+gdY44pTzHQgSvDYPuuAlVQv7HgYf40uI5JT8eRmr1j1dkTKVxot EsuDTOeGude5Dq1x7ECZqp2fJxLfU/elDkyjIxuER+uC70ydEcFMfjzgqkeyFTwF377v/oyEgWlVc W9dbNAP1EQvuX2jGfhUielB/xSVhiJ33EHZ4x0iuoZ8HRTRzKsBKxE29Wrg+ayUC9LAjC0KDtrwl3 lyvBGUaL4fh9rfmgGHg8aJ7J0XtDKMRUFc6p9k76KUZYxwIC1puM2i5HHqtAh/raFSqKS8UEZMjNQ R5X8zI8cJUmygmSFTBtg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:58671 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSmu1-0003hy-Pj; Fri, 11 Mar 2022 16:34:25 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Fri, 11 Mar 2022 22:34:16 +0100 Message-Id: <20220311213418.12472-1-ludo@gnu.org> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1647034526; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=MXM8oyYtSLL9FSzjt0xCobYF969sfKjV50Q+9x4wJ2U=; b=gVmwaI7Ymk55fppf02uhMTBxzZYUkMIkTPNZyLfK/4zGipuQrndJHZD9Kj8v1utzHsPOhV GJKTd7RNwZ6Yg1/d5iaWb02rX3WGl0qN/q/esBRGYrYNA0S5aWBLnkidkncH440cvkwekA smgZdpi6EijTUGq899YapBIPoR9mj+SxKF03YH66dlJd+xnGA2ICCy1UfeH1oWvzvXnqpi a7J1+D+DbdX4pUCtM7/Qa7Sj3RaGWhCjMRLbyLDQFdDB6iSRVJhsaV1y5iNglj2hP9tupg hTgVEQe8C5R7yhKCUpOPpQoZtyzoghnPXPr8mp1K8UHIYMcamAQ34OtjlvSQ3g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1647034526; a=rsa-sha256; cv=none; b=gnxa26B04M8akzRwSSA7D3ZU45w6BSfcDTAdgnqUCx2yGTQL/QYmDvGETbC24fwMlbEXfu oPyL/2MU3ErVWB42CmU5whpJO1kaUacYdg+k2jPXqxma6l11+TIZ99itK3HfeAMoDrIr5P BhfMXmKr04tswjr/M5lnK1EMQppNchWYUBj4lpoF2Wb8u4Whx4q1AotJj2ZjuG14dOn4hm +TmxDDJPWtQGSUjpE/FDFn5u01FItdU+/DSF7mPrXnU8QTY2zipbXWELTouQtcu5Ue7tF3 Ah/nkWNwq6in3Croz+sZJq+Ae/+c5oQe4ZpZnfqEDvxmPtR7ePIhcHywJvzDSw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=dZQeVWSr; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.59 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=dZQeVWSr; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: D87A6130AA X-Spam-Score: -3.59 X-Migadu-Scanner: scn0.migadu.com X-TUID: 942ayF2eCwag * guix/graph.scm (lookup-backend): New procedure. * guix/scripts/graph.scm (lookup-backend): Remove. * guix/scripts/system.scm (lookup-backend): Remove. * po/guix/POTFILES.in: Add 'guix/graph.scm'. --- guix/graph.scm | 14 +++++++++++++- guix/scripts/graph.scm | 9 +-------- guix/scripts/system.scm | 9 +-------- po/guix/POTFILES.in | 1 + 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/guix/graph.scm b/guix/graph.scm index 3a1cab244b..41219ab67d 100644 --- a/guix/graph.scm +++ b/guix/graph.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2015, 2016, 2020, 2021 Ludovic Courtès +;;; Copyright © 2015-2016, 2020-2022 Ludovic Courtès ;;; Copyright © 2016 Ricardo Wurmus ;;; ;;; This file is part of GNU Guix. @@ -22,10 +22,13 @@ (define-module (guix graph) #:use-module (guix monads) #:use-module (guix records) #:use-module (guix sets) + #:autoload (guix diagnostics) (formatted-message) + #:autoload (guix i18n) (G_) #:use-module (rnrs io ports) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-34) #:use-module (ice-9 match) #:use-module (ice-9 vlist) #:export (node-type @@ -47,6 +50,8 @@ (define-module (guix graph) %graph-backends %d3js-backend %graphviz-backend + lookup-backend + graph-backend? graph-backend graph-backend-name @@ -335,6 +340,13 @@ (define %graph-backends %d3js-backend %cypher-backend)) +(define (lookup-backend name) + "Return the graph backend called NAME. Raise an error if it is not found." + (or (find (lambda (backend) + (string=? (graph-backend-name backend) name)) + %graph-backends) + (raise (formatted-message (G_ "~a: unknown graph backend") name)))) + (define* (export-graph sinks port #:key reverse-edges? node-type (max-depth +inf.0) diff --git a/guix/scripts/graph.scm b/guix/scripts/graph.scm index 8943e87099..535875c858 100644 --- a/guix/scripts/graph.scm +++ b/guix/scripts/graph.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès +;;; Copyright © 2015-2022 Ludovic Courtès ;;; Copyright © 2019 Simon Tournier ;;; ;;; This file is part of GNU Guix. @@ -429,13 +429,6 @@ (define (lookup-node-type name) %node-types) (leave (G_ "~a: unknown node type~%") name))) -(define (lookup-backend name) - "Return the graph backend called NAME. Raise an error if it is not found." - (or (find (lambda (backend) - (string=? (graph-backend-name backend) name)) - %graph-backends) - (leave (G_ "~a: unknown backend~%") name))) - (define (list-node-types) "Print the available node types along with their synopsis." (display (G_ "The available node types are:\n")) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index a6e717d52c..6f7dcd4643 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -51,7 +51,7 @@ (define-module (guix scripts system) delete-matching-generations) #:autoload (guix scripts pull) (channel-commit-hyperlink) #:autoload (guix graph) (export-graph node-type - graph-backend-name %graph-backends) + graph-backend-name lookup-backend) #:use-module (guix scripts graph) #:use-module (guix scripts system reconfigure) #:use-module (guix build utils) @@ -887,13 +887,6 @@ (define bootcfg (register-root* (list output) gc-root)) (return output))))))))) -(define (lookup-backend name) ;TODO: factorize - "Return the graph backend called NAME. Raise an error if it is not found." - (or (find (lambda (backend) - (string=? (graph-backend-name backend) name)) - %graph-backends) - (leave (G_ "~a: unknown backend~%") name))) - (define* (export-extension-graph os port #:key (backend (lookup-backend "graphviz"))) "Export the service extension graph of OS to PORT using BACKEND." diff --git a/po/guix/POTFILES.in b/po/guix/POTFILES.in index d97ba8c209..49a8edfef3 100644 --- a/po/guix/POTFILES.in +++ b/po/guix/POTFILES.in @@ -66,6 +66,7 @@ guix/ci.scm guix/cve.scm guix/git-authenticate.scm guix/gnupg.scm +guix/graph.scm guix/lint.scm guix/scripts/download.scm guix/scripts/package.scm -- 2.34.0