+2024-04-08 Collin Funk <collin.funk1@gmail.com>
+
+ gnulib-tool.py: Use single-quotes for strings.
+ * pygnulib/*.py: Change double-quoted strings to use single-quotes
+ unless doing so would require adding backslashes.
+
2024-04-08 Collin Funk <collin.funk1@gmail.com>
gnulib-tool.py: Prefer 'list.append(item)' over 'list += [item]'.
placed. Default comes from configure.ac or configure.in.'''
if self.table['auxdir']:
return self.table['auxdir']
- return "build-aux"
+ return 'build-aux'
def setAuxDir(self, auxdir: str) -> None:
'''Specify directory relative to --dir where auxiliary build tools are
def copyright_notice(self) -> str:
'''Emit a header for a generated file.'''
emit = '# %s' % self.info.copyright_range()
- emit += """
+ emit += '''
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# contains a configuration script generated by Autoconf, under
# the same distribution terms as the rest of that program.
#
-# Generated by gnulib-tool.\n"""
+# Generated by gnulib-tool.\n'''
return emit
def shellvars_init(self, gentests: bool, base: str) -> str:
pobase = self.config['pobase']
podomain = self.config['podomain']
emit = ''
- emit += "## DO NOT EDIT! GENERATED AUTOMATICALLY!\n"
+ emit += '## DO NOT EDIT! GENERATED AUTOMATICALLY!\n'
emit += "%s\n" % self.copyright_notice()
- emit += "# Usually the message domain is the same as the package name.\n"
+ emit += '# Usually the message domain is the same as the package name.\n'
emit += "# But here it has a '-gnulib' suffix.\n"
- emit += "DOMAIN = %s-gnulib\n\n" % podomain
- emit += "# These two variables depend on the location of this directory.\n"
- emit += "subdir = %s\n" % pobase
- emit += "top_builddir = %s\n" % relinverse(pobase)
- emit += """
+ emit += 'DOMAIN = %s-gnulib\n\n' % podomain
+ emit += '# These two variables depend on the location of this directory.\n'
+ emit += 'subdir = %s\n' % pobase
+ emit += 'top_builddir = %s\n' % relinverse(pobase)
+ emit += '''
# These options get passed to xgettext.
XGETTEXT_OPTIONS = \\
--keyword=_ --flag=_:1:pass-c-format \\
# context. Possible values are "yes" and "no". Set this to yes if the
# package uses functions taking also a message context, like pgettext(), or
# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
-USE_MSGCTXT = no\n"""
+USE_MSGCTXT = no\n'''
return emit
def po_POTFILES_in(self, files: list[str]) -> str:
GLConfig: sourcebase.'''
sourcebase = self.config['sourcebase'] + os.path.sep
emit = ''
- emit += "## DO NOT EDIT! GENERATED AUTOMATICALLY!\n"
- emit += "%s\n" % self.copyright_notice()
- emit += "# List of files which contain translatable strings.\n"
+ emit += '## DO NOT EDIT! GENERATED AUTOMATICALLY!\n'
+ emit += '%s\n' % self.copyright_notice()
+ emit += '# List of files which contain translatable strings.\n'
for file in files:
if file.startswith('lib/'):
emit += '%s\n' % constants.substart('lib/', sourcebase, file)
# Furthermore it avoids an automake error like this when a Makefile.am
# that uses pieces of gnulib also uses $(LIBOBJ):
# automatically discovered file `error.c' should not be explicitly mentioned.
- emit += " m4_pushdef([AC_LIBOBJ], m4_defn([%s_LIBOBJ]))\n" % macro_prefix_arg
- emit += " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([%s_REPLACE_FUNCS]))\n" % macro_prefix_arg
+ emit += ' m4_pushdef([AC_LIBOBJ], m4_defn([%s_LIBOBJ]))\n' % macro_prefix_arg
+ emit += ' m4_pushdef([AC_REPLACE_FUNCS], m4_defn([%s_REPLACE_FUNCS]))\n' % macro_prefix_arg
# Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
# error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
# automatically discovered file `error.c' should not be explicitly mentioned
# We let automake know about the files to be distributed through the
# EXTRA_lib_SOURCES variable.
- emit += " m4_pushdef([AC_LIBSOURCES], m4_defn([%s_LIBSOURCES]))\n" % macro_prefix_arg
+ emit += ' m4_pushdef([AC_LIBSOURCES], m4_defn([%s_LIBSOURCES]))\n' % macro_prefix_arg
# Create data variables for checking the presence of files that are
# mentioned as AC_LIBSOURCES arguments. These are m4 variables, not shell
# variables, because we want the check to happen when the configure file is
# created, not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the
# list of files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the
# subdirectory in which to expect them.
- emit += " m4_pushdef([%s_LIBSOURCES_LIST], [])\n" % macro_prefix_arg
- emit += " m4_pushdef([%s_LIBSOURCES_DIR], [])\n" % macro_prefix_arg
+ emit += ' m4_pushdef([%s_LIBSOURCES_LIST], [])\n' % macro_prefix_arg
+ emit += ' m4_pushdef([%s_LIBSOURCES_DIR], [])\n' % macro_prefix_arg
# Scope for m4 macros.
- emit += " m4_pushdef([GL_MACRO_PREFIX], [%s])\n" % macro_prefix_arg
+ emit += ' m4_pushdef([GL_MACRO_PREFIX], [%s])\n' % macro_prefix_arg
# Scope the GNULIB_<modulename> variables.
- emit += " m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [%s])\n" % module_indicator_prefix
- emit += " gl_COMMON\n"
+ emit += ' m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [%s])\n' % module_indicator_prefix
+ emit += ' gl_COMMON\n'
if gentests:
emit += ' AC_REQUIRE([gl_CC_ALLOW_WARNINGS])\n'
emit += ' AC_REQUIRE([gl_CXX_ALLOW_WARNINGS])\n'
raise TypeError('sourcebase_arg must be a string, not %s'
% type(sourcebase_arg).__name__)
emit = ''
- emit += """\
+ emit += '''\
# Like AC_LIBOBJ, except that the module name goes
# into %V1%_LIBOBJS instead of into LIBOBJS.
m4_append([%V1%_LIBSOURCES_LIST], _gl_NAME, [ ])
])
])
-])\n"""
+])\n'''
emit = emit.replace('%V1%', macro_prefix_arg)
emit = emit.replace('%V2%', sourcebase_arg)
return emit
edit_check_PROGRAMS = True
else: # if not for_test
edit_check_PROGRAMS = False
- emit += "## DO NOT EDIT! GENERATED AUTOMATICALLY!\n"
+ emit += '## DO NOT EDIT! GENERATED AUTOMATICALLY!\n'
if not gnu_make:
- emit += "## Process this file with automake to produce Makefile.in.\n"
+ emit += '## Process this file with automake to produce Makefile.in.\n'
emit += self.copyright_notice()
if actioncmd:
- emit += "# Reproduce by:\n%s\n" % actioncmd
+ emit += '# Reproduce by:\n%s\n' % actioncmd
emit += '\n'
uses_subdirs = False
testsbase_inverse = relinverse(testsbase)
# Begin the generation.
- emit += "## DO NOT EDIT! GENERATED AUTOMATICALLY!\n"
- emit += "## Process this file with automake to produce Makefile.in.\n"
+ emit += '## DO NOT EDIT! GENERATED AUTOMATICALLY!\n'
+ emit += '## Process this file with automake to produce Makefile.in.\n'
emit += '%s\n' % self.copyright_notice()
uses_subdirs = False
# 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"
+ emit += ('LDADD = libtests.a %s/%s/%s.%s libtests.a %s/%s/%s.%s libtests.a $(LIBTESTS_LIBDEPS)\n'
% (testsbase_inverse, sourcebase, libname, libext,
testsbase_inverse, sourcebase, libname, libext))
else:
- emit += ("LDADD = %s/%s/%s.%s\n"
+ emit += ('LDADD = %s/%s/%s.%s\n'
% (testsbase_inverse, sourcebase, libname, libext))
emit += '\n'
if libtests:
if self.message == None:
message = None
if errno == 1:
- message = "file does not exist in GLFileSystem: %s" % repr(errinfo)
+ message = 'file does not exist in GLFileSystem: %s' % repr(errinfo)
elif errno == 2:
- message = "cannot patch file inside GLFileSystem: %s" % repr(errinfo)
+ message = 'cannot patch file inside GLFileSystem: %s' % repr(errinfo)
elif errno == 3:
- message = "configure file does not exist: %s" % repr(errinfo)
+ message = 'configure file does not exist: %s' % repr(errinfo)
elif errno == 4:
- message = "minimum supported autoconf version is 2.64, not %s" % repr(errinfo)
+ message = 'minimum supported autoconf version is 2.64, not %s' % repr(errinfo)
elif errno == 5:
- message = "%s is expected to contain gl_M4_BASE([%s])" % (repr(os.path.join(errinfo, 'gnulib-comp.m4')), repr(errinfo))
+ message = '%s is expected to contain gl_M4_BASE([%s])' % (repr(os.path.join(errinfo, 'gnulib-comp.m4')), repr(errinfo))
elif errno == 6:
message = "missing sourcebase argument; cache file doesn't contain it, so you might have to set this argument"
elif errno == 7:
- message = "missing docbase argument; you might have to create GLImport instance with mode 0 and docbase argument"
+ message = 'missing docbase argument; you might have to create GLImport instance with mode 0 and docbase argument'
elif errno == 8:
message = "missing testsbase argument; cache file doesn't contain it, so you might have to set this argument"
elif errno == 9:
message = "missing libname argument; cache file doesn't contain it, so you might have to set this argument"
elif errno == 10:
- message = "conddeps are not supported with inctests"
+ message = 'conddeps are not supported with inctests'
elif errno == 11:
- message = "incompatible licenses on modules: %s" % repr(errinfo)
+ message = 'incompatible licenses on modules: %s' % repr(errinfo)
elif errno == 12:
- message = "cannot process empty filelist"
+ message = 'cannot process empty filelist'
elif errno == 13:
- message = "cannot create the given directory: %s" % repr(errinfo)
+ message = 'cannot create the given directory: %s' % repr(errinfo)
elif errno == 14:
- message = "cannot remove the given file: %s" % repr(errinfo)
+ message = 'cannot remove the given file: %s' % repr(errinfo)
elif errno == 15:
- message = "cannot create the given file: %s" % repr(errinfo)
+ message = 'cannot create the given file: %s' % repr(errinfo)
elif errno == 16:
- message = "cannot transform the given file: %s" % repr(errinfo)
+ message = 'cannot transform the given file: %s' % repr(errinfo)
elif errno == 17:
- message = "cannot update/replace the given file: %s" % repr(errinfo)
+ message = 'cannot update/replace the given file: %s' % repr(errinfo)
elif errno == 18:
- message = "module lacks a license: %s" % repr(errinfo)
+ message = 'module lacks a license: %s' % repr(errinfo)
elif errno == 19:
- message = "error when running subprocess: %s" % repr(errinfo)
+ message = 'error when running subprocess: %s' % repr(errinfo)
elif errno == 20:
message = 'could not patch test-driver script'
elif errno == 21:
except Exception as exc:
raise GLError(15, lookedup) from exc
# Don't process binary files with sed.
- if not (original.endswith(".class") or original.endswith(".mo")):
+ if not (original.endswith('.class') or original.endswith('.mo')):
transformer = None
if original.startswith('lib/'):
if sed_transform_main_lib_file:
# line has length >= 3071; similarly, the IRIX 6.5 awk fails if a
# line has length >= 3072.
if len(localpath) > 0:
- actioncmd += ''.join([f" \\\n# --local-dir={x}" for x in localpath])
+ actioncmd += ''.join([f' \\\n# --local-dir={x}' for x in localpath])
actioncmd += ' \\\n# --lib=%s' % libname
actioncmd += ' \\\n# --source-base=%s' % sourcebase
actioncmd += ' \\\n# --m4-base=%s' % m4base
have_GNU_date = False
if have_GNU_date:
args = ['git', 'log', '-n', '1', '--format=medium', '--date=iso', 'ChangeLog']
- result = sp.check_output(args, cwd=DIRS['root']).decode("UTF-8")
+ result = sp.check_output(args, cwd=DIRS['root']).decode('UTF-8')
# Get date as "2008-03-21 07:16:51 -0600" from string
pattern = re.compile(r'^Date:[\t ]*(.*?)$', re.M)
result = pattern.findall(result)
# Use GNU date to compute the time in GMT
args = ['date', '-d', result, '-u', '+%Y-%m-%d %H:%M:%S']
proc = sp.check_output(args)
- result = str(proc, "UTF-8")
+ result = str(proc, 'UTF-8')
result = result.rstrip(os.linesep)
return result
# gnulib copy without versioning information.
if have_git:
version_gen = joinpath(DIRS['build-aux'], 'git-version-gen')
args = [version_gen, '/dev/null']
- result = sp.check_output(args, cwd=DIRS['root']).decode("UTF-8")
+ result = sp.check_output(args, cwd=DIRS['root']).decode('UTF-8')
result = result.strip()
result = result.replace('-dirty', '-modified')
if result == 'UNKNOWN':
vc_witness = joinpath(DIRS['root'], 'ChangeLog')
mdate_sh = joinpath(DIRS['root'], 'build-aux', 'mdate-sh')
args = ['sh', mdate_sh, vc_witness]
- cvsdate = sp.check_output(args).decode("UTF-8").strip()
+ cvsdate = sp.check_output(args).decode('UTF-8').strip()
for key in repdict:
if len(key) > 3:
cvsdate = cvsdate.replace(key, repdict[key])
def execute(args: list[str], verbose: int) -> None:
'''Execute the given shell command.'''
if verbose >= 0:
- print("executing %s" % ' '.join(args), flush=True)
+ print('executing %s' % ' '.join(args), flush=True)
try: # Try to run
retcode = sp.call(args)
except Exception as error:
if retcode == 0:
os.remove(temp)
else:
- print("executing %s" % ' '.join(args))
+ print('executing %s' % ' '.join(args))
with codecs.open(temp, 'rb') as file:
cmdout = file.read()
print(cmdout)
parser.add_argument('--conditional-dependencies',
dest='cond_dependencies',
default=None,
- action="store_true")
+ action='store_true')
parser.add_argument('--no-conditional-dependencies',
dest='cond_dependencies',
default=None,
- action="store_false")
+ action='store_false')
# libtool
parser.add_argument('--libtool',
dest='libtool',
default=None,
- action="store_true")
+ action='store_true')
parser.add_argument('--no-libtool',
dest='libtool',
default=None,
- action="store_false")
+ action='store_false')
# libname
parser.add_argument('--lib',
dest='libname',
default=None,
nargs=1)
# All other arguments are collected.
- parser.add_argument("non_option_arguments",
+ parser.add_argument('non_option_arguments',
nargs='*')
# Parse the given arguments. Don't signal an error if non-option arguments
command = "find modules -type f -print | xargs -n 100 grep -l %s /dev/null | sed -e 's,^modules/,,'" % shlex.quote(filename_line_regex)
os.chdir(constants.DIRS['root'])
with sp.Popen(command, shell=True, stdout=sp.PIPE) as proc:
- result = proc.stdout.read().decode("UTF-8")
+ result = proc.stdout.read().decode('UTF-8')
os.chdir(DIRS['cwd'])
# Read module candidates from local directories.
if localpath != None and len(localpath) > 0:
for localdir in localpath:
os.chdir(localdir)
with sp.Popen(command, shell=True, stdout=sp.PIPE) as proc:
- result += proc.stdout.read().decode("UTF-8")
+ result += proc.stdout.read().decode('UTF-8')
os.chdir(DIRS['cwd'])
listing = [ line
for line in result.split('\n')