From: "Ludovic Courtès" <ludo@gnu.org>
To: 54344@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>
Subject: [bug#54344] [PATCH 1/3] graph: Factorize 'lookup-backend'.
Date: Fri, 11 Mar 2022 22:34:16 +0100 [thread overview]
Message-ID: <20220311213418.12472-1-ludo@gnu.org> (raw)
In-Reply-To: <20220311213233.12415-1-ludo@gnu.org>
* 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 <ludo@gnu.org>
+;;; Copyright © 2015-2016, 2020-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
;;;
;;; 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 <ludo@gnu.org>
+;;; Copyright © 2015-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
;;;
;;; 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
next prev parent reply other threads:[~2022-03-11 21:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-11 21:32 [bug#54344] [PATCH 0/3] Add 'guix home extension-graph' and 'shepherd-graph' Ludovic Courtès
2022-03-11 21:34 ` Ludovic Courtès [this message]
2022-03-11 21:34 ` [bug#54344] [PATCH 2/3] home: services: Export record type accessors Ludovic Courtès
2022-03-11 21:34 ` [bug#54344] [PATCH 3/3] guix home: Implement the 'extension-graph' and 'shepherd-graph' actions Ludovic Courtès
2022-03-17 5:14 ` Andrew Tropin
2022-03-18 15:11 ` bug#54344: [PATCH 0/3] Add 'guix home extension-graph' and 'shepherd-graph' Ludovic Courtès
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220311213418.12472-1-ludo@gnu.org \
--to=ludo@gnu.org \
--cc=54344@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 external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.