]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool: Remove unused variables.
authorBruno Haible <bruno@clisp.org>
Tue, 2 Apr 2024 11:42:53 +0000 (13:42 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 2 Apr 2024 11:42:53 +0000 (13:42 +0200)
* pygnulib/GLConfig.py: Remove unused variables.
* pygnulib/GLEmiter.py: Likewise.
* pygnulib/GLFileSystem.py: Likewise.
* pygnulib/GLImport.py: Likewise.
* pygnulib/GLInfo.py: Likewise.
* pygnulib/GLModuleSystem.py: Likewise.
* pygnulib/GLTestDir.py: Likewise.
* pygnulib/main.py: Likewise.
* gnulib-tool.sh (func_emit_tests_Makefile_am): Remove unused variable
perhapsLT.

ChangeLog
gnulib-tool.sh
pygnulib/GLConfig.py
pygnulib/GLEmiter.py
pygnulib/GLFileSystem.py
pygnulib/GLImport.py
pygnulib/GLInfo.py
pygnulib/GLModuleSystem.py
pygnulib/GLTestDir.py
pygnulib/main.py

index 3efa3fab713fb6d01c89e691441e60e36b598276..5c51c941663046b56bdcf68b4d5fdad2abe6122f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2024-04-02  Bruno Haible  <bruno@clisp.org>
 
+       gnulib-tool: Remove unused variables.
+       * pygnulib/GLConfig.py: Remove unused variables.
+       * pygnulib/GLEmiter.py: Likewise.
+       * pygnulib/GLFileSystem.py: Likewise.
+       * pygnulib/GLImport.py: Likewise.
+       * pygnulib/GLInfo.py: Likewise.
+       * pygnulib/GLModuleSystem.py: Likewise.
+       * pygnulib/GLTestDir.py: Likewise.
+       * pygnulib/main.py: Likewise.
+       * gnulib-tool.sh (func_emit_tests_Makefile_am): Remove unused variable
+       perhapsLT.
+
        gnulib-tool.py: Remove no-op statements.
        * pygnulib/GLConfig.py (GLConfig.update): Remove no-op statement.
 
index 6b12542adc817194d994c77925a07614be0121a0..197744d8eddf7d0688f65e0b8a29b6d585c1024c 100755 (executable)
@@ -4173,11 +4173,9 @@ func_emit_tests_Makefile_am ()
   witness_macro="$1"
   if test "$libtool" = true; then
     libext=la
-    perhapsLT=LT
     sed_eliminate_LDFLAGS="$sed_noop"
   else
     libext=a
-    perhapsLT=
     sed_eliminate_LDFLAGS='/^lib_LDFLAGS[       ]*+=/d'
   fi
   # Replace NMD, so as to remove redundant "$(MKDIR_P) '.'" invocations.
index de720488c9e6572772c89b02e095afde6ce97f08..63d1d06b1c55f551f3956f516b2879af8f9687ed 100644 (file)
@@ -251,9 +251,6 @@ class GLConfig(object):
     def __getitem__(self, y: str) -> str | float | int | bool | CopyAction | list[str] | None:
         '''x.__getitem__(y) <==> x[y]'''
         if y in self.table:
-            result = self.table[y]
-            if type(y) is list:
-                result = list(self.table[y])
             if y == "auxdir":
                 if self.table['auxdir']:
                     return self.table['auxdir']
@@ -546,7 +543,7 @@ class GLConfig(object):
             for module in modules:
                 try:  # Try to add each module
                     self.addModule(module)
-                except TypeError as error:
+                except TypeError:
                     self.table['modules'] = old_modules
                     raise TypeError('each module must be a string')
                 except GLError:
@@ -592,7 +589,7 @@ class GLConfig(object):
             for module in modules:
                 try:  # Try to add each module
                     self.addAvoid(module)
-                except TypeError as error:
+                except TypeError:
                     self.table['avoids'] = old_avoids
                     raise TypeError('each module must be a string')
                 except GLError:
@@ -637,7 +634,7 @@ class GLConfig(object):
             for file in files:
                 try:  # Try to add each file
                     self.addFile(file)
-                except TypeError as error:
+                except TypeError:
                     self.table['files'] = old_files
                     raise TypeError('each file must be a string')
                 except GLError:
@@ -695,7 +692,7 @@ class GLConfig(object):
             for category in categories:
                 try:  # Try to enable each category
                     self.enableInclTestCategory(category)
-                except TypeError as error:
+                except TypeError:
                     self.table['incl_test_categories'] = old_categories
                     raise TypeError('each category must be one of TESTS integers')
         else:  # if type of categories is not list or tuple
@@ -743,7 +740,7 @@ class GLConfig(object):
             for category in categories:
                 try:  # Try to enable each category
                     self.enableExclTestCategory(category)
-                except TypeError as error:
+                except TypeError:
                     self.table['excl_test_categories'] = old_categories
                     raise TypeError('each category must be one of TESTS integers')
         else:  # if type of categories is not list or tuple
index aff00eddf6cc0acd9bfb6a35bb497535cd90091b..186d94bb92ff33b27ddfdd550354fda8311e447e 100644 (file)
@@ -308,7 +308,6 @@ class GLEmiter(object):
         if type(replace_auxdir) is not bool:
             raise TypeError('replace_auxdir must be a bool, not %s'
                             % type(replace_auxdir).__name__)
-        auxdir = self.config['auxdir']
         conddeps = self.config['conddeps']
         macro_prefix = self.config['macro_prefix']
         emit = ''
@@ -742,7 +741,6 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         witness_c_macro = self.config['witness_c_macro']
         include_guard_prefix = self.config['include_guard_prefix']
         module_indicator_prefix = self.config.getModuleIndicatorPrefix()
-        ac_version = self.config['ac_version']
         destfile = os.path.normpath(destfile)
         emit = ''
 
@@ -1030,29 +1028,23 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         sourcebase = self.config['sourcebase']
         libname = self.config['libname']
         m4base = self.config['m4base']
-        pobase = self.config['pobase']
         testsbase = self.config['testsbase']
         gnu_make = self.config['gnu_make']
-        makefile_name = self.config['makefile_name']
         libtool = self.config['libtool']
         macro_prefix = self.config['macro_prefix']
-        podomain = self.config['podomain']
         conddeps = self.config['conddeps']
         witness_c_macro = self.config['witness_c_macro']
         include_guard_prefix = self.config['include_guard_prefix']
         module_indicator_prefix = self.config.getModuleIndicatorPrefix()
-        ac_version = self.config['ac_version']
         libtests = self.config['libtests']
         single_configure = self.config['single_configure']
         emit = ''
 
         if libtool:
             libext = 'la'
-            perhapsLT = 'LT'
             eliminate_LDFLAGS = False
         else:  # if not libtool
             libext = 'a'
-            perhapsLT = ''
             eliminate_LDFLAGS = True
         if for_test:
             # When creating a package for testing: Attempt to provoke failures,
index 10b5ad6d59ec038b6ccc7a00db0a44532280ac55..40e7c7615d6b2117b2d94a54f0511990a709213c 100644 (file)
@@ -110,7 +110,7 @@ class GLFileSystem(object):
                 tempFile = joinpath(self.config['tempdir'], name)
                 try:  # Try to create directories
                     os.makedirs(os.path.dirname(tempFile))
-                except OSError as error:
+                except OSError:
                     pass  # Skip errors if directory exists
                 if isfile(tempFile):
                     os.remove(tempFile)
@@ -120,7 +120,7 @@ class GLFileSystem(object):
                     command = 'patch -s "%s" < "%s" >&2' % (tempFile, diff_in_localdir)
                     try:  # Try to apply patch
                         sp.check_call(command, shell=True)
-                    except sp.CalledProcessError as error:
+                    except sp.CalledProcessError:
                         raise GLError(2, name)
                 result = (tempFile, True)
             else:
@@ -260,7 +260,7 @@ class GLFileAssistant(object):
                 else:  # Move instead of linking.
                     try:  # Try to move file
                         movefile(tmpfile, joinpath(destdir, rewritten))
-                    except Exception as error:
+                    except Exception:
                         raise GLError(17, original)
         else:  # if self.config['dryrun']
             print('Copy file %s' % rewritten)
@@ -299,7 +299,7 @@ class GLFileAssistant(object):
                     os.remove(backuppath)
                 try:  # Try to replace the given file
                     movefile(basepath, backuppath)
-                except Exception as error:
+                except Exception:
                     raise GLError(17, original)
                 if self.filesystem.shouldLink(original, lookedup) == CopyAction.Symlink \
                         and not tmpflag and filecmp.cmp(lookedup, tmpfile):
@@ -313,7 +313,7 @@ class GLFileAssistant(object):
                             if os.path.exists(basepath):
                                 os.remove(basepath)
                             copyfile(tmpfile, joinpath(destdir, rewritten))
-                        except Exception as error:
+                        except Exception:
                             raise GLError(17, original)
             else:  # if self.config['dryrun']
                 if already_present:
@@ -337,14 +337,13 @@ class GLFileAssistant(object):
             xoriginal = substart('tests=lib/', 'lib/', original)
         lookedup, tmpflag = self.filesystem.lookup(xoriginal)
         tmpfile = self.tmpfilename(rewritten)
-        sed_transform_lib_file = self.transformers.get('lib')
         sed_transform_build_aux_file = self.transformers.get('aux')
         sed_transform_main_lib_file = self.transformers.get('main')
         sed_transform_testsrelated_lib_file = self.transformers.get('tests')
         try:  # Try to copy lookedup file to tmpfile
             copyfile(lookedup, tmpfile)
             ensure_writable(tmpfile)
-        except Exception as error:
+        except Exception:
             raise GLError(15, lookedup)
         # Don't process binary files with sed.
         if not (original.endswith(".class") or original.endswith(".mo")):
index 0adfd8a73c684fcf6ef77b5f300b1da8392b81fe..05ce82b7acc1cb7be55e051eabc344159274c847 100644 (file)
@@ -381,7 +381,6 @@ class GLImport(object):
         '''Return command-line invocation comment.'''
         modules = self.config.getModules()
         avoids = self.config.getAvoids()
-        destdir = self.config.getDestDir()
         localpath = self.config.getLocalPath()
         auxdir = self.config.getAuxDir()
         sourcebase = self.config.getSourceBase()
@@ -402,7 +401,6 @@ class GLImport(object):
         witness_c_macro = self.config.getWitnessCMacro()
         podomain = self.config.getPoDomain()
         vc_files = self.config.checkVCFiles()
-        verbose = self.config.getVerbosity()
 
         # Command-line invocation printed in a comment in generated gnulib-cache.m4.
         actioncmd = '# gnulib-tool --import'
@@ -605,29 +603,17 @@ class GLImport(object):
         if type(gentests) is not bool:
             raise TypeError(f'gentests should be a bool, not {type(gentests).__name__}')
         emit = ''
-        assistant = self.assistant
         moduletable = self.moduletable
-        destdir = self.config['destdir']
         auxdir = self.config['auxdir']
         sourcebase = self.config['sourcebase']
         m4base = self.config['m4base']
-        pobase = self.config['pobase']
-        docbase = self.config['docbase']
         testsbase = self.config['testsbase']
-        lgpl = self.config['lgpl']
         libname = self.config['libname']
-        gnu_make = self.config['gnu_make']
-        makefile_name = self.config['makefile_name']
-        conddeps = self.config['conddeps']
         libtool = self.config['libtool']
         macro_prefix = self.config['macro_prefix']
-        podomain = self.config['podomain']
         witness_c_macro = self.config['witness_c_macro']
         configure_ac = self.config['configure_ac']
-        vc_files = self.config['vc_files']
         libtests = self.config['libtests']
-        modules = [ str(module)
-                    for module in moduletable['base'] ]
         emit += '# DO NOT EDIT! GENERATED AUTOMATICALLY!\n'
         emit += self.emitter.copyright_notice()
         emit += '''#
@@ -820,24 +806,9 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         '''Make all preparations before the execution of the code.
         Returns filetable and sed transformers, which change the license.'''
         destdir = self.config['destdir']
-        auxdir = self.config['auxdir']
         modules = list(self.config['modules'])
-        sourcebase = self.config['sourcebase']
         m4base = self.config['m4base']
-        pobase = self.config['pobase']
-        docbase = self.config['docbase']
-        testsbase = self.config['testsbase']
         lgpl = self.config['lgpl']
-        libname = self.config['libname']
-        makefile_name = self.config['makefile_name']
-        conddeps = self.config['conddeps']
-        libtool = self.config['libtool']
-        macro_prefix = self.config['macro_prefix']
-        podomain = self.config['podomain']
-        witness_c_macro = self.config['witness_c_macro']
-        vc_files = self.config['vc_files']
-        configure_ac = self.config['configure_ac']
-        ac_version = self.config['ac_version']
         verbose = self.config['verbosity']
         base_modules = sorted(set([ self.modulesystem.find(m)
                                     for m in modules ]))
@@ -895,7 +866,6 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         # Check license incompatibilities.
         listing = list()
         compatibilities = dict()
-        incompatibilities = ''
         compatibilities['all'] = ['GPLv2+ build tool', 'GPLed build tool',
                                   'public domain', 'unlimited',
                                   'unmodifiable license text']
@@ -1007,26 +977,18 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
                 raise KeyError('filetable must contain key %s' % repr(key))
         destdir = self.config['destdir']
         auxdir = self.config['auxdir']
-        modules = list(self.config['modules'])
         sourcebase = self.config['sourcebase']
         m4base = self.config['m4base']
         pobase = self.config['pobase']
         docbase = self.config['docbase']
         testsbase = self.config['testsbase']
-        lgpl = self.config['lgpl']
         libname = self.config['libname']
         makefile_name = self.config['makefile_name']
         tests_makefile_name = self.config['tests_makefile_name']
         automake_subdir = self.config['automake_subdir']
-        conddeps = self.config['conddeps']
-        libtool = self.config['libtool']
         macro_prefix = self.config['macro_prefix']
-        podomain = self.config['podomain']
-        witness_c_macro = self.config['witness_c_macro']
         vc_files = self.config['vc_files']
         configure_ac = self.config['configure_ac']
-        ac_version = self.config['ac_version']
-        verbose = self.config['verbosity']
         actioncmd = self.actioncmd()
 
         # Determine whether to put anything into $testsbase.
@@ -1056,7 +1018,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
                 if not self.config['dryrun']:
                     try:  # Try to create directory
                         os.makedirs(directory)
-                    except Exception as error:
+                    except Exception:
                         raise GLError(13, directory)
                 else:  # if self.config['dryrun']
                     print('Create directory %s' % directory)
@@ -1081,7 +1043,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
                         if os.path.exists(backup):
                             os.remove(backup)
                         movefile(path, '%s~' % path)
-                    except Exception as error:
+                    except Exception:
                         raise GLError(14, file)
                 else:  # if self.config['dryrun']
                     print('Remove file %s (backup in %s~)' % (path, path))
@@ -1119,9 +1081,6 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         filetable['added'] += self.assistant.getFiles()
         filetable['added'] = sorted(set(filetable['added']))
 
-        # Determine include_guard_prefix.
-        include_guard_prefix = self.config['include_guard_prefix']
-
         # Default the source makefile name to Makefile.am.
         if makefile_name:
             source_makefile_am = makefile_name
@@ -1139,7 +1098,6 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         # Setup list of Makefile.am edits that are to be performed afterwards.
         # Some of these edits apply to files that we will generate; others are
         # under the responsibility of the developer.
-        makefile_am_edits = dict()
         if source_makefile_am == 'Makefile.am':
             sourcebase_dir = os.path.dirname(sourcebase)
             sourcebase_base = os.path.basename(sourcebase)
index ff96e93999e60a6a41ccc802a8f1bea446f3006f..4dd8dd6e354b00594056efb4d586e9a9b77c34db 100644 (file)
@@ -120,7 +120,6 @@ class GLInfo(object):
                     result = result.rstrip(os.linesep)
                     return result
         # gnulib copy without versioning information.
-        first_changelog_line = None
         with codecs.open(os.path.join(DIRS['root'], 'ChangeLog'), 'rb', 'UTF-8') as file:
             line = file.readline()
             first_changelog_line = line.rstrip()
index ba92d8a9338e3683a9e6007abdaae361fee4c17d..c0ea65676f5725b1c89a29e226fcbce4eb389f6c 100644 (file)
@@ -130,7 +130,6 @@ class GLModuleSystem(object):
         of os.walk() function and re module. However, it takes too much time to
         complete, so this version uses subprocess to run shell commands.'''
         result = ''
-        listing = list()
         localpath = self.config['localpath']
         find_args = ['find', 'modules', '-type', 'f', '-print']
 
@@ -489,8 +488,7 @@ class GLModule(object):
         return self.sections.get('Files', '')
 
     def getFiles(self) -> list[str]:
-        '''Return list of files.
-        GLConfig: ac_version.'''
+        '''Return list of files.'''
         if 'files' not in self.cache:
             snippet = self.getFiles_Raw()
             result = [ line.strip()
@@ -575,7 +573,7 @@ class GLModule(object):
 
     def getAutomakeSnippet(self) -> str:
         '''Get automake snippet.
-        GLConfig: auxdir, ac_version.'''
+        GLConfig: auxdir.'''
         result = ''
         conditional = self.getAutomakeSnippet_Conditional()
         if conditional.strip():
@@ -591,9 +589,8 @@ class GLModule(object):
 
     def getAutomakeSnippet_Unconditional(self) -> str:
         '''Return unconditional automake snippet.
-        GLConfig: auxdir, ac_version.'''
+        GLConfig: auxdir'''
         auxdir = self.config['auxdir']
-        ac_version = self.config['ac_version']
         result = ''
         if 'makefile-unconditional' not in self.cache:
             if self.getName().endswith('-tests'):
@@ -1015,9 +1012,7 @@ class GLModuleTable(object):
     def add_dummy(self, modules: list[GLModule]) -> list[GLModule]:
         '''Add dummy package to list of modules if dummy package is needed.
         If not, return original list of modules.
-        GLConfig: auxdir, ac_version, conddeps.'''
-        auxdir = self.config['auxdir']
-        ac_version = self.config['ac_version']
+        GLConfig: conddeps.'''
         conddeps = self.config['conddeps']
         for module in modules:
             if type(module) is not GLModule:
@@ -1053,9 +1048,7 @@ class GLModuleTable(object):
 
     def filelist(self, modules: list[GLModule]) -> list[str]:
         '''Determine the final file list for the given list of modules.
-        The list of modules must already include dependencies.
-        GLConfig: ac_version.'''
-        ac_version = self.config['ac_version']
+        The list of modules must already include dependencies.'''
         filelist = list()
         for module in modules:
             if type(module) is not GLModule:
@@ -1074,7 +1067,6 @@ class GLModuleTable(object):
         files in lib/* go into $sourcebase/ if they are in the main file list but
         into $testsbase/ if they are in the tests-related file list. Furthermore
         lib/dummy.c can be in both.'''
-        ac_version = self.config['ac_version']
         main_filelist = self.filelist(main_modules)
         tests_filelist = self.filelist(tests_modules)
         tests_filelist = [ file.replace('lib/', 'tests=lib/', 1) if file.startswith('lib/') else file
index f0fe993c58f4f496a426e2475aa6fb5221241488..12fe48685953f51555ef2ddebeb35a82d98da921 100644 (file)
@@ -111,7 +111,7 @@ class GLTestDir(object):
         if not os.path.exists(self.testdir):
             try:  # Try to create directory
                 os.mkdir(self.testdir)
-            except Exception as error:
+            except Exception:
                 raise GLError(19, self.testdir)
         self.emitter = GLEmiter(self.config)
         self.filesystem = GLFileSystem(self.config)
@@ -172,14 +172,10 @@ class GLTestDir(object):
         auxdir = self.config['auxdir']
         sourcebase = self.config['sourcebase']
         m4base = self.config['m4base']
-        pobase = self.config['pobase']
-        docbase = self.config['docbase']
         testsbase = self.config['testsbase']
         libname = self.config['libname']
         libtool = self.config['libtool']
-        witness_c_macro = self.config['witness_c_macro']
         single_configure = self.config['single_configure']
-        include_guard_prefix = self.config['include_guard_prefix']
         macro_prefix = self.config['macro_prefix']
         verbose = self.config['verbosity']
 
@@ -417,7 +413,6 @@ class GLTestDir(object):
         subdirs = [sourcebase, m4base]
         subdirs_with_configure_ac = list()
 
-        testsbase_append = False
         inctests = self.config.checkInclTestCategory(TESTS['tests'])
         if inctests:
             directory = joinpath(self.testdir, testsbase)
@@ -540,7 +535,6 @@ class GLTestDir(object):
                 subdirs_with_configure_ac += [testsbase]
 
             subdirs += [testsbase]
-            testsbase_append = True
 
         # Create Makefile.am.
         emit = '## Process this file with automake to produce Makefile.in.\n\n'
@@ -905,7 +899,7 @@ class GLMegaTestDir(object):
         if not os.path.exists(self.megatestdir):
             try:  # Try to create directory
                 os.mkdir(self.megatestdir)
-            except Exception as error:
+            except Exception:
                 raise GLError(19, self.megatestdir)
         self.emitter = GLEmiter(self.config)
         self.filesystem = GLFileSystem(self.config)
@@ -1033,7 +1027,7 @@ class GLMegaTestDir(object):
             if not isdir('build-aux'):
                 print('executing mkdir build-aux')
                 os.mkdir('build-aux')
-        except Exception as error:
+        except Exception:
             pass
         args = [UTILS['autoconf']]
         constants.execute(args, verbose)
index a57e5b04a38368ff2ac43a2222e1ab3ba4d4f46f..c6a6bd3241e1c833b8112ce47a51f1c80c0f5f20 100644 (file)
@@ -1100,7 +1100,7 @@ def main() -> None:
             sp.call([UTILS['make']])
             sp.call([UTILS['make'], 'check'])
             sp.call([UTILS['make'], 'distclean'])
-        except Exception as error:
+        except Exception:
             sys.exit(1)
         args = ['find', '.', '-type', 'f', '-print']
         remaining = sp.check_output(args).decode(ENCS['shell'])