From: Collin Funk <collin.funk1@gmail.com>
To: Bruno Haible <bruno@clisp.org>, bug-gnulib@gnu.org
Subject: Refactoring rewrite_filename functions
Date: Tue, 16 Apr 2024 18:12:29 -0700 [thread overview]
Message-ID: <4f567b55-2b44-48a3-9cdb-1a8a9570d589@gmail.com> (raw)
In-Reply-To: <6055935.ntHmXhgcp8@nimes>
Hi Bruno,
On 4/16/24 8:09 AM, Bruno Haible wrote:
> I'm talking about this piece of code:
>
> filetable = []
> for src in filelist:
> dest = self.rewrite_files([src])[-1]
> filetable.append(tuple([dest, src]))
>
> which can be written as
>
> filetable = [ tuple([self.rewrite_filename(src), src])
> for src in filelist ]
I'm taking a look at this again and I think it would make sense to
move these 'rewrite_filename' functions to GLConfig since they only
use the directory names stored there. Right now we have the following:
1. GLImport.rewrite_old_files() # Uses self.cache
2. GLImport.rewrite_new_files() # Uses self.config
3. GLTestDir.rewrite_files() # Uses self.config, TestDir has no cache
I'm thinking of making this function accept a single filename instead
of a list, and then moving it to GLConfig. Omitting the tuple stuff
for clarity, but this is how the new/old filename distinction would be
handled:
# Equals current GLImport.rewrite_old_files()
[ self.cache.rewrite_filename(src)
for src in filelist ]
# Equals current GLImport.rewrite_new_files()
[ self.config.rewrite_filename(src)
for src in filelist ]
What do you think about this change?
Also, there is a similar section of code to this new function in
main.py line 1313 under "mode == 'copy-file'", but it is missing the
'tests=lib/' replacement. Would there be a way to simplify that too?
The use of 'tests=lib/' is escaping my mind at the moment...
Collin
next prev parent reply other threads:[~2024-04-17 1:12 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 ` Collin Funk [this message]
2024-04-17 1:35 ` Refactoring rewrite_filename functions Bruno Haible
2024-04-17 2:08 ` Collin Funk
2024-04-17 14:03 ` Bruno Haible
2024-04-15 11:47 ` gnulib-tool.py: Remove a redundant function Bruno Haible
2024-04-15 14:07 ` 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=4f567b55-2b44-48a3-9cdb-1a8a9570d589@gmail.com \
--to=collin.funk1@gmail.com \
--cc=bruno@clisp.org \
--cc=bug-gnulib@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.
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).