GNU bug report logs - #24450
pypi importer outputs strange character series in optional dependency case.

Previous Next

Package: guix;

Reported by: ng0 <ng0 <at> we.make.ritual.n0.is>

Date: Fri, 16 Sep 2016 20:02:01 UTC

Severity: normal

Tags: patch

Merged with 24557, 33047, 33569, 34266

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ricardo Wurmus <ricardo.wurmus <at> mdc-berlin.de>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: 24450 <at> debbugs.gnu.org
Subject: bug#24450: [PATCHv2] Re: pypi importer outputs strange character series in optional dependency case.
Date: Tue, 11 Jun 2019 13:56:46 +0200
Hi Maxim,

>>> +  (call-with-input-file metadata
>>> +    (lambda (port)
>>> +      (let loop ((requirements '()))
>>> +        (let ((line (read-line port)))
>>> +          ;; Stop at the first 'Provides-Extra' section: the non-optional
>>> +          ;; requirements appear before the optional ones.
>>> +          (if (eof-object? line)
>>> +              (reverse (delete-duplicates requirements))
>>> +              (cond
>>> +               ((and (requires-dist-header? line) (not (extra? line)))
>>> +                (loop (cons (specification->requirement-name
>>> +                             (requires-dist-value line))
>>> +                            requirements)))
>>> +               (else
>>> +                (loop requirements)))))))))
>>> +
>>
>> As before you can simplify the nested let and merge “if” and "cond“.
>
> Oh, I get it now, I think:
>
> --8<---------------cut here---------------start------------->8---
>
>    (call-with-input-file metadata
>      (lambda (port)
>        (let loop ((requirements '()))
> -        (let ((line (read-line port)))
> -          ;; Stop at the first 'Provides-Extra' section: the non-optional
> -          ;; requirements appear before the optional ones.
> -          (if (eof-object? line)
> -              (reverse (delete-duplicates requirements))
> -              (cond
> -               ((and (requires-dist-header? line) (not (extra? line)))
> -                (loop (cons (specification->requirement-name
> -                             (requires-dist-value line))
> -                            requirements)))
> -               (else
> -                (loop requirements)))))))))
> +        (match (read-line port)
> +          (line
> +           ;; Stop at the first 'Provides-Extra' section: the non-optional
> +           ;; requirements appear before the optional ones.
> +           (cond
> +            ((eof-object? line)
> +             (reverse (delete-duplicates requirements)))
> +            ((and (requires-dist-header? line) (not (extra? line)))
> +             (loop (cons (specification->requirement-name
> +                          (requires-dist-value line))
> +                         requirements)))
> +            (else
> +             (loop requirements)))))))))
>
>  (define (guess-requirements source-url wheel-url archive)
>    "Given SOURCE-URL, WHEEL-URL and a ARCHIVE of the package, return a list
> --8<---------------cut here---------------end--------------->8---

Not quite.  Your ‘match’ expression here doesn’t do anything that a
‘let’ wouldn’t have done.  It really just binds the return value of
(read-line port) to ‘line’; that’s the same as (let ((line (read-line
port))) …).

I gave a match example using predicate matchers in a previous reply.  In
any case, using ‘cond’ inside of a let would be just fine.  If you
wanted to go with ‘match’, though, you’d replace the ‘cond’.

--
Ricardo




This bug report was last modified 6 years and 13 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.