bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Cc: Collin Funk <collin.funk1@gmail.com>
Subject: Re: gnulib-tool.py: Remove a redundant function.
Date: Mon, 15 Apr 2024 13:47:00 +0200	[thread overview]
Message-ID: <5642994.VNxaBq3RWB@nimes> (raw)
In-Reply-To: <c7033250-db71-4b45-b9b8-6fac4075c511@gmail.com>

Collin Funk wrote:
> The GLImport class has two functions that are the same,
> GLImport.rewrite_old_files() and GLImport.rewrite_new_files().

No. When I copy these functions into separate text files and use 'diff'
on them:

$ diff -u 1 2
--- 1   2024-04-15 06:34:45.441369330 +0200
+++ 2   2024-04-15 06:35:01.941511954 +0200
@@ -1,7 +1,7 @@
 
-    def rewrite_old_files(self, files: list[str]) -> list[str]:
-        '''Replace auxdir, docbase, sourcebase, m4base and testsbase from default
-        to their version from cached config.'''
+    def rewrite_new_files(self, files: list[str]) -> list[str]:
+        '''Replace auxdir, docbase, sourcebase, m4base and testsbase from
+        default to their version from config.'''
         if type(files) is not list:
             raise TypeError('files argument must has list type, not %s'
                             % type(files).__name__)
@@ -9,13 +9,11 @@
             if type(file) is not str:
                 raise TypeError('each file must be a string instance')
         files = sorted(set(files))
-        files = [ '%s%s' % (file, os.path.sep)
-                  for file in files ]
-        auxdir = self.cache['auxdir']
-        docbase = self.cache['docbase']
-        sourcebase = self.cache['sourcebase']
-        m4base = self.cache['m4base']
-        testsbase = self.cache['testsbase']
+        auxdir = self.config['auxdir']
+        docbase = self.config['docbase']
+        sourcebase = self.config['sourcebase']
+        m4base = self.config['m4base']
+        testsbase = self.config['testsbase']
         result = []
         for file in files:
             if file.startswith('build-aux/'):

> Therefore, we can remove GLImport.rewrite_old_files() and rename
> GLImport.rewrite_new_files() to GLImport.rewrite_files().

No. I'm adding 3 unit tests that prove that the patch is wrong,
one for each of docbase, sourcebase, testsbase. (For auxdir and m4base
gnulib-tool.{sh,py} does not support changing the value while preserving
the rest: For auxdir the old files are not removed, for m4base the list
of modules gets reset to empty.)

Bruno





  parent reply	other threads:[~2024-04-15 11:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15  1:23 gnulib-tool.py: Remove a redundant function Collin Funk
2024-04-15  2:20 ` Collin Funk
2024-04-15 14:58   ` Bruno Haible
2024-04-15 15:24     ` Collin Funk
2024-04-16 15:09       ` Bruno Haible
2024-04-16 16:23         ` Collin Funk
2024-04-17  1:12         ` Refactoring rewrite_filename functions Collin Funk
2024-04-17  1:35           ` Bruno Haible
2024-04-17  2:08             ` Collin Funk
2024-04-17 14:03               ` Bruno Haible
2024-04-15 11:47 ` Bruno Haible [this message]
2024-04-15 14:07   ` gnulib-tool.py: Remove a redundant function Collin Funk

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://lists.gnu.org/mailman/listinfo/bug-gnulib

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

  git send-email \
    --in-reply-to=5642994.VNxaBq3RWB@nimes \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=collin.funk1@gmail.com \
    /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.
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).