mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
import: pypi: Use 'with-error-handling'.
* guix/scripts/import/pypi.scm (guix-import-pypi): Wrap body in 'with-error-handling'.
This commit is contained in:
parent
2178692c93
commit
31ca569ca5
1 changed files with 19 additions and 18 deletions
|
@ -79,27 +79,28 @@ (define (parse-options)
|
|||
|
||||
(let* ((opts (parse-options))
|
||||
(args (filter-map (match-lambda
|
||||
(('argument . value)
|
||||
value)
|
||||
(_ #f))
|
||||
(('argument . value)
|
||||
value)
|
||||
(_ #f))
|
||||
(reverse opts))))
|
||||
(match args
|
||||
((spec)
|
||||
(let ((name version (package-name->name+version spec)))
|
||||
(if (assoc-ref opts 'recursive)
|
||||
;; Recursive import
|
||||
(map (match-lambda
|
||||
((and ('package ('name name) . rest) pkg)
|
||||
`(define-public ,(string->symbol name)
|
||||
,pkg))
|
||||
(_ #f))
|
||||
(pypi-recursive-import name version))
|
||||
;; Single import
|
||||
(let ((sexp (pypi->guix-package name #:version version)))
|
||||
(unless sexp
|
||||
(leave (G_ "failed to download meta-data for package '~a'~%")
|
||||
name))
|
||||
sexp))))
|
||||
(with-error-handling
|
||||
(let ((name version (package-name->name+version spec)))
|
||||
(if (assoc-ref opts 'recursive)
|
||||
;; Recursive import
|
||||
(map (match-lambda
|
||||
((and ('package ('name name) . rest) pkg)
|
||||
`(define-public ,(string->symbol name)
|
||||
,pkg))
|
||||
(_ #f))
|
||||
(pypi-recursive-import name version))
|
||||
;; Single import
|
||||
(let ((sexp (pypi->guix-package name #:version version)))
|
||||
(unless sexp
|
||||
(leave (G_ "failed to download meta-data for package '~a'~%")
|
||||
name))
|
||||
sexp)))))
|
||||
(()
|
||||
(leave (G_ "too few arguments~%")))
|
||||
((many ...)
|
||||
|
|
Loading…
Reference in a new issue