aboutsummaryrefslogtreecommitdiff
path: root/guix/graph.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-03-11 21:13:31 +0100
committerLudovic Courtès <ludo@gnu.org>2022-03-18 16:03:33 +0100
commitf5a94b3a9f5b62e79d616e9631a5137f1a100f69 (patch)
tree19b2318316cc1ad6fa4bbb4114288a883081bc09 /guix/graph.scm
parent625fa3cfe8c57cd5624608d2478c8c6be4c69c3b (diff)
downloadguix-f5a94b3a9f5b62e79d616e9631a5137f1a100f69.tar
guix-f5a94b3a9f5b62e79d616e9631a5137f1a100f69.tar.gz
graph: Factorize 'lookup-backend'.
* 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'.
Diffstat (limited to 'guix/graph.scm')
-rw-r--r--guix/graph.scm14
1 files changed, 13 insertions, 1 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 @@
#: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 @@
%graph-backends
%d3js-backend
%graphviz-backend
+ lookup-backend
+
graph-backend?
graph-backend
graph-backend-name
@@ -335,6 +340,13 @@ nodeArray.push(nodes[\"~a\"]);~%"
%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)