Subject: [PATCH v4 10/11] import: egg: Use maybe-*inputs procedures.

From: Herman Rimm <[email-masked]>
Date: Mon, 9 Dec 2024 20:58:14 +0100

* guix/import/egg.scm (maybe-inputs): Delete procedure.
(egg-parse-dependency): Simplify procedure to return strings.
(egg->guix-package): Use maybe-*inputs procedures.

Change-Id: Ib0a3f5b6f02912c847defd02ba7675d80005279b
---
 guix/import/egg.scm | 39 +++++++++++----------------------------
 1 file changed, 11 insertions(+), 28 deletions(-)

diff --git a/guix/import/egg.scm b/guix/import/egg.scm
index a87de1453e..049c45257e 100644
--- a/guix/import/egg.scm
+++ b/guix/import/egg.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2021 Sarah Morgensen <[email-masked]>
 ;;; Copyright © 2022 Hartmut Goebel <[email-masked]>
 ;;; Copyright © 2024 Ekaitz Zarraga <[email-masked]>
+;;; Copyright © 2024 Herman Rimm <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -230,23 +231,14 @@ (define* (egg->guix-package name version #:key (file #f) (source #f)
                           (else char)))
                       (maybe-symbol->string name)))
 
-        (define* (egg-parse-dependency name #:key (system? #f))
-          (define extract-name
-            (match-lambda
-              ((name version) name)
-              (name name)))
-
-          (define (prettify-name name)
+        (define* (egg-parse-dependency dependency #:key (system? #f))
+          (let ((name (match dependency
+                        ((name version) name)
+                        (name name))))
             (if system?
                 (prettify-system-dependency name)
-                (maybe-symbol->string name)))
-
-          (let ((name (prettify-name (extract-name name))))
-            ;; Dependencies are sometimes specified as symbols and sometimes
-            ;; as strings
-            (string->symbol (string-append
-                             (if system? "" package-name-prefix)
-                             name))))
+                (string-append package-name-prefix
+                               (maybe-symbol->string name)))))
 
         (define egg-propagated-inputs
           (let ((dependencies (assoc-ref egg-content 'dependencies)))
@@ -278,15 +270,6 @@ (define* (egg->guix-package name version #:key (file #f) (source #f)
                               test+build-dependencies))
               (() '()))))
 
-        ;; Copied from (guix import hackage).
-        (define (maybe-inputs input-type inputs)
-          (match inputs
-            (()
-             '())
-            ((inputs ...)
-             (list (list input-type
-                         `(list ,@inputs))))))
-
         (values
          `(package
             (name ,(egg-name->guix-name name))
@@ -304,16 +287,16 @@ (define* (egg->guix-package name version #:key (file #f) (source #f)
                                    "failed to download tar archive"))))))
             (build-system chicken-build-system)
             (arguments ,(list 'quasiquote (list #:egg-name name)))
-            ,@(maybe-inputs 'native-inputs egg-native-inputs)
-            ,@(maybe-inputs 'inputs egg-inputs)
-            ,@(maybe-inputs 'propagated-inputs egg-propagated-inputs)
+            ,@(maybe-native-inputs egg-native-inputs)
+            ,@(maybe-inputs egg-inputs)
+            ,@(maybe-propagated-inputs egg-propagated-inputs)
             (home-page ,egg-home-page)
             (synopsis ,egg-synopsis)
             (description #f)
             (license ,egg-licenses))
          (filter (lambda (name)
                    (not (member name '("srfi-4"))))
-                 (map (compose guix-name->egg-name symbol->string)
+                 (map guix-name->egg-name
                       (append egg-propagated-inputs
                               egg-native-inputs)))))))
 
-- 
2.45.2