From ec3d2f70a06e93b6cd730dd1f3629d5a6ad386fc Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Sun, 14 Apr 2024 18:09:39 -0700 Subject: [PATCH] gnulib-tool.py: Remove a redundant function. * pygnulib/GLImport.py (GLImport.rewrite_old_files): Remove function. (GLImport.rewrite_new_files): Rename to rewrite_files. (GLImport.prepare): Use rewrite_files instead of rewrite_old_files and rewrite_new_files. --- ChangeLog | 8 ++++++++ pygnulib/GLImport.py | 44 +++----------------------------------------- 2 files changed, 11 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b7b3a36fc..82c4a5f838 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-04-14 Collin Funk + + gnulib-tool.py: Remove a redundant function. + * pygnulib/GLImport.py (GLImport.rewrite_old_files): Remove function. + (GLImport.rewrite_new_files): Rename to rewrite_files. + (GLImport.prepare): Use rewrite_files instead of rewrite_old_files and + rewrite_new_files. + 2024-04-14 Collin Funk gnulib-tool.py: Fix incorrect type hint. diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index c6a4693c90..430691efbd 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -314,45 +314,7 @@ def __repr__(self) -> str: result = '' % hex(id(self)) return result - 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.''' - if type(files) is not list: - raise TypeError('files argument must has list type, not %s' - % type(files).__name__) - for file in files: - 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'] - result = [] - for file in files: - if file.startswith('build-aux/'): - path = constants.substart('build-aux/', '%s/' % auxdir, file) - elif file.startswith('doc/'): - path = constants.substart('doc/', '%s/' % docbase, file) - elif file.startswith('lib/'): - path = constants.substart('lib/', '%s/' % sourcebase, file) - elif file.startswith('m4/'): - path = constants.substart('m4/', '%s/' % m4base, file) - elif file.startswith('tests/'): - path = constants.substart('tests/', '%s/' % testsbase, file) - elif file.startswith('tests=lib/'): - path = constants.substart('tests=lib/', '%s/' % testsbase, file) - elif file.startswith('top/'): - path = constants.substart('top/', '', file) - else: # file is not a special file - path = file - result.append(os.path.normpath(path)) - return sorted(set(result)) - - def rewrite_new_files(self, files: list[str]) -> list[str]: + def rewrite_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: @@ -959,10 +921,10 @@ def prepare(self) -> tuple[dict[str, list[str]], dict[str, str]]: old_table = [] new_table = [] for src in old_files: - dest = self.rewrite_old_files([src])[-1] + dest = self.rewrite_files([src])[-1] old_table.append(tuple([dest, src])) for src in new_files: - dest = self.rewrite_new_files([src])[-1] + dest = self.rewrite_files([src])[-1] new_table.append(tuple([dest, src])) old_table = sorted(set(old_table)) new_table = sorted(set(new_table)) -- 2.44.0