bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnulib-tool.py: Remove a redundant function.


From: Collin Funk
Subject: gnulib-tool.py: Remove a redundant function.
Date: Sun, 14 Apr 2024 18:23:48 -0700
User-agent: Mozilla Thunderbird

The GLImport class has two functions that are the same,
GLImport.rewrite_old_files() and GLImport.rewrite_new_files().

The GLImport.rewrite_old_files() function does this extra step before
processing the list:

        files = [ '%s%s' % (file, os.path.sep)
                   for file in files ]

But before appending it to the resulting list os.path.normpath() is
used.

Since the following is true:

      os.path.normpath('abc') == 'abc'
      os.path.normpath('abc/') == 'abc'

both of these functions are the same.

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

Also, I noticed we have:

         for src in old_files:
             dest = self.rewrite_files([src])[-1]
             old_table.append(tuple([dest, src]))

This is looping over a list, creating a new list with one item,
calling GLImport.rewrite_files(), which then calls sorted(set(...))
twice, and then appending the result to a list.

We should be able to create a new list from that function and zip()
the two together. I'll submit another patch for that since it requires
some sorting changes.

Collin

Attachment: 0001-gnulib-tool.py-Remove-a-redundant-function.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]