* 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.
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.
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.
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']
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:
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:
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:
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
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
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 = ''
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 = ''
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,
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)
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:
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)
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):
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:
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")):
'''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()
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'
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 += '''#
'''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 ]))
# Check license incompatibilities.
listing = list()
compatibilities = dict()
- incompatibilities = ''
compatibilities['all'] = ['GPLv2+ build tool', 'GPLed build tool',
'public domain', 'unlimited',
'unmodifiable license text']
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.
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)
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))
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
# 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)
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()
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']
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()
def getAutomakeSnippet(self) -> str:
'''Get automake snippet.
- GLConfig: auxdir, ac_version.'''
+ GLConfig: auxdir.'''
result = ''
conditional = self.getAutomakeSnippet_Conditional()
if conditional.strip():
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'):
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:
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:
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
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)
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']
subdirs = [sourcebase, m4base]
subdirs_with_configure_ac = list()
- testsbase_append = False
inctests = self.config.checkInclTestCategory(TESTS['tests'])
if inctests:
directory = joinpath(self.testdir, testsbase)
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'
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)
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)
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'])