* gnulib-tool.py: Break lines before the % operator, not after.
* pygnulib/*.py: Likewise. Avoid line breaks when the resulting lines
are not too long.
2022-08-04 Bruno Haible <bruno@clisp.org>
+ gnulib-tool.py: Use mainstream/GNU coding style.
+ * gnulib-tool.py: Break lines before the % operator, not after.
+ * pygnulib/*.py: Likewise. Avoid line breaks when the resulting lines
+ are not too long.
+
gnulib-tool.py: Follow gnulib-tool changes, part 24.
Follow gnulib-tool change
2017-02-19 Bruno Haible <bruno@clisp.org>
print(info.usage())
sys.exit(0)
if cmdargs.version != None:
- message = '''gnulib-tool (%s %s)%s\n%s\n%s\n\nWritten by %s.''' % \
- (info.package(), info.date(), info.version(), info.copyright(),
- info.license(), info.authors())
+ message = '''gnulib-tool (%s %s)%s\n%s\n%s\n\nWritten by %s.''' \
+ % (info.package(), info.date(), info.version(), info.copyright(),
+ info.license(), info.authors())
print(message)
sys.exit(0)
else: # if libtool
self.enableLibtool()
else: # if type(libtool) is not bool
- raise TypeError('libtool must be a bool, not %s' %
- type(libtool).__name__)
+ raise TypeError('libtool must be a bool, not %s'
+ % type(libtool).__name__)
# conddeps
self.resetCondDeps()
if conddeps != None:
else: # if conddeps
self.enableCondDeps()
else: # if type(conddeps) is not bool
- raise TypeError('conddeps must be a bool, not %s' %
- type(conddeps).__name__)
+ raise TypeError('conddeps must be a bool, not %s'
+ % type(conddeps).__name__)
# macro_prefix
self.resetMacroPrefix()
if macro_prefix != None:
else: # if witness_c_macro
self.resetWitnessCMacro()
else: # if type(witness_c_macro) is not bool
- raise TypeError('witness_c_macro must be a bool, not %s' %
- type(witness_c_macro).__name__)
+ raise TypeError('witness_c_macro must be a bool, not %s'
+ % type(witness_c_macro).__name__)
# vc_files
self.resetVCFiles()
if vc_files != None:
else: # if vc_files
self.enableVCFiles()
else: # if type(vc_files) is not bool
- raise TypeError('vc_files must be a bool, not %s' %
- type(vc_files).__name__)
+ raise TypeError('vc_files must be a bool, not %s'
+ % type(vc_files).__name__)
# symbolic
self.resetSymbolic()
if symbolic != None:
else: # if symbolic
self.enableSymbolic()
else: # if type(symbolic) is not bool
- raise TypeError('symbolic must be a bool, not %s' %
- type(symbolic).__name__)
+ raise TypeError('symbolic must be a bool, not %s'
+ % type(symbolic).__name__)
# lsymbolic
self.resetLSymbolic()
if lsymbolic != None:
else: # if lsymbolic
self.enableLSymbolic()
else: # if type(lsymbolic) is not bool
- raise TypeError('lsymbolic must be a bool, not %s' %
- type(lsymbolic).__name__)
+ raise TypeError('lsymbolic must be a bool, not %s'
+ % type(lsymbolic).__name__)
# modcache
self.resetModuleCaching()
if modcache != None:
else: # if modcache
self.enableModuleCaching()
else: # if type(modcache) is not bool
- raise TypeError('modcache must be a bool, not %s' %
- type(modcache).__name__)
+ raise TypeError('modcache must be a bool, not %s'
+ % type(modcache).__name__)
# configure_ac
self.resetAutoconfFile()
if configure_ac != None:
else: # if libtests
self.enableLibtests()
else: # if type(libtests) is not bool
- raise TypeError('libtests must be a bool, not %s' %
- type(libtests).__name__)
+ raise TypeError('libtests must be a bool, not %s'
+ % type(libtests).__name__)
# single_configure
self.resetSingleConfigure()
if single_configure != None:
else: # if single_configure
self.enableSingleConfigure()
else: # if type(single_configure) is not bool
- raise TypeError('single_configure must be a bool, not %s' %
- type(single_configure).__name__)
+ raise TypeError('single_configure must be a bool, not %s'
+ % type(single_configure).__name__)
# verbose
self.resetVerbosity()
if verbose != None:
else: # if dryrun
self.enableDryRun()
else: # if type(dryrun) is not bool
- raise TypeError('dryrun must be a bool, not %s' %
- type(dryrun).__name__)
+ raise TypeError('dryrun must be a bool, not %s'
+ % type(dryrun).__name__)
# errors
self.resetErrors()
if errors != None:
else: # if errors
self.enableErrors()
else: # if type(errors) is not bool
- raise TypeError('errors must be a bool, not %s' %
- type(errors).__name__)
+ raise TypeError('errors must be a bool, not %s'
+ % type(errors).__name__)
# Define special methods.
def __repr__(self):
def update(self, dictionary):
'''Specify the dictionary whose keys will be used to update config.'''
if type(dictionary) is not GLConfig:
- raise TypeError('dictionary must be a GLConfig, not %s' %
- type(dictionary).__name__)
+ raise TypeError('dictionary must be a GLConfig, not %s'
+ % type(dictionary).__name__)
dictionary = dict(dictionary.table)
result = dict()
for key in dictionary:
'''Update the given key using value from the given dictionary.'''
if key in self.table:
if type(dictionary) is not GLConfig:
- raise TypeError('dictionary must be a GLConfig, not %s' %
- type(dictionary).__name__)
+ raise TypeError('dictionary must be a GLConfig, not %s'
+ % type(dictionary).__name__)
dictionary = dict(dictionary.table)
self.table[key] = dictionary[key]
else: # if key not in self.table
if destdir:
self.table['destdir'] = os.path.normpath(destdir)
else: # if destdir has not str type
- raise TypeError('destdir must be a string, not %s' %
- type(destdir).__name__)
+ raise TypeError('destdir must be a string, not %s'
+ % type(destdir).__name__)
def resetDestDir(self):
'''Reset the target directory. For --import, this specifies where your
if auxdir:
self.table['auxdir'] = remove_trailing_slashes(auxdir)
else: # if type of auxdir is not str
- raise TypeError('auxdir must be a string, not %s' %
- type(auxdir).__name__)
+ raise TypeError('auxdir must be a string, not %s'
+ % type(auxdir).__name__)
def resetAuxDir(self):
'''Reset directory relative to --dir where auxiliary build tools are
if sourcebase:
self.table['sourcebase'] = remove_trailing_slashes(sourcebase)
else: # if type of sourcebase is not str
- raise TypeError('sourcebase must be a string, not %s' %
- type(sourcebase).__name__)
+ raise TypeError('sourcebase must be a string, not %s'
+ % type(sourcebase).__name__)
def resetSourceBase(self):
'''Return directory relative to destdir where source code is placed.'''
if m4base:
self.table['m4base'] = remove_trailing_slashes(m4base)
else: # if type of m4base is not str
- raise TypeError('m4base must be a string, not %s' %
- type(m4base).__name__)
+ raise TypeError('m4base must be a string, not %s'
+ % type(m4base).__name__)
def resetM4Base(self):
'''Reset directory relative to destdir where *.m4 macros are placed.'''
if pobase:
self.table['pobase'] = remove_trailing_slashes(pobase)
else: # if type of pobase is not str
- raise TypeError('pobase must be a string, not %s' %
- type(pobase).__name__)
+ raise TypeError('pobase must be a string, not %s'
+ % type(pobase).__name__)
def resetPoBase(self):
'''Reset directory relative to destdir where *.po files are placed.'''
if docbase:
self.table['docbase'] = remove_trailing_slashes(docbase)
else: # if type of docbase is not str
- raise TypeError('docbase must be a string, not %s' %
- type(docbase).__name__)
+ raise TypeError('docbase must be a string, not %s'
+ % type(docbase).__name__)
def resetDocBase(self):
'''Reset directory relative to destdir where doc files are placed.
if testsbase:
self.table['testsbase'] = remove_trailing_slashes(testsbase)
else: # if type of testsbase is not str
- raise TypeError('testsbase must be a string, not %s' %
- type(testsbase).__name__)
+ raise TypeError('testsbase must be a string, not %s'
+ % type(testsbase).__name__)
def resetTestsBase(self):
'''Reset directory relative to destdir where unit tests are placed.
if module not in self.table['modules']:
self.table['modules'] += [module]
else: # if module has not str type
- raise TypeError('module must be a string, not %s' %
- type(module).__name__)
+ raise TypeError('module must be a string, not %s'
+ % type(module).__name__)
def removeModule(self, module):
'''Remove the module from the modules list.'''
if module in self.table['modules']:
self.table['modules'].remove(module)
else: # if module has not str type
- raise TypeError('module must be a string, not %s' %
- type(module).__name__)
+ raise TypeError('module must be a string, not %s'
+ % type(module).__name__)
def getModules(self):
'''Return the modules list.'''
self.table['modules'] = old_modules
raise
else: # if type of modules is not list or tuple
- raise TypeError('modules must be a list or a tuple, not %s' %
- type(modules).__name__)
+ raise TypeError('modules must be a list or a tuple, not %s'
+ % type(modules).__name__)
def resetModules(self):
'''Reset the list of the modules.'''
if module not in self.table['avoids']:
self.table['avoids'].append(module)
else: # if module has not str type
- raise TypeError('avoid must be a string, not %s' %
- type(module).__name__)
+ raise TypeError('avoid must be a string, not %s'
+ % type(module).__name__)
def removeAvoid(self, module):
'''Remove the given module from the list of avoided modules.'''
if module in self.table['avoids']:
self.table['avoids'].remove(module)
else: # if module has not str type
- raise TypeError('avoid must be a string, not %s' %
- type(module).__name__)
+ raise TypeError('avoid must be a string, not %s'
+ % type(module).__name__)
def getAvoids(self):
'''Return the list of the avoided modules.'''
self.table['avoids'] = old_avoids
raise
else: # if type of modules is not list or tuple
- raise TypeError('modules must be a list or a tuple, not %s' %
- type(modules).__name__)
+ raise TypeError('modules must be a list or a tuple, not %s'
+ % type(modules).__name__)
def resetAvoids(self):
'''Reset the list of the avoided modules.'''
if file not in self.table['files']:
self.table['files'].append(file)
else: # if file has not str type
- raise TypeError('file must be a string, not %s' %
- type(file).__name__)
+ raise TypeError('file must be a string, not %s'
+ % type(file).__name__)
def removeFile(self, file):
'''Remove the given file from the list of files.'''
if file in self.table['files']:
self.table['files'].remove(file)
else: # if file has not str type
- raise TypeError('file must be a string, not %s' %
- type(file).__name__)
+ raise TypeError('file must be a string, not %s'
+ % type(file).__name__)
def getFiles(self):
'''Return the list of the fileed files.'''
self.table['files'] = old_files
raise
else: # if type of files is not list or tuple
- raise TypeError('files must be a list or a tuple, not %s' %
- type(files).__name__)
+ raise TypeError('files must be a list or a tuple, not %s'
+ % type(files).__name__)
def resetFiles(self):
'''Reset the list of files.'''
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
- raise TypeError('categories must be a list or a tuple, not %s' %
- type(categories).__name__)
+ raise TypeError('categories must be a list or a tuple, not %s'
+ % type(categories).__name__)
def resetInclTestCategories(self):
'''Reset test categories.'''
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
- raise TypeError('categories must be a list or a tuple, not %s' %
- type(categories).__name__)
+ raise TypeError('categories must be a list or a tuple, not %s'
+ % type(categories).__name__)
def resetExclTestCategories(self):
'''Reset test categories.'''
if libname:
self.table['libname'] = libname
else: # if type of libname is not str
- raise TypeError('libname must be a string, not %s' %
- type(module).__name__)
+ raise TypeError('libname must be a string, not %s'
+ % type(module).__name__)
def resetLibName(self):
'''Reset the library name to 'libgnu'.'''
if macro_prefix:
self.table['macro_prefix'] = macro_prefix
else: # if type of macro_prefix is not str
- raise TypeError('macro_prefix must be a string, not %s' %
- type(macro_prefix).__name__)
+ raise TypeError('macro_prefix must be a string, not %s'
+ % type(macro_prefix).__name__)
if macro_prefix == 'gl':
include_guard_prefix = 'GL'
else: # macro_prefix != 'gl'
if makefile:
self.table['makefile'] = makefile
else: # if type of makefile is not str
- raise TypeError('makefile must be a string, not %s' %
- type(makefile).__name__)
+ raise TypeError('makefile must be a string, not %s'
+ % type(makefile).__name__)
def resetMakefile(self):
'''Reset the name of makefile in automake syntax in the source-base and
if podomain:
self.table['podomain'] = podomain
else: # if type of podomain is not str
- raise TypeError('podomain must be a string, not %s' %
- type(podomain).__name__)
+ raise TypeError('podomain must be a string, not %s'
+ % type(podomain).__name__)
def resetPoDomain(self):
'''Reset the prefix of the i18n domain. Usually use the package name.
if witness_c_macro:
self.table['witness_c_macro'] = witness_c_macro
else: # if type of witness_c_macro is not str
- raise TypeError('witness_c_macro must be a string, not %s' %
- type(witness_c_macro).__name__)
+ raise TypeError('witness_c_macro must be a string, not %s'
+ % type(witness_c_macro).__name__)
def resetWitnessCMacro(self):
'''Return the C macro that is defined when the sources in this directory
self.table['configure_ac'] = \
relpath(self.table['destdir'], configure_ac)
else: # if type of configure_ac is not str
- raise TypeError('configure_ac must be a string, not %s' %
- type(configure_ac).__name__)
+ raise TypeError('configure_ac must be a string, not %s'
+ % type(configure_ac).__name__)
def resetAutoconfFile(self):
'''Reset path of autoconf file relative to destdir.'''
if type(ac_version) is float or type(ac_version) is int:
self.table['ac_version'] = float(ac_version)
else: # if ac_version has not int or float type
- raise TypeError('ac_version must be an int or a float, not %s' %
- type(ac_version).__name__)
+ raise TypeError('ac_version must be an int or a float, not %s'
+ % type(ac_version).__name__)
def resetAutoconfVersion(self):
'''Specify preferred autoconf version. Default value is 2.59.'''
elif verbose > MODES['verbose-max']:
self.table['verbosity'] = MODES['verbose-max']
else: # if type(verbose) is not int
- raise TypeError('verbosity must be an int, not %s' %
- type(verbose).__name__)
+ raise TypeError('verbosity must be an int, not %s'
+ % type(verbose).__name__)
def resetVerbosity(self):
'''Reset verbosity level.'''
Create GLEmiter instance.'''
self.info = GLInfo()
if type(config) is not GLConfig:
- raise TypeError('config must be a GLConfig, not %s' %
- type(config).__name__)
+ raise TypeError('config must be a GLConfig, not %s'
+ % type(config).__name__)
self.config = config
def __repr__(self):
indentation is a string which contain spaces to prepend on each line.'''
emit = ''
if type(module) is not GLModule:
- raise TypeError('module must be a GLModule, not %s' %
- type(module).__name__)
+ raise TypeError('module must be a GLModule, not %s'
+ % type(module).__name__)
if type(fileassistant) is not GLFileAssistant:
- raise TypeError('fileassistant must be a GLFileAssistant, not %s' %
- type(fileassistant).__name__)
+ raise TypeError('fileassistant must be a GLFileAssistant, not %s'
+ % type(fileassistant).__name__)
if type(toplevel) is not bool:
- raise TypeError('toplevel must be a bool, not %s' %
- type(toplevel).__name__)
+ raise TypeError('toplevel must be a bool, not %s'
+ % type(toplevel).__name__)
if type(disable_libtool) is not bool:
- raise TypeError('disable_libtool must be a bool, not %s' %
- type(disable_libtool).__name__)
+ raise TypeError('disable_libtool must be a bool, not %s'
+ % type(disable_libtool).__name__)
if type(disable_gettext) is not bool:
- raise TypeError('disable_gettext must be a bool, not %s' %
- type(disable_gettext).__name__)
+ raise TypeError('disable_gettext must be a bool, not %s'
+ % type(disable_gettext).__name__)
if type(indentation) is not str:
- raise TypeError('indentation must be a string, not %s' %
- type(indentation).__name__)
+ raise TypeError('indentation must be a string, not %s'
+ % type(indentation).__name__)
if not indentation.isspace():
raise ValueError('indentation must contain only whitespaces')
auxdir = self.config['auxdir']
if type(module) is not GLModule:
raise TypeError('each module must be a GLModule instance')
if type(moduletable) is not GLModuleTable:
- raise TypeError('moduletable must be a GLFileAssistant, not %s' %
- type(moduletable).__name__)
+ raise TypeError('moduletable must be a GLFileAssistant, not %s'
+ % type(moduletable).__name__)
if type(fileassistant) is not GLFileAssistant:
- raise TypeError('fileassistant must be a GLFileAssistant, not %s' %
- type(fileassistant).__name__)
+ raise TypeError('fileassistant must be a GLFileAssistant, not %s'
+ % type(fileassistant).__name__)
if type(verifier) is not int:
- raise TypeError('verifier must be an int, not %s' %
- type(verifier).__name__)
+ raise TypeError('verifier must be an int, not %s'
+ % type(verifier).__name__)
if not (0 <= verifier <= 2):
raise ValueError('verifier must be 0, 1 or 2, not %d' % verifier)
if type(toplevel) is not bool:
- raise TypeError('toplevel must be a bool, not %s' %
- type(toplevel).__name__)
+ raise TypeError('toplevel must be a bool, not %s'
+ % type(toplevel).__name__)
if type(disable_libtool) is not bool:
- raise TypeError('disable_libtool must be a bool, not %s' %
- type(disable_libtool).__name__)
+ raise TypeError('disable_libtool must be a bool, not %s'
+ % type(disable_libtool).__name__)
if type(disable_gettext) is not bool:
- raise TypeError('disable_gettext must be a bool, not %s' %
- type(disable_gettext).__name__)
+ raise TypeError('disable_gettext must be a bool, not %s'
+ % type(disable_gettext).__name__)
if type(replace_auxdir) is not bool:
- raise TypeError('replace_auxdir must be a bool, not %s' %
- type(replace_auxdir).__name__)
+ 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 the first few statements of the gl_INIT macro.'''
emit = ''
if type(macro_prefix_arg) is not str:
- raise TypeError('macro_prefix_arg must be a string, not %s' %
- type(macro_prefix_arg).__name__)
+ raise TypeError('macro_prefix_arg must be a string, not %s'
+ % type(macro_prefix_arg).__name__)
module_indicator_prefix = self.config.getModuleIndicatorPrefix()
# Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
# platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead
Emit the last few statements of the gl_INIT macro.'''
emit = ''
if type(macro_prefix_arg) is not str:
- raise TypeError('macro_prefix_arg must be a string, not %s' %
- type(macro_prefix_arg).__name__)
+ raise TypeError('macro_prefix_arg must be a string, not %s'
+ % type(macro_prefix_arg).__name__)
# Check the presence of files that are mentioned as AC_LIBSOURCES
# arguments. The check is performed only when autoconf is run from the
# directory where the configure.ac resides; if it is run from a different
GLConfig: sourcebase.'''
emit = ''
if type(macro_prefix_arg) is not str:
- raise TypeError('macro_prefix_arg must be a string, not %s' %
- type(macro_prefix_arg).__name__)
+ raise TypeError('macro_prefix_arg must be a string, not %s'
+ % type(macro_prefix_arg).__name__)
if type(sourcebase_arg) is not str:
- raise TypeError('sourcebase_arg must be a string, not %s' %
- type(sourcebase_arg).__name__)
+ raise TypeError('sourcebase_arg must be a string, not %s'
+ % type(sourcebase_arg).__name__)
emit += """\
# Like AC_LIBOBJ, except that the module name goes
for_test is a bool variable; it must be set to True if creating a package
for testing, False otherwise.'''
if type(destfile) is not str:
- raise TypeError('destfile must be a string, not %s' %
- type(destfile).__name__)
+ raise TypeError('destfile must be a string, not %s'
+ % type(destfile).__name__)
for module in modules:
if type(module) is not GLModule:
raise TypeError('each module must be a GLModule instance')
if type(moduletable) is not GLModuleTable:
- raise TypeError('moduletable must be a GLModuleTable, not %s' %
- type(moduletable).__name__)
+ raise TypeError('moduletable must be a GLModuleTable, not %s'
+ % type(moduletable).__name__)
if type(makefiletable) is not GLMakefileTable:
- raise TypeError('makefiletable must be a GLMakefileTable, not %s' %
- type(makefiletable).__name__)
+ raise TypeError('makefiletable must be a GLMakefileTable, not %s'
+ % type(makefiletable).__name__)
if type(actioncmd) is not str:
- raise TypeError('actioncmd must be a string, not %s' %
- type(actioncmd).__name__)
+ raise TypeError('actioncmd must be a string, not %s'
+ % type(actioncmd).__name__)
if type(for_test) is not bool:
- raise TypeError('for_test must be a bool, not %s' %
- type(for_test).__name__)
+ raise TypeError('for_test must be a bool, not %s'
+ % type(for_test).__name__)
emit = ''
sourcebase = self.config['sourcebase']
modcache = self.config['modcache']
'lib_LDFLAGS[\t ]*\\+=(.*?)$', re.S | re.M)
amsnippet1 = pattern.sub('', amsnippet1)
pattern = compiler('lib_([A-Z][A-Z](?:.*?))', re.S | re.M)
- amsnippet1 = pattern.sub('%s_%s_\\1' %
- (libname, libext), amsnippet1)
+ amsnippet1 = pattern.sub('%s_%s_\\1' % (libname, libext),
+ amsnippet1)
amsnippet1 = amsnippet1.replace(
'$(GNULIB_', '$(' + module_indicator_prefix + '_GNULIB_')
amsnippet1 = amsnippet1.replace(
amsnippet1 = amsnippet1.replace('${gl_include_guard_prefix}',
include_guard_prefix)
if str(module) == 'alloca':
- amsnippet1 += '%s_%s_LIBADD += @%sALLOCA@\n' % \
- (libname, libext, perhapsLT)
- amsnippet1 += '%s_%s_DEPENDENCIES += @%sALLOCA@\n' % \
- (libname, libext, perhapsLT)
+ amsnippet1 += '%s_%s_LIBADD += @%sALLOCA@\n' % (libname, libext, perhapsLT)
+ amsnippet1 += '%s_%s_DEPENDENCIES += @%sALLOCA@\n' % (libname, libext, perhapsLT)
amsnippet1 = constants.combine_lines_matching(
compiler('%s_%s_SOURCES' % (libname, libext)),
amsnippet1)
# Get unconditional snippet, edit it and save to amsnippet2.
amsnippet2 = module.getAutomakeSnippet_Unconditional()
pattern = compiler('lib_([A-Z][A-Z](?:.*?))', re.S | re.M)
- amsnippet2 = pattern.sub('%s_%s_\\1' %
- (libname, libext), amsnippet2)
+ amsnippet2 = pattern.sub('%s_%s_\\1' % (libname, libext),
+ amsnippet2)
amsnippet2 = amsnippet2.replace(
'$(GNULIB_', '$(' + module_indicator_prefix + '_GNULIB_')
if not (amsnippet1 + amsnippet2).isspace():
if dictionary['var']:
paths = list()
paths += [joinpath(dictionary['dir'], 'Makefile.am')]
- paths += [os.path.normpath('./%s/Makefile.am' %
- dictionary['dir'])]
+ paths += [os.path.normpath('./%s/Makefile.am' % dictionary['dir'])]
paths = sorted(set(paths))
if destfile in paths:
emit += '%s += %s\n' % (dictionary['var'],
# First test if allsnippets already specify an installation location.
insnippets = False
inmakefile = False
- regex = '^[a-zA-Z0-9_]*_%sLIBRARIES *\\+{0,1}= *%s.%s' % \
- (perhapsLT, libname, libext)
+ regex = '^[a-zA-Z0-9_]*_%sLIBRARIES *\\+{0,1}= *%s.%s' % (perhapsLT, libname, libext)
pattern = compiler(regex, re.S | re.M)
insnippets = bool(pattern.findall(allsnippets))
# Then test if $sourcebase/Makefile.am (if it exists) specifies it.
inmakefile = bool(pattern.findall(data))
if not any([insnippets, inmakefile]):
# By default, the generated library should not be installed.
- emit += 'noinst_%sLIBRARIES += %s.%s\n' % (
- perhapsLT, libname, libext)
+ emit += 'noinst_%sLIBRARIES += %s.%s\n' % (perhapsLT, libname, libext)
emit += '\n'
emit += '%s_%s_SOURCES =\n' % (libname, libext)
# Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
# automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
- emit += '%s_%s_LIBADD = $(%s_%sLIBOBJS)\n' % \
- (libname, libext, macro_prefix, perhapsLT)
- emit += '%s_%s_DEPENDENCIES = $(%s_%sLIBOBJS)\n' % \
- (libname, libext, macro_prefix, perhapsLT)
+ emit += '%s_%s_LIBADD = $(%s_%sLIBOBJS)\n' % (libname, libext, macro_prefix, perhapsLT)
+ emit += '%s_%s_DEPENDENCIES = $(%s_%sLIBOBJS)\n' % (libname, libext, macro_prefix, perhapsLT)
emit += 'EXTRA_%s_%s_SOURCES =\n' % (libname, libext)
if libtool:
emit += '%s_%s_LDFLAGS = $(AM_LDFLAGS)\n' % (libname, libext)
for_test is a bool variable; it must be set to True if creating a package
for testing, False otherwise.'''
if type(destfile) is not str:
- raise TypeError('destfile must be a string, not %s' %
- type(destfile).__name__)
+ raise TypeError('destfile must be a string, not %s'
+ % type(destfile).__name__)
for module in modules:
if type(module) is not GLModule:
raise TypeError('each module must be a GLModule instance')
if type(makefiletable) is not GLMakefileTable:
- raise TypeError('makefiletable must be a GLMakefileTable, not %s' %
- type(makefiletable).__name__)
+ raise TypeError('makefiletable must be a GLMakefileTable, not %s'
+ % type(makefiletable).__name__)
if type(witness_macro) is not str:
- raise TypeError('witness_macro must be a string, not %s' %
- type(witness_macro).__name__)
+ raise TypeError('witness_macro must be a string, not %s'
+ % type(witness_macro).__name__)
if type(for_test) is not bool:
- raise TypeError('for_test must be a bool, not %s' %
- type(for_test).__name__)
+ raise TypeError('for_test must be a bool, not %s'
+ % type(for_test).__name__)
emit = ''
auxdir = self.config['auxdir']
sourcebase = self.config['sourcebase']
if dictionary['var']:
paths = list()
paths += [joinpath(dictionary['dir'], 'Makefile.am')]
- paths += [os.path.normpath('./%s/Makefile.am' %
- dictionary['dir'])]
+ paths += [os.path.normpath('./%s/Makefile.am' % dictionary['dir'])]
paths = sorted(set(paths))
if destfile in paths:
emit += '%s += %s\n' % (dictionary['var'],
if witness_macro:
emit += ' -D@%s@=1 \\\n' % witness_macro
emit += ' -I. -I$(srcdir) \\\n'
- emit += ' -I%s -I$(srcdir)/%s \\\n' % \
- (testsbase_inverse, testsbase_inverse)
- emit += ' -I%s/%s -I$(srcdir)/%s/%s\n' % \
- (testsbase_inverse, sourcebase, testsbase_inverse, sourcebase)
+ emit += ' -I%s -I$(srcdir)/%s \\\n' % (testsbase_inverse, testsbase_inverse)
+ emit += ' -I%s/%s -I$(srcdir)/%s/%s\n' % (testsbase_inverse, sourcebase, testsbase_inverse, sourcebase)
emit += '\n'
if libtests:
# voluntarily omitted).
# The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it
# does not matter.
- emit += 'LDADD = libtests.a %s/%s/%s.%s libtests.a %s/%s/%s.%s libtests.a $(LIBTESTS_LIBDEPS)\n\n' % \
- (testsbase_inverse, sourcebase, libname, libext,
- testsbase_inverse, sourcebase, libname, libext)
+ emit += 'LDADD = libtests.a %s/%s/%s.%s libtests.a %s/%s/%s.%s libtests.a $(LIBTESTS_LIBDEPS)\n\n' \
+ % (testsbase_inverse, sourcebase, libname, libext,
+ testsbase_inverse, sourcebase, libname, libext)
else:
- emit += 'LDADD = %s/%s/%s.%s\n\n' % \
- (testsbase_inverse, sourcebase, libname, libext)
+ emit += 'LDADD = %s/%s/%s.%s\n\n' % (testsbase_inverse, sourcebase, libname, libext)
if libtests:
emit += 'libtests_a_SOURCES =\n'
# Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
'''Create new GLFileSystem instance. The only argument is localpath,
which can be an empty list.'''
if type(config) is not GLConfig:
- raise TypeError('config must be a GLConfig, not %s' %
- type(config).__name__)
+ raise TypeError('config must be a GLConfig, not %s'
+ % type(config).__name__)
self.config = config
def __repr__(self):
indicates whether file is a temporary file.
GLConfig: localpath.'''
if type(name) is not str:
- raise TypeError(
- 'name must be a string, not %s' % type(module).__name__)
+ raise TypeError('name must be a string, not %s'
+ % type(module).__name__)
localpath = self.config['localpath']
# Each element in localpath is a directory whose contents overrides
# or amends the result of the lookup in the rest of localpath and
def __init__(self, config, transformers=dict()):
'''Create GLFileAssistant instance.'''
if type(config) is not GLConfig:
- raise TypeError('config must be a GLConfig, not %s' %
- type(config).__name__)
+ raise TypeError('config must be a GLConfig, not %s'
+ % type(config).__name__)
if type(transformers) is not dict:
- raise TypeError('transformers must be a dict, not %s' %
- type(transformers).__name__)
+ raise TypeError('transformers must be a dict, not %s'
+ % type(transformers).__name__)
for key in ['lib', 'aux', 'main', 'tests']:
if key not in transformers:
transformers[key] = 's,x,x,'
else: # if key in transformers
value = transformers[key]
if type(value) is not str:
- raise TypeError('transformers[%s] must be a string, not %s' %
- (key, type(value).__name__))
+ raise TypeError('transformers[%s] must be a string, not %s'
+ % (key, type(value).__name__))
self.original = None
self.rewritten = None
self.added = list()
if rewritten == None:
raise TypeError('rewritten must be set before applying the method')
if type(lookedup) is not str:
- raise TypeError('lookedup must be a string, not %s' %
- type(lookedup).__name__)
+ raise TypeError('lookedup must be a string, not %s'
+ % type(lookedup).__name__)
if type(already_present) is not bool:
- raise TypeError('already_present must be a bool, not %s' %
- type(already_present).__name__)
+ raise TypeError('already_present must be a bool, not %s'
+ % type(already_present).__name__)
basename = rewritten
backupname = '%s~' % basename
basepath = joinpath(destdir, basename)
if not filecmp.cmp(basepath, tmpfile):
if not self.config['dryrun']:
if already_present:
- print('Updating file %s (backup in %s)' %
- (basename, backupname))
+ print('Updating file %s (backup in %s)' % (basename, backupname))
else: # if not already_present
message = 'Replacing file '
message += '%s (non-gnulib code backed up in ' % basename
raise GLError(17, original)
else: # if self.config['dryrun']
if already_present:
- print('Update file %s (backup in %s)' %
- (rewritten, backup))
+ print('Update file %s (backup in %s)' % (rewritten, backup))
else: # if not already_present
- print('Replace file %s (backup in %s)' %
- (rewritten, backup))
+ print('Replace file %s (backup in %s)' % (rewritten, backup))
def add_or_update(self, already_present):
'''GLFileAssistant.add_or_update(already_present)
elif rewritten == None:
raise TypeError('rewritten must be set before applying the method')
if type(already_present) is not bool:
- raise TypeError('already_present must be a bool, not %s' %
- type(already_present).__name__)
+ raise TypeError('already_present must be a bool, not %s'
+ % type(already_present).__name__)
xoriginal = original
if original.startswith('tests=lib/'):
xoriginal = constants.substart('tests=lib/', 'lib/', original)
object, which is accessible from constants module. The second one, config,
must be a GLConfig object.'''
if type(config) is not GLConfig:
- raise TypeError('config must have GLConfig type, not %s' %
- repr(config))
+ raise TypeError('config must have GLConfig type, not %s'
+ % repr(config))
if type(mode) is int and \
MODES['import'] <= mode <= MODES['update']:
self.mode = mode
else: # if mode is not int or is not 0-3
- raise TypeError('mode must be 0 <= mode <= 3, not %s' %
- repr(mode))
+ raise TypeError('mode must be 0 <= mode <= 3, not %s'
+ % repr(mode))
# Initialize some values.
self.cache = GLConfig()
if isfile(path):
with codecs.open(path, 'rb', 'UTF-8') as file:
data = file.read()
- regex = 'AC_DEFUN\\(\\[%s_FILE_LIST\\], \\[(.*?)\\]\\)' % \
- self.cache['macro_prefix']
+ regex = 'AC_DEFUN\\(\\[%s_FILE_LIST\\], \\[(.*?)\\]\\)' % self.cache['macro_prefix']
pattern = compiler(regex, re.S | re.M)
self.cache.setFiles(pattern.findall(data)[-1].strip().split())
emit += self.emiter.initmacro_start(macro_prefix)
emit += ' gl_source_base=\'%s\'\n' % sourcebase
if witness_c_macro:
- emit += ' m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [%s])\n' % \
- witness_c_macro
+ emit += ' m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [%s])\n' % witness_c_macro
# Emit main autoconf snippets.
emit += self.emiter.autoconfSnippets(moduletable['main'],
moduletable, assistant, 0, True, False, True, replace_auxdir)
destdata = '\n'.join(sorted(set(dirs_ignore))).strip()
if srcdata != destdata:
if not self.config['dryrun']:
- print('Updating %s (backup in %s)' %
- (srcpath, backupname))
+ print('Updating %s (backup in %s)' % (srcpath, backupname))
copyfile2(srcpath, backupname)
result = ''
with codecs.open(srcpath, 'ab', 'UTF-8') as file:
file.write(destdata)
else: # if self.config['dryrun']
- print('Updating %s (backup in %s)' %
- (srcpath, backupname))
+ print('Updating %s (backup in %s)' % (srcpath, backupname))
else: # if not isfile(srcpath)
if dirs_added:
if not self.config['dryrun']:
format except filelist argument. Such lists of files can be created using
GLImport.prepare() function.'''
if type(filetable) is not dict:
- raise TypeError('filetable must be a dict, not %s' %
- type(filetable).__name__)
+ raise TypeError('filetable must be a dict, not %s'
+ % type(filetable).__name__)
for key in ['all', 'old', 'new', 'added', 'removed']:
if key not in filetable:
raise KeyError('filetable must contain key %s' % repr(key))
basename, tmpfile)
if flag == 1:
if not self.config['dryrun']:
- print('Updating %s (backup in %s)' %
- (filename, backup))
+ print('Updating %s (backup in %s)' % (filename, backup))
else: # if self.config['dryrun']
print('Update %s (backup in %s)' % (filename, backup))
elif flag == 2:
print('')
print('Don\'t forget to')
if makefile_am == 'Makefile.am':
- print(' - add "%s/Makefile" to AC_CONFIG_FILES in %s,' %
- (sourcebase, configure_ac))
+ print(' - add "%s/Makefile" to AC_CONFIG_FILES in %s,' % (sourcebase, configure_ac))
else: # if makefile_am != 'Makefile.am'
- print(' - "include %s" from within "%s/Makefile.am",' %
- (makefile, sourcebase))
+ print(' - "include %s" from within "%s/Makefile.am",' % (makefile, sourcebase))
if pobase:
- print(' - add "%s/Makefile.in to AC_CONFIG_FILES in %s,' %
- (pobase, configure_ac))
+ print(' - add "%s/Makefile.in to AC_CONFIG_FILES in %s,' % (pobase, configure_ac))
if inctests:
if makefile_am == 'Makefile.am':
- print(' - add "%s/Makefile" to AC_CONFIG_FILES in %s,' %
- (testsbase, configure_ac))
+ print(' - add "%s/Makefile" to AC_CONFIG_FILES in %s,' % (testsbase, configure_ac))
else: # if makefile_am != 'Makefile.am'
- print(' - "include %s" from within "%s/Makefile.am",' %
- (makefile, testsbase))
+ print(' - "include %s" from within "%s/Makefile.am",' % (makefile, testsbase))
# Print makefile edits.
current_edit = int()
makefile_am_edits = self.makefiletable.count()
while current_edit != makefile_am_edits:
dictionary = self.makefiletable[current_edit]
if dictionary['var']:
- print(' - mention "%s" in %s in %s,' %
- (dictionary['val'], dictionary['var'],
- joinpath(dictionary['dir'], 'Makefile.am')))
+ print(' - mention "%s" in %s in %s,'
+ % (dictionary['val'], dictionary['var'], joinpath(dictionary['dir'], 'Makefile.am')))
current_edit += 1
# Detect position_early_after.
position_early_after = 'AC_PROG_CC_C99'
else: # if not any([match_result1, match_result2])
position_early_after = 'AC_PROG_CC'
- print(' - invoke %s_EARLY in %s, right after %s,' %
- (macro_prefix, configure_ac, position_early_after))
- print(' - invoke %s_INIT in %s.' %
- (macro_prefix, configure_ac))
+ print(' - invoke %s_EARLY in %s, right after %s,' % (macro_prefix, configure_ac, position_early_after))
+ print(' - invoke %s_INIT in %s.' % (macro_prefix, configure_ac))
sp.call(['rm', '-rf', self.config['tempdir']], shell=False)
Create GLMakefileTable instance.'''
if type(config) is not GLConfig:
- raise TypeError('config must be a GLConfig, not %s' %
- type(config).__name__)
+ raise TypeError('config must be a GLConfig, not %s'
+ % type(config).__name__)
self.config = config
self.table = list()
def __getitem__(self, y):
'''x.__getitem__(y) = x[y]'''
if type(y) is not int:
- raise TypeError('indices must be integers, not %s' %
- type(y).__name__)
+ raise TypeError('indices must be integers, not %s'
+ % type(y).__name__)
result = self.table[y]
return dict(result)
'patch' utility.'''
self.args = dict()
if type(config) is not GLConfig:
- raise TypeError('config must be a GLConfig, not %s' %
- type(config).__name__)
+ raise TypeError('config must be a GLConfig, not %s'
+ % type(config).__name__)
self.config = config
self.filesystem = GLFileSystem(self.config)
self.cache = dict()
self.content = ''
if type(config) is not GLConfig:
- raise TypeError('config must be a GLConfig, not %s' %
- type(config).__name__)
+ raise TypeError('config must be a GLConfig, not %s'
+ % type(config).__name__)
if type(module) is not str:
- raise TypeError('module must be a string, not %s' %
- type(module).__name__)
+ raise TypeError('module must be a string, not %s'
+ % type(module).__name__)
if type(patched) is not bool:
- raise TypeError('patched must be a bool, not %s' %
- type(module).__name__)
+ raise TypeError('patched must be a bool, not %s'
+ % type(module).__name__)
self.module = module
self.patched = patched
self.config = config
def __repr__(self):
'''x.__repr__ <==> repr(x)'''
- result = '<pygnulib.GLModule %s %s>' % \
- (repr(self.getName()), hex(id(self)))
+ result = '<pygnulib.GLModule %s %s>' % (repr(self.getName()), hex(id(self)))
return result
def getName(self):
self.tests_modules = list() # Tests modules
self.final_modules = list() # Final modules
if type(config) is not GLConfig:
- raise TypeError('config must be a GLConfig, not %s' %
- type(config).__name__)
+ raise TypeError('config must be a GLConfig, not %s'
+ % type(config).__name__)
self.config = config
self.filesystem = GLFileSystem(self.config)
self.modulesystem = GLModuleSystem(self.config)
if type(inc_all_direct_tests) is not bool:
- raise TypeError('inc_all_direct_tests must be a bool, not %s' %
- type(inc_all_direct_tests).__name__)
+ raise TypeError('inc_all_direct_tests must be a bool, not %s'
+ % type(inc_all_direct_tests).__name__)
self.inc_all_direct_tests = inc_all_direct_tests
self.inc_all_indirect_tests = inc_all_indirect_tests
self.avoids = list() # Avoids
Add new conditional dependency from parent to module with condition.'''
if type(parent) is not GLModule:
- raise TypeError('parent must be a GLModule, not %s' %
- type(parent).__name__)
+ raise TypeError('parent must be a GLModule, not %s'
+ % type(parent).__name__)
if type(module) is not GLModule:
- raise TypeError('module must be a GLModule, not %s' %
- type(module).__name__)
+ raise TypeError('module must be a GLModule, not %s'
+ % type(module).__name__)
if not (type(condition) is str or condition == True):
- raise TypeError('condition must be a string or True, not %s' %
- type(condition).__name__)
+ raise TypeError('condition must be a string or True, not %s'
+ % type(condition).__name__)
if not str(module) in self.unconditionals:
if str(module) not in self.dependers:
self.dependers[module] = list()
Add module as unconditional dependency.'''
if type(module) is not GLModule:
- raise TypeError('module must be a GLModule, not %s' %
- type(module).__name__)
+ raise TypeError('module must be a GLModule, not %s'
+ % type(module).__name__)
if str(module) in self.dependers:
self.dependers.pop(str(module))
self.unconditionals[str(module)] = True
Check whether module is unconditional.'''
if type(module) is not GLModule:
- raise TypeError('module must be a GLModule, not %s' %
- type(module).__name__)
+ raise TypeError('module must be a GLModule, not %s'
+ % type(module).__name__)
result = str(module) in self.dependers
return result
Return condition from parent to module. Condition can be string or True.
If module is not in the list of conddeps, method returns None.'''
if type(parent) is not GLModule:
- raise TypeError('parent must be a GLModule, not %s' %
- type(parent).__name__)
+ raise TypeError('parent must be a GLModule, not %s'
+ % type(parent).__name__)
if type(module) is not GLModule:
- raise TypeError('module must be a GLModule, not %s' %
- type(module).__name__)
+ raise TypeError('module must be a GLModule, not %s'
+ % type(module).__name__)
key = '%s---%s' % (str(parent), str(module))
result = None
if key in self.conditionals:
main_modules = self.transitive_closure(basemodules)
self.config.setInclTestCategory(TESTS['tests'], saved_inctests)
tests_modules = \
- [m for m in finalmodules if m not in main_modules] + \
- [m for m in main_modules if m.getApplicability() != 'main']
+ [m for m in finalmodules if m not in main_modules] \
+ + [m for m in main_modules if m.getApplicability() != 'main']
tests_modules = sorted(set(tests_modules))
result = tuple([main_modules, tests_modules])
return result
Create new GLTestDir instance.'''
if type(config) is not GLConfig:
- raise TypeError('config must be a GLConfig, not %s' %
- type(config).__name__)
+ raise TypeError('config must be a GLConfig, not %s'
+ % type(config).__name__)
if type(testdir) is not str:
- raise TypeError('testdir must be a string, not %s' %
- type(testdir).__name__)
+ raise TypeError('testdir must be a string, not %s'
+ % type(testdir).__name__)
self.config = config
self.testdir = os.path.normpath(testdir)
if not os.path.exists(self.testdir):
if single_configure:
# Determine main module list and tests-related module list separately.
main_modules, tests_modules = \
- moduletable.transitive_closure_separately(
- specified_modules, final_modules)
+ moduletable.transitive_closure_separately(specified_modules, final_modules)
# Print main_modules and tests_modules.
if verbose >= 1:
print('Main module list:')
# Define a tests witness macro.
emit += ' %stests_WITNESS=IN_GNULIB_TESTS\n' % macro_prefix
emit += ' AC_SUBST([%stests_WITNESS])\n' % macro_prefix
- emit += ' gl_module_indicator_condition=$%stests_WITNESS\n' % \
- macro_prefix
+ emit += ' gl_module_indicator_condition=$%stests_WITNESS\n' % macro_prefix
emit += ' m4_pushdef([gl_MODULE_INDICATOR_CONDITION], '
emit += '[$gl_module_indicator_condition])\n'
snippets = self.emiter.autoconfSnippets(tests_modules, moduletable,
emit += '])\n'
emit += self.emiter.initmacro_done(macro_prefix, sourcebase)
if single_configure:
- emit += self.emiter.initmacro_done('%stests' %
- macro_prefix, testsbase)
+ emit += self.emiter.initmacro_done('%stests' % macro_prefix, testsbase)
emit += '\ngl_INIT\n\n'
if subdirs_with_configure_ac:
if single_configure:
- emit += 'AC_CONFIG_SUBDIRS([%s])\n' % \
- ' '.join(subdirs_with_configure_ac[:-1])
+ emit += 'AC_CONFIG_SUBDIRS([%s])\n' % ' '.join(subdirs_with_configure_ac[:-1])
else: # if not single_configure
- emit += 'AC_CONFIG_SUBDIRS([%s])\n' % \
- ' '.join(subdirs_with_configure_ac)
+ emit += 'AC_CONFIG_SUBDIRS([%s])\n' % ' '.join(subdirs_with_configure_ac)
makefiles = ['Makefile']
for directory in subdirs:
# For subdirs that have a configure.ac by their own, it's the subdir's
Create new GLTestDir instance.'''
if type(config) is not GLConfig:
- raise TypeError('config must be a GLConfig, not %s' %
- type(config).__name__)
+ raise TypeError('config must be a GLConfig, not %s'
+ % type(config).__name__)
if type(megatestdir) is not str:
- raise TypeError('megatestdir must be a string, not %s' %
- type(megatestdir).__name__)
+ raise TypeError('megatestdir must be a string, not %s'
+ % type(megatestdir).__name__)
self.config = config
self.megatestdir = os.path.normpath(megatestdir)
if not os.path.exists(self.megatestdir):
listing = list()
for filename in filelist:
if filename.startswith(prefix) and filename.endswith(suffix):
- pattern = compiler('^%s(.*?)%s$' %
- (removed_prefix, removed_suffix))
- result = pattern.sub('%s\\1%s' %
- (added_prefix, added_suffix), filename)
+ pattern = compiler('^%s(.*?)%s$'
+ % (removed_prefix, removed_suffix))
+ result = pattern.sub('%s\\1%s'
+ % (added_prefix, added_suffix), filename)
listing += [result]
result = separator.join(listing)
return result