unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Mathieu Othacehe <m.othacehe@gmail.com>
To: 26772@debbugs.gnu.org
Subject: bug#26772: [PATCH 3/3] import: pypi: Robustify latest-release.
Date: Thu,  4 May 2017 12:06:27 +0200	[thread overview]
Message-ID: <20170504100627.27553-3-m.othacehe@gmail.com> (raw)
In-Reply-To: <20170504100627.27553-1-m.othacehe@gmail.com>

* guix/import/pypi.scm (latest-release): Check if pypi-fetch has
  failed. If so return #f, else construct the <upstream-source>.
---
 guix/import/pypi.scm | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index 4f9518f2e..9c72e7331 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2014 David Thompson <davet@gnu.org>
 ;;; Copyright © 2015 Cyril Roelandt <tipecaml@gmail.com>
 ;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -322,15 +323,17 @@ VERSION, SOURCE-URL, HOME-PAGE, SYNOPSIS, DESCRIPTION, and LICENSE."
 
 (define (latest-release package)
   "Return an <upstream-source> for the latest release of PACKAGE."
-  (guard (c ((missing-source-error? c) #f))
-    (let* ((pypi-name (guix-package->pypi-name package))
-           (metadata (pypi-fetch pypi-name))
-           (version (assoc-ref* metadata "info" "version"))
-           (url (assoc-ref (latest-source-release metadata) "url")))
-      (upstream-source
-       (package (package-name package))
-       (version version)
-       (urls (list url))))))
+  (let* ((pypi-name    (guix-package->pypi-name package))
+         (pypi-package (pypi-fetch pypi-name)))
+    (and pypi-package
+         (guard (c ((missing-source-error? c) #f))
+           (let* ((metadata pypi-package)
+                  (version (assoc-ref* metadata "info" "version"))
+                  (url (assoc-ref (latest-source-release metadata) "url")))
+             (upstream-source
+              (package (package-name package))
+              (version version)
+              (urls (list url))))))))
 
 (define %pypi-updater
   (upstream-updater
-- 
2.12.2

  parent reply	other threads:[~2017-05-04 10:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-04 10:04 bug#26772: [PATCH 0/3] Fix guix refresh errors Mathieu Othacehe
2017-05-04 10:06 ` bug#26772: [PATCH 1/3] gnu: python-termcolor: Fix uri Mathieu Othacehe
2017-05-04 10:06   ` bug#26772: [PATCH 2/3] import: cran: Robustify cran-package? Mathieu Othacehe
2017-05-12 22:11     ` Ludovic Courtès
2017-05-13 10:44       ` Mathieu Othacehe
2017-05-13 13:12         ` Ludovic Courtès
2017-05-04 10:06   ` Mathieu Othacehe [this message]
2017-05-12 22:11     ` bug#26772: [PATCH 3/3] import: pypi: Robustify latest-release Ludovic Courtès
2017-05-04 10:09   ` bug#26772: [PATCH 1/3] gnu: python-termcolor: Fix uri Mathieu Othacehe
2017-05-12 22:07   ` 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

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170504100627.27553-3-m.othacehe@gmail.com \
    --to=m.othacehe@gmail.com \
    --cc=26772@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 public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).