Hi Bruno,
On 4/8/24 2:19 PM, Bruno Haible wrote:
> My experience is that ChatGPT (3.5) provides good answers for things that
> have a lot of mentions on the web. Whereas for things that are rarely
> mentioned, it starts to hallucinate and often provides wrong answers.
> Therefore, for routine questions around Python or C++, it is perfectly
> suited. Whereas for expert questions or things that require logical
> reasoning, you better do a fact-checking on the answer.
Ah, okay yes that makes sense and seems to match what I have seen in
my little experience using it.
I had a Bioinformatics professor who wanted to scare us away from
using ChatGPT on homework/exams. He asked it a somewhat unique, as in
not easily found online, but interesting question about nucleotide
triplets that create stop codons [1]. I can't remember the exact
question, but ChatGPT would give very obviously incorrect answers and
insist it was correct if you mentioned it.
>> Sounds good. What do you think about two patches to normalize the
>> existing code with the conventions we've agreed upon:
>>
>> 1. Convert '+= [item]' to '.append(item)'
>
Patch 0001.
>> 2. Use single quotes for string literals.
Patch 0002.
> OK in places where the strings don't contain single-quotes. In class
> GLEmiter, in particular, there are many strings that contain commands
> in shell syntax, and these often contain single-quotes. Here, choose
> the style that best avoids backslashing.
Sounds good. In that case you have the option of double-quotes, raw
strings (r'...'), or three quotes ('''...'''). Since each of those has
their own upsides and limitations I have only changed double-quotes
which do not have an effect on backslashing if changed.
Also I ran all the tests successfully with Python 3.7 + 3.12 just to
make sure I didn't miss anything strange.
[1]
https://en.wikipedia.org/wiki/DNA_and_RNA_codon_tables#Standard_RNA_codon_table
Collin
From 7f0131f7f2a0282587b7ace9b2c5fafef9338647 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Mon, 8 Apr 2024 16:08:50 -0700
Subject: [PATCH 1/2] gnulib-tool.py: Prefer 'list.append(item)' over 'list +=
[item]'.
* pygnulib/*.py: Change occurrences '+= [item]' to use '.append(item)'
where item is a single element added to the list.
See discussion here:
<https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00091.html>
---
ChangeLog | 8 +++++++
pygnulib/GLConfig.py | 2 +-
pygnulib/GLFileSystem.py | 2 +-
pygnulib/GLImport.py | 42 ++++++++++++++++++-------------------
pygnulib/GLMakefileTable.py | 2 +-
pygnulib/GLModuleSystem.py | 10 ++++-----
pygnulib/GLTestDir.py | 18 ++++++++--------
pygnulib/constants.py | 4 ++--
pygnulib/main.py | 26 +++++++++++------------
9 files changed, 61 insertions(+), 53 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index efb797f5df..f8cd4ae4a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-04-08 Collin Funk <collin.fu...@gmail.com>
+
+ gnulib-tool.py: Prefer 'list.append(item)' over 'list += [item]'.
+ * pygnulib/*.py: Change occurrences '+= [item]' to use '.append(item)'
+ where item is a single element added to the list.
+ See discussion here:
+ <https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00091.html>
+
2024-04-08 Collin Funk <collin.fu...@gmail.com>
gnulib-tool.py: Fix incomplete type hint.
diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py
index 0f9d118a78..571c22b8fc 100644
--- a/pygnulib/GLConfig.py
+++ b/pygnulib/GLConfig.py
@@ -514,7 +514,7 @@ class GLConfig:
'''Add the module to the modules list.'''
if type(module) is str:
if module not in self.table['modules']:
- self.table['modules'] += [module]
+ self.table['modules'].append(module)
else: # if module has not str type
raise TypeError('module must be a string, not %s'
% type(module).__name__)
diff --git a/pygnulib/GLFileSystem.py b/pygnulib/GLFileSystem.py
index a463575f73..810117ec46 100644
--- a/pygnulib/GLFileSystem.py
+++ b/pygnulib/GLFileSystem.py
@@ -226,7 +226,7 @@ class GLFileAssistant:
def addFile(self, file: str) -> None:
'''Add file to the list of added files.'''
if file not in self.added:
- self.added += [file]
+ self.added.append(file)
def getFiles(self) -> list[str]:
'''Return list of the added files.'''
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index 08e83c5c9a..b5f268af3d 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -335,7 +335,7 @@ class GLImport:
path = constants.substart('top/', '', file)
else: # file is not a special file
path = file
- result += [os.path.normpath(path)]
+ result.append(os.path.normpath(path))
return sorted(set(result))
def rewrite_new_files(self, files: list[str]) -> list[str]:
@@ -371,7 +371,7 @@ class GLImport:
path = constants.substart('top/', '', file)
else: # file is not a special file
path = file
- result += [os.path.normpath(path)]
+ result.append(os.path.normpath(path))
return sorted(set(result))
def actioncmd(self) -> str:
@@ -929,7 +929,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
old_files = list(self.cache['files'])
path = joinpath(destdir, m4base, 'gnulib-tool.m4')
if isfile(path):
- old_files += [joinpath('m4', 'gnulib-tool.m4')]
+ old_files.append(joinpath('m4', 'gnulib-tool.m4'))
# Construct tables and transformers.
transformers = dict()
@@ -941,10 +941,10 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
new_table = []
for src in old_files:
dest = self.rewrite_old_files([src])[-1]
- old_table += [tuple([dest, src])]
+ old_table.append(tuple([dest, src]))
for src in new_files:
dest = self.rewrite_new_files([src])[-1]
- new_table += [tuple([dest, src])]
+ new_table.append(tuple([dest, src]))
old_table = sorted(set(old_table))
new_table = sorted(set(new_table))
@@ -997,14 +997,14 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
# Create all necessary directories.
dirs = [sourcebase, m4base]
if pobase:
- dirs += [pobase]
+ dirs.append(pobase)
if [ file
for file in filetable['all']
if file.startswith('doc/') ]:
- dirs += [docbase]
+ dirs.append(docbase)
if gentests:
- dirs += [testsbase]
- dirs += [auxdir]
+ dirs.append(testsbase)
+ dirs.append(auxdir)
dirs += sorted([ os.path.dirname(pair[0])
for pair in filetable['new'] ])
dirs = [ os.path.join(destdir, d)
@@ -1044,7 +1044,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
raise GLError(14, file) from exc
else: # if self.config['dryrun']
print('Remove file %s (backup in %s~)' % (path, path))
- filetable['removed'] += [file]
+ filetable['removed'].append(file)
# Files which are in filetable['new'] and not in filetable['old'].
# They will be added/updated and added to filetable['added'] list.
@@ -1132,7 +1132,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
print('Creating %s' % filename)
else: # if self.config['dryrun']:
print('Create %s' % filename)
- filetable['added'] += [filename]
+ filetable['added'].append(filename)
if isfile(tmpfile):
os.remove(tmpfile)
@@ -1153,7 +1153,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
print('Creating %s' % filename)
else: # if self.config['dryrun']:
print('Create %s' % filename)
- filetable['added'] += [filename]
+ filetable['added'].append(filename)
if isfile(tmpfile):
os.remove(tmpfile)
@@ -1174,7 +1174,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
print('Creating %s' % filename)
else: # if self.config['dryrun']:
print('Create %s' % filename)
- filetable['added'] += [filename]
+ filetable['added'].append(filename)
if isfile(tmpfile):
os.remove(tmpfile)
@@ -1206,7 +1206,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
print('Updating %s (backup in %s)' % (filename, backup))
elif flag == 2:
print('Creating %s' % filename)
- filetable['added'] += [filename]
+ filetable['added'].append(filename)
if isfile(tmpfile):
os.remove(tmpfile)
else: # if not self.config['dryrun']
@@ -1291,7 +1291,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
print('Creating %s' % filename)
else: # if self.config['dryrun']:
print('Create %s' % filename)
- filetable['added'] += [filename]
+ filetable['added'].append(filename)
if isfile(tmpfile):
os.remove(tmpfile)
@@ -1315,7 +1315,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
print('Creating %s' % filename)
else: # if self.config['dryrun']:
print('Create %s' % filename)
- filetable['added'] += [filename]
+ filetable['added'].append(filename)
if isfile(tmpfile):
os.remove(tmpfile)
@@ -1323,15 +1323,15 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
# Update the .cvsignore and .gitignore files.
ignorelist = []
# Treat gnulib-comp.m4 like an added file, even if it already existed.
- filetable['added'] += [joinpath(m4base, 'gnulib-comp.m4')]
+ filetable['added'].append(joinpath(m4base, 'gnulib-comp.m4'))
filetable['added'] = sorted(set(filetable['added']))
filetable['removed'] = sorted(set(filetable['removed']))
for file in filetable['added']:
directory, basename = os.path.split(file)
- ignorelist += [tuple([directory, '|A|', basename])]
+ ignorelist.append(tuple([directory, '|A|', basename]))
for file in filetable['removed']:
directory, basename = os.path.split(file)
- ignorelist += [tuple([directory, '|R|', basename])]
+ ignorelist.append(tuple([directory, '|R|', basename]))
# Sort ignorelist by directory.
ignorelist = sorted(ignorelist, key=lambda row: row[0])
last_dir = ''
@@ -1347,9 +1347,9 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
last_dir_files_added = []
last_dir_files_removed = []
if operand == '|A|':
- last_dir_files_added += [filename]
+ last_dir_files_added.append(filename)
elif operand == '|R|':
- last_dir_files_removed += [filename]
+ last_dir_files_removed.append(filename)
self._done_dir_(last_dir, last_dir_files_added, last_dir_files_removed)
# Finish the work.
diff --git a/pygnulib/GLMakefileTable.py b/pygnulib/GLMakefileTable.py
index 7547116f35..8df0822f00 100644
--- a/pygnulib/GLMakefileTable.py
+++ b/pygnulib/GLMakefileTable.py
@@ -83,7 +83,7 @@ class GLMakefileTable:
if type(dotfirst) is not bool:
raise TypeError('dotfirst must be a bool, not %s' % (type(dotfirst).__name__))
dictionary = {'dir': dir, 'var': var, 'val': val, 'dotfirst': dotfirst}
- self.table += [dictionary]
+ self.table.append(dictionary)
def parent(self, gentests: bool, source_makefile_am: str, tests_makefile_am: str) -> None:
'''Add a special row to Makefile.am table with the first parent directory
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index 761c43c2e0..c2e20b801a 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -856,7 +856,7 @@ class GLModuleTable:
inmodules = [] # Accumulator, queue for next round
for module in inmodules_this_round:
if module not in self.avoids:
- outmodules += [module]
+ outmodules.append(module)
if self.config['conddeps']:
conditional = self.isConditional(module)
dependencies = module.getDependenciesWithConditions()
@@ -878,8 +878,8 @@ class GLModuleTable:
testsname = module.getTestsName()
if self.modulesystem.exists(testsname):
testsmodule = self.modulesystem.find(testsname)
- depmodules += [testsmodule]
- conditions += [None]
+ depmodules.append(testsmodule)
+ conditions.append(None)
for depmodule in depmodules:
# Determine whether to include the dependency or tests module.
include = True
@@ -912,7 +912,7 @@ class GLModuleTable:
if not inc_all_tests:
include = False
if include and depmodule not in self.avoids:
- inmodules += [depmodule]
+ inmodules.append(depmodule)
if self.config['conddeps']:
index = depmodules.index(depmodule)
condition = conditions[index]
@@ -1056,7 +1056,7 @@ class GLModuleTable:
for listing in listings:
for file in listing:
if file not in filelist:
- filelist += [file]
+ filelist.append(file)
return filelist
def filelist_separately(self, main_modules: list[GLModule],
diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py
index 8defe52fc6..9e071ace14 100644
--- a/pygnulib/GLTestDir.py
+++ b/pygnulib/GLTestDir.py
@@ -164,7 +164,7 @@ class GLTestDir:
path = constants.substart('top/', '', file)
else: # file is not a special file
path = file
- result += [os.path.normpath(path)]
+ result.append(os.path.normpath(path))
return sorted(set(result))
def execute(self) -> None:
@@ -355,7 +355,7 @@ class GLTestDir:
filetable = []
for src in filelist:
dest = self.rewrite_files([src])[-1]
- filetable += [tuple([dest, src])]
+ filetable.append(tuple([dest, src]))
for row in filetable:
src = row[1]
dest = row[0]
@@ -466,7 +466,7 @@ class GLTestDir:
pattern = re.compile(r'AC_REQUIRE\(\[([^()]*)\]\)', re.M)
snippet = pattern.sub(r'\1', snippet)
snippet = snippet.strip()
- snippets += [snippet]
+ snippets.append(snippet)
snippets = [ snippet
for snippet in snippets
if snippet.strip()]
@@ -532,9 +532,9 @@ class GLTestDir:
# Restore changed variables.
self.config.setAuxDir(saved_auxdir)
auxdir = self.config['auxdir']
- subdirs_with_configure_ac += [testsbase]
+ subdirs_with_configure_ac.append(testsbase)
- subdirs += [testsbase]
+ subdirs.append(testsbase)
# Create Makefile.am.
emit = '## Process this file with automake to produce Makefile.in.\n\n'
@@ -580,7 +580,7 @@ class GLTestDir:
pattern = re.compile(r'AC_REQUIRE\(\[([^()]*)\]\)', re.M)
snippet = pattern.sub(r'\1', snippet)
snippet = snippet.strip()
- snippets += [snippet]
+ snippets.append(snippet)
snippets = [ snippet
for snippet in snippets
if snippet.strip() ]
@@ -659,7 +659,7 @@ class GLTestDir:
for directory in subdirs:
# For subdirs that have a configure.ac by their own, it's the subdir's
# configure.ac which creates the subdir's Makefile.am, not this one.
- makefiles += [joinpath(directory, 'Makefile')]
+ makefiles.append(joinpath(directory, 'Makefile'))
if not single_configure:
makefiles = makefiles[:-1]
emit += 'AC_CONFIG_FILES([%s])\n' % ' '.join(makefiles)
@@ -926,7 +926,7 @@ class GLMegaTestDir:
for module in modules:
self.config.setModules([str(module)])
GLTestDir(self.config, joinpath(self.megatestdir, str(module))).execute()
- megasubdirs += [str(module)]
+ megasubdirs.append(str(module))
# Then, all modules all together.
# Except config-h, which breaks all modules which use HAVE_CONFIG_H.
@@ -936,7 +936,7 @@ class GLMegaTestDir:
self.config.setModules([ str(module)
for module in modules ])
GLTestDir(self.config, joinpath(self.megatestdir, 'ALL')).execute()
- megasubdirs += ['ALL']
+ megasubdirs.append('ALL')
# Create autobuild.
emit = ''
diff --git a/pygnulib/constants.py b/pygnulib/constants.py
index a07e473529..0a4f13b434 100644
--- a/pygnulib/constants.py
+++ b/pygnulib/constants.py
@@ -275,7 +275,7 @@ def joinpath(head: str, *tail: str) -> str:
such as '$(srcdir)'.'''
newtail = []
for item in tail:
- newtail += [item]
+ newtail.append(item)
result = os.path.normpath(os.path.join(head, *tail))
return result
@@ -469,7 +469,7 @@ def filter_filelist(separator: str, filelist: str, prefix: str, suffix: str,
% (removed_prefix, removed_suffix))
result = pattern.sub(r'%s\1%s'
% (added_prefix, added_suffix), filename)
- listing += [result]
+ listing.append(result)
# Return an empty string if no files were matched, else combine them
# with the given separator.
if listing:
diff --git a/pygnulib/main.py b/pygnulib/main.py
index a67252f7f6..151229489d 100644
--- a/pygnulib/main.py
+++ b/pygnulib/main.py
@@ -757,28 +757,28 @@ def main() -> None:
inctests = True
incl_test_categories = []
if inctests:
- incl_test_categories += [constants.TESTS['tests']]
+ incl_test_categories.append(constants.TESTS['tests'])
if cmdargs.obsolete:
- incl_test_categories += [constants.TESTS['obsolete']]
+ incl_test_categories.append(constants.TESTS['obsolete'])
if cmdargs.inc_cxx_tests:
- incl_test_categories += [constants.TESTS['cxx-tests']]
+ incl_test_categories.append(constants.TESTS['cxx-tests'])
if cmdargs.inc_longrunning_tests:
- incl_test_categories += [constants.TESTS['longrunning-tests']]
+ incl_test_categories.append(constants.TESTS['longrunning-tests'])
if cmdargs.inc_privileged_tests:
- incl_test_categories += [constants.TESTS['privileged-tests']]
+ incl_test_categories.append(constants.TESTS['privileged-tests'])
if cmdargs.inc_unportable_tests:
- incl_test_categories += [constants.TESTS['unportable-tests']]
+ incl_test_categories.append(constants.TESTS['unportable-tests'])
if cmdargs.alltests:
- incl_test_categories += [constants.TESTS['all-tests']]
+ incl_test_categories.append(constants.TESTS['all-tests'])
excl_test_categories = []
if cmdargs.excl_cxx_tests:
- excl_test_categories += [constants.TESTS['cxx-tests']]
+ excl_test_categories.append(constants.TESTS['cxx-tests'])
if cmdargs.excl_longrunning_tests:
- excl_test_categories += [constants.TESTS['longrunning-tests']]
+ excl_test_categories.append(constants.TESTS['longrunning-tests'])
if cmdargs.excl_privileged_tests:
- excl_test_categories += [constants.TESTS['privileged-tests']]
+ excl_test_categories.append(constants.TESTS['privileged-tests'])
if cmdargs.excl_unportable_tests:
- excl_test_categories += [constants.TESTS['unportable-tests']]
+ excl_test_categories.append(constants.TESTS['unportable-tests'])
lgpl = cmdargs.lgpl
if lgpl != None:
lgpl = lgpl[-1]
@@ -999,7 +999,7 @@ def main() -> None:
# Ignore absolute directory pathnames, like /usr/local/share/aclocal.
if not isabs(aclocal_amflag):
if isfile(joinpath(destdir, aclocal_amflag, 'gnulib-cache.m4')):
- m4dirs += [aclocal_amflag]
+ m4dirs.append(aclocal_amflag)
dirisnext = False
else: # if not dirisnext
if aclocal_amflag == '-I':
@@ -1010,7 +1010,7 @@ def main() -> None:
# Ignore absolute directory pathnames, like /usr/local/share/aclocal.
if not isabs(arg):
if isfile(joinpath(destdir, arg, 'gnulib-cache.m4')):
- m4dirs += [arg]
+ m4dirs.append(arg)
else: # if not isfile(filepath)
# No Makefile.am! Oh well. Look at the last generated aclocal.m4.
filepath = joinpath(destdir, 'aclocal.m4')
--
2.44.0
From 9f697acabf2b5815ebae10642c67e0d65303541a Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Mon, 8 Apr 2024 16:37:48 -0700
Subject: [PATCH 2/2] 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.
---
ChangeLog | 6 ++++
pygnulib/GLConfig.py | 2 +-
pygnulib/GLEmiter.py | 60 ++++++++++++++++++++--------------------
pygnulib/GLError.py | 32 ++++++++++-----------
pygnulib/GLFileSystem.py | 2 +-
pygnulib/GLImport.py | 2 +-
pygnulib/GLInfo.py | 6 ++--
pygnulib/GLTestDir.py | 2 +-
pygnulib/constants.py | 4 +--
pygnulib/main.py | 14 +++++-----
10 files changed, 68 insertions(+), 62 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f8cd4ae4a7..fe6a8974b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-04-08 Collin Funk <collin.fu...@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.fu...@gmail.com>
gnulib-tool.py: Prefer 'list.append(item)' over 'list += [item]'.
diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py
index 571c22b8fc..e0530c9886 100644
--- a/pygnulib/GLConfig.py
+++ b/pygnulib/GLConfig.py
@@ -396,7 +396,7 @@ class GLConfig:
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
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index 45462c5fe3..963d3ac3ad 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -126,7 +126,7 @@ class GLEmiter:
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
@@ -146,7 +146,7 @@ class GLEmiter:
# 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:
@@ -464,15 +464,15 @@ class GLEmiter:
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 \\
@@ -510,7 +510,7 @@ EXTRA_LOCALE_CATEGORIES =
# 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:
@@ -518,9 +518,9 @@ USE_MSGCTXT = no\n"""
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)
@@ -548,27 +548,27 @@ USE_MSGCTXT = no\n"""
# 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'
@@ -663,7 +663,7 @@ changequote([, ])dnl
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.
@@ -690,7 +690,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
m4_append([%V1%_LIBSOURCES_LIST], _gl_NAME, [ ])
])
])
-])\n"""
+])\n'''
emit = emit.replace('%V1%', macro_prefix_arg)
emit = emit.replace('%V2%', sourcebase_arg)
return emit
@@ -766,12 +766,12 @@ AC_DEFUN([%V1%_LIBSOURCES], [
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
@@ -1059,8 +1059,8 @@ AC_DEFUN([%V1%_LIBSOURCES], [
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
@@ -1247,11 +1247,11 @@ AC_DEFUN([%V1%_LIBSOURCES], [
# 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:
diff --git a/pygnulib/GLError.py b/pygnulib/GLError.py
index e1b6d747d5..a4c835f43e 100644
--- a/pygnulib/GLError.py
+++ b/pygnulib/GLError.py
@@ -76,43 +76,43 @@ class GLError(Exception):
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:
diff --git a/pygnulib/GLFileSystem.py b/pygnulib/GLFileSystem.py
index 810117ec46..6c40586574 100644
--- a/pygnulib/GLFileSystem.py
+++ b/pygnulib/GLFileSystem.py
@@ -341,7 +341,7 @@ class GLFileAssistant:
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:
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index b5f268af3d..f890c07a86 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -409,7 +409,7 @@ class GLImport:
# 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
diff --git a/pygnulib/GLInfo.py b/pygnulib/GLInfo.py
index c38977c23e..845ca6d733 100644
--- a/pygnulib/GLInfo.py
+++ b/pygnulib/GLInfo.py
@@ -105,7 +105,7 @@ class GLInfo:
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)
@@ -116,7 +116,7 @@ class GLInfo:
# 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.
@@ -342,7 +342,7 @@ Report bugs to <bug-gnulib@gnu.org>.'''
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':
diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py
index 9e071ace14..e8c8f63faf 100644
--- a/pygnulib/GLTestDir.py
+++ b/pygnulib/GLTestDir.py
@@ -958,7 +958,7 @@ class GLMegaTestDir:
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])
diff --git a/pygnulib/constants.py b/pygnulib/constants.py
index 0a4f13b434..014dcce947 100644
--- a/pygnulib/constants.py
+++ b/pygnulib/constants.py
@@ -219,7 +219,7 @@ def force_output() -> None:
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:
@@ -238,7 +238,7 @@ def execute(args: list[str], verbose: int) -> None:
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)
diff --git a/pygnulib/main.py b/pygnulib/main.py
index 151229489d..530b22e6f2 100644
--- a/pygnulib/main.py
+++ b/pygnulib/main.py
@@ -359,20 +359,20 @@ def main() -> None:
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',
@@ -495,7 +495,7 @@ def main() -> None:
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
@@ -872,7 +872,7 @@ def main() -> None:
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:
@@ -880,7 +880,7 @@ def main() -> None:
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')
--
2.44.0