From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: bug#24450: [PATCHv2] Re: pypi importer outputs strange character series in optional dependency case. Date: Mon, 10 Jun 2019 22:13:38 +0200 Message-ID: <878su9ci6l.fsf@mdc-berlin.de> References: <87pnod7ot4.fsf@gmail.com> <87blz55zzu.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:42356) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haQub-000544-7r for bug-guix@gnu.org; Mon, 10 Jun 2019 16:29:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haQg6-0002Kp-2w for bug-guix@gnu.org; Mon, 10 Jun 2019 16:14:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:43974) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1haQg5-0002JO-TY for bug-guix@gnu.org; Mon, 10 Jun 2019 16:14:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1haQg5-0003q6-NL for bug-guix@gnu.org; Mon, 10 Jun 2019 16:14:01 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87blz55zzu.fsf@gmail.com> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Maxim Cournoyer Cc: 24450@debbugs.gnu.org Hi Maxim, thanks for your patience in addressing my comments. I appreciate it! >> I think the double application of file-sans-extension and the >> intermediate variable name =E2=80=9Croot-directory=E2=80=9D for somethin= g that is a file >> is a little confusing, but I don=E2=80=99t have a better proposal (other= than to >> replace file-extension and file-sans-extension with a match expression). > > Done, w.r.t. using "match": > > --8<---------------cut here---------------start------------->8--- > @@ -198,10 +198,12 @@ be extracted in a temporary directory." > ;; that will be created upon decompressing it. If the filetype is not > ;; supported, return #f. > (if (compressed-file? url) > - (let ((root-directory (file-sans-extension (basename url)))) > - (if (string=3D? "tar" (file-extension root-directory)) > - (file-sans-extension root-directory) > - root-directory)) > + (match (file-sans-extension (basename url)) > + (root-directory > + (match (file-extension root-directory) > + ("tar" > + (file-sans-extension root-directory)) > + (_ root-directory)))) > (begin > (warning (G_ "Unsupported archive format (~a): \ > cannot determine package dependencies") (file-extension url)) > --8<---------------cut here---------------end--------------->8--- The first application of =E2=80=9Cmatch=E2=80=9D matches anything. What I = had in mind was really a slightly different approach, namely to split up the =E2=80=9Cu= rl=E2=80=9D string at dots and then match the resulting list of strings. Something like this: (match (string-split "hello.tar.gz" #\.) ((base "tar" (or "bz2" "gz")) base) ((base ext) base)) > I don't see much of a problem with the current design since there are > two questions being answered: > > 1) What should be the directory name of the extracted package (retrieved > from the base name of the archive). > 2) What extractor should be used (zip vs tar). > > These two questions are orthogonal, and that the same primitive get used > to answer both is an implementation, or rather, an optimization detail. > >> I wonder if we could do better and answer the question just once. > > The questions are different :-). We could optimize, but that would be at > the price of expressiveness (squash the two questions into one solving > space). Okay. I guess I=E2=80=99m too picky :) I=E2=80=99d be happy if we could move the checks to tiny named procedures, = but it=E2=80=99s probably fine the way it is. Thanks! -- Ricardo