* pygnulib/GLModuleSystem.py (GLModule.getName): Remove function.
(GLModule.__str__, GLModule.__repr__, GLModule.isNonTests)
(GLModule.repeatModuleInTests, GLModule.getDependenciesRecursively)
(GLModule.getShellFunc, GLModule.getShellVar)
(GLModule.getConditionalName, GLModule.getApplicability)
(GLModule.getDependencies, GLModule.getAutomakeSnippet_Unconditional)
(GLModule.getLicense, GLModuleSystem.find)
(GLModuleTable.transitive_closure): Use the GLModule's name instance
variable instead of using str() or removed getName() function.
* pygnulib/GLEmiter.py (GLEmiter.autoconfSnippet)
(GLEmiter.preEarlyMacros, GLEmiter.lib_Makefile_am)
(GLEmiter.tests_Makefile_am): Likewise.
* pygnulib/GLImport.py (GLImport.gnulib_comp, GLImport.prepare):
Likewise.
* pygnulib/GLTestDir.py (GLTestDir.execute, GLMegaTestDir.execute):
Likewise.
+2024-05-01 Collin Funk <collin.funk1@gmail.com>
+
+ gnulib-tool.py: Use the GLModule's name variable directly.
+ * pygnulib/GLModuleSystem.py (GLModule.getName): Remove function.
+ (GLModule.__str__, GLModule.__repr__, GLModule.isNonTests)
+ (GLModule.repeatModuleInTests, GLModule.getDependenciesRecursively)
+ (GLModule.getShellFunc, GLModule.getShellVar)
+ (GLModule.getConditionalName, GLModule.getApplicability)
+ (GLModule.getDependencies, GLModule.getAutomakeSnippet_Unconditional)
+ (GLModule.getLicense, GLModuleSystem.find)
+ (GLModuleTable.transitive_closure): Use the GLModule's name instance
+ variable instead of using str() or removed getName() function.
+ * pygnulib/GLEmiter.py (GLEmiter.autoconfSnippet)
+ (GLEmiter.preEarlyMacros, GLEmiter.lib_Makefile_am)
+ (GLEmiter.tests_Makefile_am): Likewise.
+ * pygnulib/GLImport.py (GLImport.gnulib_comp, GLImport.prepare):
+ Likewise.
+ * pygnulib/GLTestDir.py (GLTestDir.execute, GLMegaTestDir.execute):
+ Likewise.
+
2024-04-30 Paul Eggert <eggert@cs.ucla.edu>
intprops: document fix for GCC bug 68193
libtool = self.config['libtool']
include_guard_prefix = self.config['include_guard_prefix']
emit = ''
- if str(module) in ['gnumakefile', 'maintainer-makefile']:
+ if module.name in ['gnumakefile', 'maintainer-makefile']:
# These modules are meant to be used only in the top-level directory.
flag = toplevel
- else: # if str(module) not in ['gnumakefile', 'maintainer-makefile']
+ else: # if module.name not in ['gnumakefile', 'maintainer-makefile']
flag = True
if flag:
snippet = module.getAutoconfSnippet()
# autopoint through at least GNU gettext version 0.18.2.
snippet = re.compile(r'^ *AM_GNU_GETTEXT_VERSION', re.M).sub(r'AM_GNU_GETTEXT_VERSION', snippet)
emit += snippet
- if str(module) == 'alloca' and libtool and not disable_libtool:
+ if module.name == 'alloca' and libtool and not disable_libtool:
emit += 'changequote(,)dnl\n'
emit += "LTALLOCA=`echo \"$ALLOCA\" | sed -e 's/\\.[^.]* /.lo /g;s/\\.[^.]*$/.lo/'`\n"
emit += 'changequote([, ])dnl\n'
emit = '\n' + indentation + '# Pre-early section.\n'
# We need to call gl_USE_SYSTEM_EXTENSIONS before gl_PROG_AR_RANLIB.
# Doing AC_REQUIRE in configure-ac.early is not early enough.
- if any(str(module) == 'extensions' for module in modules):
+ if any(module.name == 'extensions' for module in modules):
if require:
emit += indentation + 'AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])\n'
else:
amsnippet1 = amsnippet1.replace('check_PROGRAMS', 'noinst_PROGRAMS')
amsnippet1 = amsnippet1.replace('${gl_include_guard_prefix}',
include_guard_prefix)
- if str(module) == 'alloca':
+ if module.name == 'alloca':
amsnippet1 += '%s_%s_LIBADD += @%sALLOCA@\n' % (libname, libext, perhapsLT)
amsnippet1 += '%s_%s_DEPENDENCIES += @%sALLOCA@\n' % (libname, libext, perhapsLT)
amsnippet1 = combine_lines_matching(re.compile(r'%s_%s_SOURCES' % (libname, libext)),
'$(' + module_indicator_prefix + '_GNULIB_')
# Skip the contents if it's entirely empty.
if (amsnippet1 + amsnippet2).strip() != '':
- allsnippets += '## begin gnulib module %s\n' % str(module)
+ allsnippets += '## begin gnulib module %s\n' % module.name
if gnu_make:
- allsnippets += 'ifeq (,$(OMIT_GNULIB_MODULE_%s))\n' % str(module)
+ allsnippets += 'ifeq (,$(OMIT_GNULIB_MODULE_%s))\n' % module.name
allsnippets += '\n'
if conddeps:
if moduletable.isConditional(module):
allsnippets += amsnippet2
if gnu_make:
allsnippets += 'endif\n'
- allsnippets += '## end gnulib module %s\n\n' % str(module)
+ allsnippets += '## end gnulib module %s\n\n' % module.name
# Test whether there are some source files in subdirectories.
for file in module.getFiles():
amsnippet1 = amsnippet1.replace('${gl_include_guard_prefix}',
include_guard_prefix)
# Check if module is 'alloca'.
- if libtests and str(module) == 'alloca':
+ if libtests and module.name == 'alloca':
amsnippet1 += 'libtests_a_LIBADD += @ALLOCA@\n'
amsnippet1 += 'libtests_a_DEPENDENCIES += @ALLOCA@\n'
'$(' + module_indicator_prefix + '_GNULIB_')
# Skip the contents if it's entirely empty.
if (amsnippet1 + amsnippet2).strip() != '':
- snippet = '## begin gnulib module %s\n' % str(module)
+ snippet = '## begin gnulib module %s\n' % module.name
if gnu_make:
- snippet += 'ifeq (,$(OMIT_GNULIB_MODULE_%s))\n' % str(module)
+ snippet += 'ifeq (,$(OMIT_GNULIB_MODULE_%s))\n' % module.name
snippet += '\n'
if conddeps:
if moduletable.isConditional(module):
snippet += amsnippet2
if gnu_make:
snippet += 'endif\n'
- snippet += '## end gnulib module %s\n\n' % str(module)
+ snippet += '## end gnulib module %s\n\n' % module.name
# Mention long-running tests at the end.
if 'longrunning-test' in module.getStatuses():
longrun_snippets += snippet
m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable\n''' % (configure_ac, macro_prefix)
emit += self.emitter.preEarlyMacros(True, ' ', moduletable.getFinalModules())
for module in moduletable.getFinalModules():
- emit += ' # Code from module %s:\n' % str(module)
+ emit += ' # Code from module %s:\n' % module.name
snippet = module.getAutoconfEarlySnippet()
lines = [ line
for line in snippet.split('\n')
(bold_on, bold_off) = bold_escapes()
print('Module list with included dependencies (indented):')
for module in final_modules:
- if str(module) in self.config.getModules():
- print(' %s%s%s' % (bold_on, module, bold_off))
- else: # if str(module) not in self.config.getModules()
- print(' %s' % module)
+ if module.name in self.config.getModules():
+ print(' %s%s%s' % (bold_on, module.name, bold_off))
+ else: # if module.name not in self.config.getModules()
+ print(' %s' % module.name)
# Separate modules into main_modules and tests_modules.
modules = \
if verbose >= 1:
print('Main module list:')
for module in main_modules:
- print(' %s' % str(module))
+ print(' %s' % module.name)
print('Tests-related module list:')
for module in tests_modules:
- print(' %s' % str(module))
+ print(' %s' % module.name)
# Determine whether a $testsbase/libtests.a is needed.
libtests = False
if license not in compatibilities['all']:
if lgpl == True:
if license not in compatibilities['3']:
- listing.append(tuple([str(module), license]))
+ listing.append(tuple([module.name, license]))
else:
if license not in compatibilities[lgpl]:
- listing.append(tuple([str(module), license]))
+ listing.append(tuple([module.name, license]))
if listing:
raise GLError(11, listing)
for module in main_modules:
notice = module.getNotice().strip('\n')
if notice:
- print('Notice from module %s:' % str(module))
+ print('Notice from module %s:' % module.name)
pattern = re.compile(r'^(.*?)$', re.S | re.M)
notice = pattern.sub(r' \1', notice)
print(notice)
# Determine script to apply to imported library files.
sed_transform_lib_file = None
- if 'config-h' in [ str(module)
+ if 'config-h' in [ module.name
for module in main_modules ]:
sed_transform_lib_file = (re.compile(r'^#ifdef[\t ]*HAVE_CONFIG_H[\t ]*$', re.MULTILINE), r'#if 1')
raise GLError(3, module)
else: # if not self.config['errors']
sys.stderr.write('gnulib-tool: warning: ')
- sys.stderr.write("module %s doesn't exist\n" % str(module))
+ sys.stderr.write("module %s doesn't exist\n" % module.name)
def file_is_module(self, filename: str) -> bool:
'''Given the name of a file in the modules/ directory, return true
def __str__(self) -> str:
'''x.__str__() <==> str(x)'''
- result = self.getName()
- return result
+ return self.name
def __repr__(self) -> str:
'''x.__repr__ <==> repr(x)'''
- result = '<pygnulib.GLModule %s %s>' % (repr(self.getName()), hex(id(self)))
+ result = '<pygnulib.GLModule %s %s>' % (repr(self.name), hex(id(self)))
return result
- def getName(self) -> str:
- '''Return the name of the module.'''
- return self.name
-
def isPatched(self) -> bool:
'''Check whether module was created after applying patch.'''
return self.patched
def isNonTests(self) -> bool:
'''Check whether module is not a *-tests module.'''
- result = not self.getName().endswith('-tests')
+ result = not self.name.endswith('-tests')
return result
def getTestsName(self) -> str:
# tests contain such an invocation, the module - as part of tests -
# will produce different AC_SUBSTed variable values than the same module
# - as part of the main configure.ac -.
- result = self.getName() == 'libtextstyle-optional'
+ result = self.name == 'libtextstyle-optional'
return result
def getDependenciesRecursively(self) -> str:
# Remove handledmodules from inmodules.
inmodules = inmodules.difference(handledmodules)
- module_names = sorted([ str(module)
+ module_names = sorted([ module.name
for module in outmodules ])
return lines_to_multiline(module_names)
for the module.'''
macro_prefix = self.config['macro_prefix']
valid_shell_id = True
- for char in self.getName():
+ for char in self.name:
if char not in GLModule.shell_id_chars:
valid_shell_id = False
break
if valid_shell_id:
- identifier = self.getName()
+ identifier = self.name
else:
- hash_input = '%s\n' % self.getName()
+ hash_input = '%s\n' % self.name
identifier = hashlib.md5(hash_input.encode(ENCS['default'])).hexdigest()
result = 'func_%s_gnulib_m4code_%s' % (macro_prefix, identifier)
return result
m4 macros for the module have been executed.'''
macro_prefix = self.config['macro_prefix']
valid_shell_id = True
- for char in self.getName():
+ for char in self.name:
if char not in GLModule.shell_id_chars:
valid_shell_id = False
break
if valid_shell_id:
- identifier = self.getName()
+ identifier = self.name
else:
- hash_input = '%s\n' % self.getName()
+ hash_input = '%s\n' % self.name
identifier = hashlib.md5(hash_input.encode(ENCS['default'])).hexdigest()
result = '%s_gnulib_enabled_%s' % (macro_prefix, identifier)
return result
GLConfig: macro_prefix.'''
macro_prefix = self.config['macro_prefix']
valid_shell_id = True
- for char in self.getName():
+ for char in self.name:
if char not in GLModule.shell_id_chars:
valid_shell_id = False
break
if valid_shell_id:
- identifier = self.getName()
+ identifier = self.name
else:
- hash_input = '%s\n' % self.getName()
+ hash_input = '%s\n' % self.name
identifier = hashlib.md5(hash_input.encode(ENCS['default'])).hexdigest()
result = '%s_GNULIB_ENABLED_%s' % (macro_prefix, identifier)
return result
result = result.strip()
if not result:
# The default is 'main' or 'tests', depending on the module's name.
- if self.getName().endswith('-tests'):
+ if self.name.endswith('-tests'):
result = 'tests'
else:
result = 'main'
if 'dependencies' not in self.cache:
result = ''
# ${module}-tests implicitly depends on ${module}, if that module exists.
- if self.getName().endswith('-tests'):
- main_module = subend('-tests', '', self.getName())
+ if self.name.endswith('-tests'):
+ main_module = subend('-tests', '', self.name)
if self.modulesystem.exists(main_module):
result += '%s\n' % main_module
# Then the explicit dependencies listed in the module description.
auxdir = self.config['auxdir']
result = ''
if 'makefile-unconditional' not in self.cache:
- if self.getName().endswith('-tests'):
+ if self.name.endswith('-tests'):
# *-tests module live in tests/, not lib/.
# Synthesize an EXTRA_DIST augmentation.
files = self.getFiles()
# If some .c file exists and is not used with AC_LIBOBJ - for example,
# a .c file is preprocessed into another .c file for BUILT_SOURCES -,
# automake will generate a useless dependency; this is harmless.
- if str(self) != 'relocatable-prog-wrapper' and str(self) != 'pt_chown':
+ if self.name != 'relocatable-prog-wrapper' and self.name != 'pt_chown':
extra_files = filter_filelist('\n', extra_files,
'', '.c', '', '')
if extra_files != '':
if 'license' not in self.cache:
license = self.getLicense_Raw().strip()
# Warn if the License field is missing.
- if not self.getName().endswith('-tests'):
+ if not self.name.endswith('-tests'):
if not license:
if self.config['errors']:
- raise GLError(18, str(self))
+ raise GLError(18, self.name)
else: # if not self.config['errors']
- sys.stderr.write('gnulib-tool: warning: module %s lacks a License\n' % str(self))
- if str(self).startswith('parse-datetime'):
+ sys.stderr.write('gnulib-tool: warning: module %s lacks a License\n' % self.name)
+ if self.name.startswith('parse-datetime'):
# These modules are under a weaker license only for the purpose of some
# users who hand-edit it and don't use gnulib-tool. For the regular
# gnulib users they are under a stricter license.
for depmodule in set(depmodules)
if depmodules.count(depmodule) > 1 ]
if duplicate_depmodules:
- duplicate_depmodule_names = [ str(depmodule)
+ duplicate_depmodule_names = [ depmodule.name
for depmodule in duplicate_depmodules ]
message = ('gnulib-tool: warning: module %s has duplicated dependencies: %s\n'
% (module, duplicate_depmodule_names))
if verbose >= 0:
(bold_on, bold_off) = bold_escapes()
print('Module list with included dependencies (indented):')
- specified_modules_set = { str(module)
+ specified_modules_set = { module.name
for module in specified_modules }
for module in final_modules:
- if str(module) in specified_modules_set:
- print(' %s%s%s' % (bold_on, module, bold_off))
- else: # if str(module) not in specified_modules_set
- print(' %s' % module)
+ if module.name in specified_modules_set:
+ print(' %s%s%s' % (bold_on, module.name, bold_off))
+ else: # if module.name not in specified_modules_set
+ print(' %s' % module.name)
# Generate lists of the modules.
if single_configure:
if verbose >= 1:
print('Main module list:')
for module in main_modules:
- print(' %s' % str(module))
+ print(' %s' % module.name)
print('Tests-related module list:')
for module in tests_modules:
- print(' %s' % str(module))
+ print(' %s' % module.name)
# Determine whether a $testsbase/libtests.a is needed.
libtests = False
for module in tests_modules:
for module in main_modules:
notice = module.getNotice().strip('\n')
if notice:
- print('Notice from module %s:' % str(module))
+ print('Notice from module %s:' % module.name)
pattern = re.compile(r'^(.*)$', re.M)
notice = pattern.sub(r' \1', notice)
print(notice)
for module in modules:
notice = module.getNotice().strip('\n')
if notice:
- print('Notice from module %s:' % str(module))
+ print('Notice from module %s:' % module.name)
pattern = re.compile(r'^(.*)$', re.M)
notice = pattern.sub(r' \1', notice)
print(notice)
emit += self.emitter.preEarlyMacros(False, '', modules)
snippets = []
for module in modules:
- if str(module) in ['gnumakefile', 'maintainer-makefile']:
+ if module.name in ['gnumakefile', 'maintainer-makefile']:
# These are meant to be used only in the top-level directory.
pass
- # if str(module) not in ['gnumakefile', 'maintainer-makefile']
+ # if module.name not in ['gnumakefile', 'maintainer-makefile']
else:
snippet = module.getAutoconfEarlySnippet()
lines = [ line
# First, all modules one by one.
for module in modules:
- self.config.setModules([str(module)])
- GLTestDir(self.config, joinpath(self.megatestdir, str(module))).execute()
- megasubdirs.append(str(module))
+ self.config.setModules([module.name])
+ GLTestDir(self.config, joinpath(self.megatestdir, module.name)).execute()
+ megasubdirs.append(module.name)
# Then, all modules all together.
# Except config-h, which breaks all modules which use HAVE_CONFIG_H.
modules = [ module
for module in modules
- if str(module) != 'config-h' ]
- self.config.setModules([ str(module)
+ if module.name != 'config-h' ]
+ self.config.setModules([ module.name
for module in modules ])
GLTestDir(self.config, joinpath(self.megatestdir, 'ALL')).execute()
megasubdirs.append('ALL')