Hi, Recently I got frustrated again about how much time the creation of a gnulib testdir takes. I found out that
1) There is not much difference between "bash gnulib-tool ..." and "dash gnulib-tool ...". Although bash is generally slower than other Bourne-compatible shells, for gnulib-tool is does not matter much. 2) Two thirds of the runtime is spent in the license compatibility checks, because for each module, we compute func_modules_transitive_closure and then extract the license of each module in this transitive closure. So, it's clear that what needs speedup is the string and list processing of func_verify_module, func_acceptable, func_get_dependencies, func_get_tests_module, and so on. This was also confirmed by doing bash profiling. So, it becomes clear again that a shell script — because it has a relatively small library of built-ins — is not suitable for massive string and list processing. In other words, a shell script is useful for connecting programs together (through files, pipes, sockets), but shell is just *NOT* a decent _application_ programming language. I considered splitting the low-level parts (dealing with module description files and module description fields) to a C part, leaving the upper layer in shell. (a) by compiling the C part as a shared library — but that is not future- proof because the interface between bash extensions and bash is not documented. (b) by compiling the C part as a program, run as bash 'coproc'. This is more solid. gnulib-tool would send strings that look like function invocations to the C coprocess, and this one would respond with strings sent back, that gnulib-tool would read into bash variables through "IFS= read -r -delim ''". Still, the amount of process communication frightens me. Then I ran gnulib-tool.py again, found that it is faster than I expected (maybe Python 3 has a better compiler now than 10 years ago?). Also, Python is more popular than ever (but that helps us only if we don't have idio- syncracies in our Python code). So, I am now restarting the effort to bring gnulib-tool.py up-to-date with gnulib-tool. Today's changes: 2022-07-29 Bruno Haible <br...@clisp.org> gnulib-tool.py: Follow gnulib-tool changes, part 17. Follow gnulib-tool change 2015-10-06 Pavel Raiskup <prais...@redhat.com> gnulib-tool: fix tests of 'extensions' module * pygnulib/GLEmiter.py (GLEmiter.preEarlyMacros): New function. * pygnulib/GLImport.py (GLImport.gnulib_comp): Invoke it. * pygnulib/GLTestDir.py (GLTestDir.execute): Likewise. gnulib-tool.py: Follow gnulib-tool changes, part 16. Follow gnulib-tool change 2015-09-25 Pavel Raiskup <prais...@redhat.com> gnulib-common.m4: fix gl_PROG_AR_RANLIB/AM_PROG_AR clash * pygnulib/GLImport.py (GLImport.gnulib_comp): Put the gl_USE_SYSTEM_EXTENSIONS right before gl_PROG_AR_RANLIB into gnulib-comp.m4 (if the 'extensions' module is used). gnulib-tool.py: Modernize coding style. * pygnulib/*.py: Remove parentheses around return value expressions. gnulib-tool.py: Modernize the file headers. * pygnulib/*.py: Remove '#!/usr/bin/python' (not needed) and 'encoding: UTF-8' lines (default in Python 3). Add copyright notice. gnulib-tool.py: Use mainstream coding style. * gnulib-tool.py: Clarify the coding style. Fix some pycodestyle warnings. * pygnulib/constants.py: Likewise. * pygnulib/GLEmiter.py: Likewise. * pygnulib/GLImport.py: Likewise. * pygnulib/GLMakefileTable.py: Likewise.
>From f00ef30ee0a68bf91cfd081afc784cb8ffd00656 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Fri, 29 Jul 2022 16:35:28 +0200 Subject: [PATCH 1/5] gnulib-tool.py: Use mainstream coding style. * gnulib-tool.py: Clarify the coding style. Fix some pycodestyle warnings. * pygnulib/constants.py: Likewise. * pygnulib/GLEmiter.py: Likewise. * pygnulib/GLImport.py: Likewise. * pygnulib/GLMakefileTable.py: Likewise. --- ChangeLog | 10 ++++++++++ gnulib-tool.py | 10 ++++++++-- pygnulib/GLEmiter.py | 6 +++--- pygnulib/GLImport.py | 2 +- pygnulib/GLMakefileTable.py | 6 +++--- pygnulib/constants.py | 10 ++++++---- 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5ebb0f1dc2..20cf23f499 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2022-07-29 Bruno Haible <br...@clisp.org> + + gnulib-tool.py: Use mainstream coding style. + * gnulib-tool.py: Clarify the coding style. Fix some pycodestyle + warnings. + * pygnulib/constants.py: Likewise. + * pygnulib/GLEmiter.py: Likewise. + * pygnulib/GLImport.py: Likewise. + * pygnulib/GLMakefileTable.py: Likewise. + 2022-07-29 Bruno Haible <br...@clisp.org> gnulib-tool.py: Fix error (regression 2021-04-11). diff --git a/gnulib-tool.py b/gnulib-tool.py index f81501b9c0..860487a934 100755 --- a/gnulib-tool.py +++ b/gnulib-tool.py @@ -19,6 +19,13 @@ # This program is meant for authors or maintainers which want to import # modules from gnulib into their packages. +# CODING STYLE for this file and its companions: +# Like PEP 8 <https://peps.python.org/pep-0008/>, except +# - Line length is not limited to 79 characters. +# - Line breaking before or after binary operators? Better before, like in GNU. +# You can use this command to check the style: +# $ pycodestyle --max-line-length=128 --ignore=E265,W503,E241,E711,E712 gnulib-tool.py pygnulib/*.py + #=============================================================================== # Define global imports @@ -993,8 +1000,7 @@ if __name__ == '__main__': with codecs.open(tempname, 'wb', 'UTF-8') as file: file.write(incompatibilities) sed_table = 's,^\\([^ ]*\\) ,\\1' + ' ' * 51 + ',\n' - sed_table += 's,^\\(' + '.' * 49 + \ - '[^ ]*\) *,' + ' ' * 17 + '\\1 ,' + sed_table += 's,^\\(' + '.' * 49 + '[^ ]*\\) *,' + ' ' * 17 + '\\1 ,' args = ['sed', '-e', sed_table, tempname] incompatibilities = sp.check_output( args).decode(ENCS['default']) diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py index 6d523bda3c..3009214c9d 100644 --- a/pygnulib/GLEmiter.py +++ b/pygnulib/GLEmiter.py @@ -516,7 +516,7 @@ USE_MSGCTXT = no\n""" # 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 # directory, the check is skipped. - emit += """\ + emit += r"""\ m4_ifval(%V1%_LIBSOURCES_LIST, [ m4_syscmd([test ! -d ]m4_defn([%V1%_LIBSOURCES_DIR])[ || for gl_file in ]%V1%_LIBSOURCES_LIST[ ; do @@ -733,8 +733,8 @@ AC_DEFUN([%V1%_LIBSOURCES], [ amsnippet1 += '%s_%s_DEPENDENCIES += @%sALLOCA@\n' % \ (libname, libext, perhapsLT) amsnippet1 = constants.combine_lines_matching( - compiler('%s_%s_SOURCES' % (libname, libext)), - amsnippet1) + compiler('%s_%s_SOURCES' % (libname, libext)), + amsnippet1) # Get unconditional snippet, edit it and save to amsnippet2. amsnippet2 = module.getAutomakeSnippet_Unconditional() diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index 4fa00259e7..3acf94c463 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -105,7 +105,7 @@ class GLImport(object): self.config.setAuxDir(self.cache['auxdir']) # Guess autoconf version. - pattern = compiler('.*AC_PREREQ\((.*?)\)', re.S | re.M) + pattern = compiler(r'.*AC_PREREQ\((.*?)\)', re.S | re.M) versions = cleaner(pattern.findall(data)) if versions: version = sorted(set([float(version) for version in versions]))[-1] diff --git a/pygnulib/GLMakefileTable.py b/pygnulib/GLMakefileTable.py index 74e6fe7d7d..1e848395d0 100644 --- a/pygnulib/GLMakefileTable.py +++ b/pygnulib/GLMakefileTable.py @@ -117,9 +117,9 @@ class GLMakefileTable(object): mfx = makefile dir2 = string() while dir1 and \ - (joinpath(self.config['destdir'], dir1, mfd) or - joinpath(dir1, mfd) == joinpath(sourcebase, mfx) or - (inctests and joinpath(dir1, mfd) == joinpath(testsbase, mfx))): + (joinpath(self.config['destdir'], dir1, mfd) + or joinpath(dir1, mfd) == joinpath(sourcebase, mfx) + or (inctests and joinpath(dir1, mfd) == joinpath(testsbase, mfx))): dir2 = joinpath(os.path.basename(dir1), dir2) dir1 = os.path.dirname(dir1) self.editor(dir1, 'EXTRA_DIST', joinpath(dir2, 'gnulib-cache.m4')) diff --git a/pygnulib/constants.py b/pygnulib/constants.py index 39fe08f002..7b37a5241c 100644 --- a/pygnulib/constants.py +++ b/pygnulib/constants.py @@ -13,6 +13,7 @@ import sys import platform import tempfile import subprocess as sp +import __main__ as interpreter #=============================================================================== @@ -68,7 +69,6 @@ ABCDEFGHIJKLMNOPQRSTUVWXYZ\ 0123456789' # Alphanumeric characters # Set ENCS dictionary -import __main__ as interpreter if not hasattr(interpreter, '__file__'): if sys.stdout.encoding != None: ENCS['default'] = sys.stdout.encoding @@ -443,12 +443,14 @@ def remove_backslash_newline(text): line to it.''' return text.replace('\\\n', '') + def combine_lines(text): '''Given a multiline string text, join lines by spaces: When a line ends in a backslash, remove the backslash and join the next line to it, inserting a space between them.''' return text.replace('\\\n', ' ') + def combine_lines_matching(pattern, text): '''Given a multiline string text, join lines by spaces, when the first such line matches a given RegexObject pattern. @@ -461,9 +463,9 @@ def combine_lines_matching(pattern, text): while match: (startpos, pos) = match.span() # Look how far the continuation lines extend. - pos = text.find('\n',pos) - while pos > 0 and text[pos-1] == '\\': - pos = text.find('\n',pos+1) + pos = text.find('\n', pos) + while pos > 0 and text[pos - 1] == '\\': + pos = text.find('\n', pos + 1) if pos < 0: pos = len(text) # Perform a combine_lines throughout the continuation lines. -- 2.34.1
>From 3e44e3bb0c1a91faa5b31b257c9f32fb752f8c2d Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Fri, 29 Jul 2022 16:41:28 +0200 Subject: [PATCH 2/5] gnulib-tool.py: Modernize the file headers. * pygnulib/*.py: Remove '#!/usr/bin/python' (not needed) and 'encoding: UTF-8' lines (default in Python 3). Add copyright notice. --- ChangeLog | 4 ++++ pygnulib/GLConfig.py | 16 ++++++++++++++-- pygnulib/GLEmiter.py | 16 ++++++++++++++-- pygnulib/GLError.py | 16 ++++++++++++++-- pygnulib/GLFileSystem.py | 16 ++++++++++++++-- pygnulib/GLImport.py | 16 ++++++++++++++-- pygnulib/GLInfo.py | 16 ++++++++++++++-- pygnulib/GLMakefileTable.py | 16 ++++++++++++++-- pygnulib/GLModuleSystem.py | 16 ++++++++++++++-- pygnulib/GLTestDir.py | 16 ++++++++++++++-- pygnulib/__init__.py | 17 ++++++++++++++++- pygnulib/classes.py | 16 ++++++++++++++-- pygnulib/constants.py | 16 ++++++++++++++-- 13 files changed, 174 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 20cf23f499..01c73c251f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2022-07-29 Bruno Haible <br...@clisp.org> + gnulib-tool.py: Modernize the file headers. + * pygnulib/*.py: Remove '#!/usr/bin/python' (not needed) and + 'encoding: UTF-8' lines (default in Python 3). Add copyright notice. + gnulib-tool.py: Use mainstream coding style. * gnulib-tool.py: Clarify the coding style. Fix some pycodestyle warnings. diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py index fe219a36f6..aea34720de 100644 --- a/pygnulib/GLConfig.py +++ b/pygnulib/GLConfig.py @@ -1,5 +1,17 @@ -#!/usr/bin/python -# encoding: UTF-8 +# Copyright (C) 2002-2022 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. #=============================================================================== # Define global imports diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py index 3009214c9d..261d94ec88 100644 --- a/pygnulib/GLEmiter.py +++ b/pygnulib/GLEmiter.py @@ -1,5 +1,17 @@ -#!/usr/bin/python -# encoding: UTF-8 +# Copyright (C) 2002-2022 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. #=============================================================================== # Define global imports diff --git a/pygnulib/GLError.py b/pygnulib/GLError.py index 0727e2f38f..93604999d6 100644 --- a/pygnulib/GLError.py +++ b/pygnulib/GLError.py @@ -1,5 +1,17 @@ -#!/usr/bin/python -# encoding: UTF-8 +# Copyright (C) 2002-2022 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. #=============================================================================== # Define global imports diff --git a/pygnulib/GLFileSystem.py b/pygnulib/GLFileSystem.py index d5e253f965..1edd6d7776 100644 --- a/pygnulib/GLFileSystem.py +++ b/pygnulib/GLFileSystem.py @@ -1,5 +1,17 @@ -#!/usr/bin/python -# encoding: UTF-8 +# Copyright (C) 2002-2022 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. #=============================================================================== # Define global imports diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index 3acf94c463..61f700b8c5 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -1,5 +1,17 @@ -#!/usr/bin/python -# encoding: UTF-8 +# Copyright (C) 2002-2022 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. #=============================================================================== # Define global imports diff --git a/pygnulib/GLInfo.py b/pygnulib/GLInfo.py index 46f1dcc2d8..b3cc59dc07 100644 --- a/pygnulib/GLInfo.py +++ b/pygnulib/GLInfo.py @@ -1,5 +1,17 @@ -#!/usr/bin/python -# encoding: UTF-8 +# Copyright (C) 2002-2022 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. #=============================================================================== # Define global imports diff --git a/pygnulib/GLMakefileTable.py b/pygnulib/GLMakefileTable.py index 1e848395d0..00050b2723 100644 --- a/pygnulib/GLMakefileTable.py +++ b/pygnulib/GLMakefileTable.py @@ -1,5 +1,17 @@ -#!/usr/bin/python -# encoding: UTF-8 +# Copyright (C) 2002-2022 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. #=============================================================================== # Define global imports diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py index 11ff4c7963..01e7188c74 100644 --- a/pygnulib/GLModuleSystem.py +++ b/pygnulib/GLModuleSystem.py @@ -1,5 +1,17 @@ -#!/usr/bin/python -# encoding: UTF-8 +# Copyright (C) 2002-2022 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. #=============================================================================== # Define global imports diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py index fded6d7656..c0657acc0d 100644 --- a/pygnulib/GLTestDir.py +++ b/pygnulib/GLTestDir.py @@ -1,5 +1,17 @@ -#!/usr/bin/python -# encoding: UTF-8 +# Copyright (C) 2002-2022 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. #=============================================================================== # Define global imports diff --git a/pygnulib/__init__.py b/pygnulib/__init__.py index 129061be6a..5e916b2e2b 100644 --- a/pygnulib/__init__.py +++ b/pygnulib/__init__.py @@ -1,3 +1,18 @@ +# Copyright (C) 2002-2022 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + '''Gnulib - The GNU Portability Library GNU software has a well-deserved reputation for running on many different types of systems. While our primary goal is to write software for the GNU system, many @@ -15,6 +30,6 @@ coding standards, the GNU maintainer information, the GPL and other licenses (in Texinfo), assorted configuration scripts, and more. The goal is to provide all the common infrastructure needed by GNU packages.''' -__copyright__ = '2012-2017 Free Software Foundation, Inc.' +__copyright__ = '2012-2022 Free Software Foundation, Inc.' __author__ = 'Dmitriy Selyutin' __license__ = 'GNU GPLv3+' diff --git a/pygnulib/classes.py b/pygnulib/classes.py index 9e8a65851a..575e0b08c3 100644 --- a/pygnulib/classes.py +++ b/pygnulib/classes.py @@ -1,5 +1,17 @@ -#!/usr/bin/python -# encoding: UTF-8 +# Copyright (C) 2002-2022 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. '''An easy access to pygnulib classes.''' diff --git a/pygnulib/constants.py b/pygnulib/constants.py index 7b37a5241c..f36a9e0a7d 100644 --- a/pygnulib/constants.py +++ b/pygnulib/constants.py @@ -1,5 +1,17 @@ -#!/usr/bin/python -# encoding: UTF-8 +# Copyright (C) 2002-2022 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. '''An easy access to pygnulib constants.''' -- 2.34.1
>From 0bc144f96608c17963d021468f278a8d0c577894 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Fri, 29 Jul 2022 18:45:33 +0200 Subject: [PATCH 3/5] gnulib-tool.py: Modernize coding style. * pygnulib/*.py: Remove parentheses around return value expressions. --- ChangeLog | 3 + pygnulib/GLConfig.py | 104 ++++++++++++++++---------------- pygnulib/GLEmiter.py | 22 +++---- pygnulib/GLError.py | 2 +- pygnulib/GLFileSystem.py | 12 ++-- pygnulib/GLImport.py | 14 ++--- pygnulib/GLInfo.py | 16 ++--- pygnulib/GLMakefileTable.py | 4 +- pygnulib/GLModuleSystem.py | 114 ++++++++++++++++++------------------ pygnulib/GLTestDir.py | 2 +- pygnulib/constants.py | 18 +++--- 11 files changed, 157 insertions(+), 154 deletions(-) diff --git a/ChangeLog b/ChangeLog index 01c73c251f..01d8df2e13 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2022-07-29 Bruno Haible <br...@clisp.org> + gnulib-tool.py: Modernize coding style. + * pygnulib/*.py: Remove parentheses around return value expressions. + gnulib-tool.py: Modernize the file headers. * pygnulib/*.py: Remove '#!/usr/bin/python' (not needed) and 'encoding: UTF-8' lines (default in Python 3). Add copyright notice. diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py index aea34720de..d925e7b2b3 100644 --- a/pygnulib/GLConfig.py +++ b/pygnulib/GLConfig.py @@ -284,7 +284,7 @@ class GLConfig(object): # Define special methods. def __repr__(self): '''x.__repr__() <==> repr(x)''' - return('<pygnulib.GLConfig>') + return '<pygnulib.GLConfig>' def __getitem__(self, y): '''x.__getitem__(y) <==> x[y]''' @@ -296,18 +296,18 @@ class GLConfig(object): if self.table['auxdir']: return self.table['auxdir'] return "build-aux" - return(self.table[y]) + return self.table[y] else: # if y not in self.table raise(KeyError('GLConfig does not contain key: %s' % repr(y))) def dictionary(self): '''Return the configuration as a dict object.''' - return(dict(self.table)) + return dict(self.table) def copy(self): '''Return the copy of the configuration.''' table = copy.deepcopy(self) - return(table) + return table def update(self, dictionary): '''Specify the dictionary whose keys will be used to update config.''' @@ -346,28 +346,28 @@ class GLConfig(object): '''Return default value for the given key.''' if key in self.table: if key == 'libname': - return(string('libgnu')) + return string('libgnu') elif key == 'macro_prefix': - return(string('gl')) + return string('gl') elif key == 'include_guard_prefix': - return(string('GL')) + return string('GL') elif key == 'ac_version': - return(2.59) + return 2.59 elif key == 'verbosity': - return(0) + return 0 elif key == 'copyrights': - return(True) + return True elif key in ['modules', 'avoids', 'tests', 'testflags']: - return(list()) + return list() elif key in ['libtool', 'lgpl', 'conddeps', 'modcache', 'symbolic', 'lsymbolic', 'libtests', 'dryrun']: - return(False) + return False if key == 'vc_files': - return(None) + return None elif key == 'errors': - return(True) + return True else: # otherwise - return(string()) + return string() else: # if key not in self.table raise(KeyError('GLConfig does not contain key: %s' % repr(key))) @@ -375,23 +375,23 @@ class GLConfig(object): '''Check whether the value for the given key is a default value.''' if key in self.table: default = self.default(key) - return(value == default) + return value == default else: # if key not in self.table raise(KeyError('GLConfig does not contain key: %s' % repr(key))) def keys(self): '''Return list of keys.''' - return(list(self.table.keys())) + return list(self.table.keys()) def values(self): '''Return list of values.''' - return(list(self.table.values())) + return list(self.table.values()) # Define destdir methods. def getDestDir(self): '''Return the target directory. For --import, this specifies where your configure.ac can be found. Defaults to current directory.''' - return(self.table['destdir']) + return self.table['destdir'] def setDestDir(self, destdir): '''Specify the target directory. For --import, this specifies where your @@ -414,7 +414,7 @@ class GLConfig(object): def getLocalDir(self): '''Return a local override directory where to look up files before looking in gnulib's directory.''' - return(self.table['localdir']) + return self.table['localdir'] def setLocalDir(self, localdir): '''Specify a local override directory where to look up files before looking @@ -461,7 +461,7 @@ class GLConfig(object): # Define sourcebase methods. def getSourceBase(self): '''Return directory relative to destdir where source code is placed.''' - return(self.table['sourcebase']) + return self.table['sourcebase'] def setSourceBase(self, sourcebase): '''Specify directory relative to destdir where source code is placed.''' @@ -481,7 +481,7 @@ class GLConfig(object): # Define m4base methods. def getM4Base(self): '''Return directory relative to destdir where *.m4 macros are placed.''' - return(self.table['m4base']) + return self.table['m4base'] def setM4Base(self, m4base): '''Specify directory relative to destdir where *.m4 macros are placed.''' @@ -501,7 +501,7 @@ class GLConfig(object): # Define pobase methods. def getPoBase(self): '''Return directory relative to destdir where *.po files are placed.''' - return(self.table['pobase']) + return self.table['pobase'] def setPoBase(self, pobase): '''Specify directory relative to destdir where *.po files are placed.''' @@ -522,7 +522,7 @@ class GLConfig(object): def getDocBase(self): '''Return directory relative to destdir where doc files are placed. Default value for this variable is 'doc').''' - return(self.table['docbase']) + return self.table['docbase'] def setDocBase(self, docbase): '''Specify directory relative to destdir where doc files are placed. @@ -545,7 +545,7 @@ class GLConfig(object): def getTestsBase(self): '''Return directory relative to destdir where unit tests are placed. Default value for this variable is 'tests').''' - return(self.table['testsbase']) + return self.table['testsbase'] def setTestsBase(self, testsbase): '''Specify directory relative to destdir where unit tests are placed. @@ -589,7 +589,7 @@ class GLConfig(object): def getModules(self): '''Return the modules list.''' - return(list(self.table['modules'])) + return list(self.table['modules']) def setModules(self, modules): '''Set the modules list.''' @@ -639,7 +639,7 @@ class GLConfig(object): def getAvoids(self): '''Return the list of the avoided modules.''' - return(list(self.table['avoids'])) + return list(self.table['avoids']) def setAvoids(self, modules): '''Specify the modules which will be avoided.''' @@ -688,7 +688,7 @@ class GLConfig(object): def getFiles(self): '''Return the list of the fileed files.''' - return(list(self.table['files'])) + return list(self.table['files']) def setFiles(self, files): '''Specify the list of files.''' @@ -716,7 +716,7 @@ class GLConfig(object): def checkTestFlag(self, flag): '''Return the status of the test flag.''' if flag in TESTS.values(): - return(flag in self.table['testflags']) + return flag in self.table['testflags'] else: # if flag is not in TESTS raise(TypeError('unknown flag: %s' % repr(flag))) @@ -738,7 +738,7 @@ class GLConfig(object): def getTestFlags(self): '''Return test flags. You can get flags from TESTS variable.''' - return(list(self.table['testflags'])) + return list(self.table['testflags']) def setTestFlags(self, testflags): '''Specify test flags. You can get flags from TESTS variable.''' @@ -763,7 +763,7 @@ class GLConfig(object): # Define libname methods. def getLibName(self): '''Return the library name.''' - return(self.table['libname']) + return self.table['libname'] def setLibName(self, libname): '''Specify the library name.''' @@ -783,7 +783,7 @@ class GLConfig(object): # Define libtool methods. def checkLibtool(self): '''Check if user enabled libtool rules.''' - return(self.table['libtool']) + return self.table['libtool'] def enableLibtool(self): '''Enable libtool rules.''' @@ -800,7 +800,7 @@ class GLConfig(object): # Define conddeps methods. def checkCondDeps(self): '''Check if user enabled cond. dependencies.''' - return(self.table['conddeps']) + return self.table['conddeps'] def enableCondDeps(self): '''Enable cond. dependencies (may save configure time and object code).''' @@ -818,7 +818,7 @@ class GLConfig(object): def getLGPL(self): '''Check for abort if modules aren't available under the LGPL. Default value is False, which means that lgpl is disabled.''' - return(self.table['lgpl']) + return self.table['lgpl'] def setLGPL(self, lgpl): '''Abort if modules aren't available under the LGPL. @@ -835,17 +835,17 @@ class GLConfig(object): def getIncludeGuardPrefix(self): '''Return include_guard_prefix to use inside GLEmiter class.''' - return(self.table['include_guard_prefix']) + return self.table['include_guard_prefix'] def getModuleIndicatorPrefix(self): '''Return module_indicator_prefix to use inside GLEmiter class.''' - return(self.getIncludeGuardPrefix()) + return self.getIncludeGuardPrefix() # Define macro_prefix methods. def getMacroPrefix(self): '''Return the prefix of the macros 'gl_EARLY' and 'gl_INIT'. Default macro_prefix is 'gl'.''' - return(self.table['macro_prefix']) + return self.table['macro_prefix'] def setMacroPrefix(self, macro_prefix): '''Specify the prefix of the macros 'gl_EARLY' and 'gl_INIT'. @@ -879,7 +879,7 @@ class GLConfig(object): def getMakefile(self): '''Return the name of makefile in automake syntax in the source-base and tests-base directories. Default is 'Makefile.am'.''' - return(self.table['makefile']) + return self.table['makefile'] def setMakefile(self, makefile): '''Specify the name of makefile in automake syntax in the source-base and @@ -902,7 +902,7 @@ class GLConfig(object): def getPoDomain(self): '''Return the prefix of the i18n domain. Usually use the package name. A suffix '-gnulib' is appended.''' - return(self.table['podomain']) + return self.table['podomain'] def setPoDomain(self, podomain): '''Specify the prefix of the i18n domain. Usually use the package name. @@ -925,7 +925,7 @@ class GLConfig(object): def getWitnessCMacro(self): '''Return the C macro that is defined when the sources in this directory are compiled or used.''' - return(self.table['witness_c_macro']) + return self.table['witness_c_macro'] def setWitnessCMacro(self, witness_c_macro): '''Specify the C macro that is defined when the sources in this directory @@ -947,7 +947,7 @@ class GLConfig(object): # Define vc_files methods. def checkVCFiles(self): '''Check if update of the version control files is enabled or disabled.''' - return(self.table['vc_files']) + return self.table['vc_files'] def enableVCFiles(self): '''Enable update of the version control files.''' @@ -964,7 +964,7 @@ class GLConfig(object): # Define modcache methods. def checkModuleCaching(self): '''Get status of module caching optimization.''' - return(self.table['modcache']) + return self.table['modcache'] def enableModuleCaching(self): '''Enable module caching optimization.''' @@ -981,7 +981,7 @@ class GLConfig(object): # Define configure_ac methods. def getAutoconfFile(self): '''Return path of autoconf file relative to destdir.''' - return(self.table['configure_ac']) + return self.table['configure_ac'] def setAutoconfFile(self, configure_ac): '''Specify path of autoconf file relative to destdir.''' @@ -1007,7 +1007,7 @@ class GLConfig(object): # Define ac_version methods. def getAutoconfVersion(self): '''Return preferred autoconf version. Default value is 2.59.''' - return(self.table['ac_version']) + return self.table['ac_version'] def setAutoconfVersion(self, ac_version): '''Specify preferred autoconf version. Default value is 2.59.''' @@ -1024,11 +1024,11 @@ class GLConfig(object): # Define symbolic methods. def checkCopyrights(self): '''Check if copyright notices in files should be replaced.''' - return(self.table['copyrights']) + return self.table['copyrights'] def checkSymbolic(self): '''Check if pygnulib will make symbolic links instead of copying files.''' - return(self.table['symbolic']) + return self.table['symbolic'] def enableSymbolic(self): '''Enable creation of the symbolic links instead of copying files.''' @@ -1049,7 +1049,7 @@ class GLConfig(object): def checkLSymbolic(self): '''Check if pygnulib will make symbolic links instead of copying files, only for files from the local override directory.''' - return(self.table['lsymbolic']) + return self.table['lsymbolic'] def enableLSymbolic(self): '''Enable creation of symbolic links instead of copying files, only for @@ -1069,7 +1069,7 @@ class GLConfig(object): # Define verbosity methods. def getVerbosity(self): '''Get verbosity level.''' - return(self.table['verbosity']) + return self.table['verbosity'] def decreaseVerbosity(self): '''Decrease verbosity level.''' @@ -1103,7 +1103,7 @@ class GLConfig(object): # Define libtests methods. def checkLibtests(self): '''Return True if a testsbase/libtests.a is needed.''' - return(self.table['libtests']) + return self.table['libtests'] def enableLibtests(self): '''If libtests is enabled, then testsbase/libtests.a is needed.''' @@ -1120,7 +1120,7 @@ class GLConfig(object): # Define single_configure methods. def checkSingleConfigure(self): '''Check whether single configure file should be generated.''' - return(self.table['single_configure']) + return self.table['single_configure'] def enableSingleConfigure(self): '''Enable generation of the single configure file.''' @@ -1137,7 +1137,7 @@ class GLConfig(object): # Define dryrun methods. def checkDryRun(self): '''Check whether dryrun is enabled.''' - return(self.table['dryrun']) + return self.table['dryrun'] def enableDryRun(self): '''Enable dryrun mode.''' @@ -1154,7 +1154,7 @@ class GLConfig(object): # Define errors methods. def checkErrors(self): '''Check if GLError will be raised in non-critical situations.''' - return(self.table['errors']) + return self.table['errors'] def enableErrors(self): '''Raise GLError in non-critical situations.''' diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py index 261d94ec88..8f20990f16 100644 --- a/pygnulib/GLEmiter.py +++ b/pygnulib/GLEmiter.py @@ -82,7 +82,7 @@ class GLEmiter(object): def __repr__(self): '''x.__repr__() <==> repr(x)''' result = '<pygnulib.GLEmiter %s>' % hex(id(self)) - return(result) + return result def copyright_notice(self): '''GLEmiter.copyright_notice() -> string @@ -113,7 +113,7 @@ class GLEmiter(object): # Generated by gnulib-tool.\n""" if type(emit) is bytes: emit = emit.decode(ENCS['default']) - return(constants.nlconvert(emit)) + return constants.nlconvert(emit) def autoconfSnippet(self, module, fileassistant, toplevel, disable_libtool, disable_gettext, replace_auxdir, indentation): @@ -213,7 +213,7 @@ add AM_GNU_GETTEXT([external]) or similar to configure.ac.') emit = constants.nlconvert(emit) if type(emit) is bytes: emit = emit.decode(ENCS['default']) - return(emit) + return emit def autoconfSnippets(self, modules, moduletable, fileassistant, verifier, toplevel, disable_libtool, disable_gettext, replace_auxdir): @@ -371,7 +371,7 @@ add AM_GNU_GETTEXT([external]) or similar to configure.ac.') emit = constants.nlconvert(emit) if type(emit) is bytes: emit = emit.decode(ENCS['default']) - return(emit) + return emit def po_Makevars(self): '''GLEmiter.po_Makevars() -> string @@ -438,7 +438,7 @@ EXTRA_LOCALE_CATEGORIES = USE_MSGCTXT = no\n""" if type(emit) is bytes: emit = emit.decode(ENCS['default']) - return(constants.nlconvert(emit)) + return constants.nlconvert(emit) def po_POTFILES_in(self, files): '''GLEmiter.po_POTFILES_in(files) -> string @@ -459,7 +459,7 @@ USE_MSGCTXT = no\n""" emit += '\n' if type(emit) is bytes: emit = emit.decode(ENCS['default']) - return(constants.nlconvert(emit)) + return constants.nlconvert(emit) def initmacro_start(self, macro_prefix_arg): '''GLEmiter.initmacro_start(macro_prefix_arg) -> string @@ -511,7 +511,7 @@ USE_MSGCTXT = no\n""" emit = emit.replace('%V1%', macro_prefix_arg) if type(emit) is bytes: emit = emit.decode(ENCS['default']) - return(constants.nlconvert(emit)) + return constants.nlconvert(emit) def initmacro_end(self, macro_prefix_arg): '''GLEmiter.initmacro_end(macro_prefix_arg) -> string @@ -566,7 +566,7 @@ found])]) emit = emit.replace('%V1%', macro_prefix_arg) if type(emit) is bytes: emit = emit.decode(ENCS['default']) - return(constants.nlconvert(emit)) + return constants.nlconvert(emit) def initmacro_done(self, macro_prefix_arg, sourcebase_arg): '''GLEmiter.initmacro_done(macro_prefix_arg, sourcebase_arg) -> string @@ -618,7 +618,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [ emit = emit.replace('%V2%', sourcebase_arg) if type(emit) is bytes: emit = emit.decode(ENCS['default']) - return(constants.nlconvert(emit)) + return constants.nlconvert(emit) def lib_Makefile_am(self, destfile, modules, moduletable, makefiletable, actioncmd, for_test): @@ -910,7 +910,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [ if type(emit) is bytes: emit = emit.decode(ENCS['default']) result = tuple([emit, uses_subdirs]) - return(result) + return result def tests_Makefile_am(self, destfile, modules, makefiletable, witness_macro, for_test): @@ -1199,4 +1199,4 @@ AC_DEFUN([%V1%_LIBSOURCES], [ if type(emit) is bytes: emit = emit.decode(ENCS['default']) result = tuple([emit, uses_subdirs]) - return(result) + return result diff --git a/pygnulib/GLError.py b/pygnulib/GLError.py index 93604999d6..66838e56e6 100644 --- a/pygnulib/GLError.py +++ b/pygnulib/GLError.py @@ -124,4 +124,4 @@ class GLError(Exception): else: # if PYTHON3 self.message = ('[Errno %d] %s' % (self.errno, errors[self.errno - 1])) - return(self.message) + return self.message diff --git a/pygnulib/GLFileSystem.py b/pygnulib/GLFileSystem.py index 1edd6d7776..9d8d2b0cf7 100644 --- a/pygnulib/GLFileSystem.py +++ b/pygnulib/GLFileSystem.py @@ -78,7 +78,7 @@ class GLFileSystem(object): def __repr__(self): '''x.__repr__ <==> repr(x)''' result = '<pygnulib.GLFileSystem %s>' % hex(id(self)) - return(result) + return result def lookup(self, name): '''GLFileSystem.lookup(name) -> tuple @@ -121,7 +121,7 @@ class GLFileSystem(object): result = (path_gnulib, False) else: # if path_gnulib does not exist raise(GLError(1, name)) - return(result) + return result #=============================================================================== @@ -160,7 +160,7 @@ class GLFileAssistant(object): def __repr__(self): '''x.__repr__() <==> repr(x)''' result = '<pygnulib.GLFileAssistant %s>' % hex(id(self)) - return(result) + return result def tmpfilename(self, path): '''GLFileAssistant.tmpfilename() -> string @@ -189,7 +189,7 @@ class GLFileAssistant(object): os.makedirs(dirname) if type(result) is bytes: result = bytes.decode(ENCS['default']) - return(result) + return result def setOriginal(self, original): '''GLFileAssistant.setOriginal(original) @@ -231,7 +231,7 @@ class GLFileAssistant(object): def getFiles(self): '''Return list of the added files.''' - return(list(self.added)) + return list(self.added) def add(self, lookedup, tmpflag, tmpfile): '''GLFileAssistant.add(lookedup, tmpflag, tmpfile) @@ -415,4 +415,4 @@ class GLFileAssistant(object): else: # if self.config['dryrun'] os.remove(tmpfile) result = tuple([basename, backupname, result_flag]) - return(result) + return result diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index 61f700b8c5..10ad069271 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -286,7 +286,7 @@ class GLImport(object): def __repr__(self): '''x.__repr__ <==> repr(x)''' result = '<pygnulib.GLImport %s>' % hex(id(self)) - return(result) + return result def rewrite_old_files(self, files): '''GLImport.rewrite_old_files(files) -> list @@ -333,7 +333,7 @@ class GLImport(object): path = file result += [os.path.normpath(path)] result = sorted(set(result)) - return(list(result)) + return list(result) def rewrite_new_files(self, files): '''GLImport.rewrite_new_files(files) @@ -379,7 +379,7 @@ class GLImport(object): path = file result += [os.path.normpath(path)] result = sorted(set(result)) - return(list(result)) + return list(result) def actioncmd(self): '''Return command-line invocation comment.''' @@ -460,7 +460,7 @@ class GLImport(object): actioncmd += ' --no-vc-files' actioncmd += ' ' # Add a space actioncmd += ' '.join(modules) - return(actioncmd) + return actioncmd def gnulib_cache(self): '''GLImport.gnulib_cache() -> string @@ -547,7 +547,7 @@ gnulib-tool.m4 macro invocations:\n''' % actioncmd emit += 'gl_VC_FILES([%s])\n' % vc_files if type(emit) is bytes: emit = emit.decode(ENCS['default']) - return(constants.nlconvert(emit)) + return constants.nlconvert(emit) def gnulib_comp(self, files): '''GLImport.gnulib_comp(files) -> string @@ -692,7 +692,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix emit += '])\n' if type(emit) is bytes: emit = emit.decode(ENCS['default']) - return(emit) + return emit def _done_dir_(self, directory, dirs_added, dirs_removed): '''GLImport._done_dir_(directory, dirs_added, dirs_removed) @@ -973,7 +973,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix # Return the result. result = tuple([filetable, transformers]) - return(result) + return result def execute(self, filetable, transformers): '''Perform operations on the lists of files, which are given in a special diff --git a/pygnulib/GLInfo.py b/pygnulib/GLInfo.py index b3cc59dc07..d21e09f43d 100644 --- a/pygnulib/GLInfo.py +++ b/pygnulib/GLInfo.py @@ -67,12 +67,12 @@ class GLInfo(object): def __repr__(self): '''x.__repr__ <==> repr(x)''' result = '<pygnulib.GLInfo %s>' % hex(id(self)) - return(result) + return result def package(self): '''Return formatted string which contains name of the package.''' result = 'GNU gnulib' - return(result) + return result def authors(self): '''Return formatted string which contains authors. @@ -85,7 +85,7 @@ class GLInfo(object): result += 'and %s' % item else: result += '%s, ' % item - return(result) + return result def license(self): '''Return formatted string which contains license and its description.''' @@ -94,13 +94,13 @@ class GLInfo(object): result += 'This is free software: you are free' result += ' to change and redistribute it.\n' result += 'There is NO WARRANTY, to the extent permitted by law.' - return(result) + return result def copyright(self): '''Return formatted string which contains copyright. The special __copyright__ variable is used (type is str).''' result = 'Copyright (C) %s' % __copyright__ - return(result) + return result def date(self): '''Return formatted string which contains date and time in GMT format.''' @@ -120,7 +120,7 @@ class GLInfo(object): proc = sp.check_output(args) result = string(proc, "UTF-8") result = result.rstrip(os.linesep) - return(result) + return result def usage(self): '''Show help message.''' @@ -299,7 +299,7 @@ Options for --import, --add/remove-import, --update: -S, --more-symlinks Deprecated; equivalent to --symlink. Report bugs to <bug-gnulib@gnu.org>.''' - return(result) + return result def version(self): '''Return formatted string which contains git version.''' @@ -310,4 +310,4 @@ Report bugs to <bug-gnulib@gnu.org>.''' result = result.strip() if result == 'UNKNOWN': result = string() - return(result) + return result diff --git a/pygnulib/GLMakefileTable.py b/pygnulib/GLMakefileTable.py index 00050b2723..cff9ff34f9 100644 --- a/pygnulib/GLMakefileTable.py +++ b/pygnulib/GLMakefileTable.py @@ -82,7 +82,7 @@ class GLMakefileTable(object): raise(TypeError('indices must be integers, not %s' % type(y).__name__)) result = self.table[y] - return(dict(result)) + return dict(result) def editor(self, dir, var, val): '''GLMakefileTable.editor(dir, var, val) @@ -140,4 +140,4 @@ class GLMakefileTable(object): '''GLMakefileTable.count() -> int Count number of edits which were applied.''' - return(len(self.table)) + return len(self.table) diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py index 01e7188c74..d599755ee9 100644 --- a/pygnulib/GLModuleSystem.py +++ b/pygnulib/GLModuleSystem.py @@ -82,7 +82,7 @@ class GLModuleSystem(object): def __repr__(self): '''x.__repr__ <==> repr(x)''' result = '<pygnulib.GLModuleSystem %s>' % hex(id(self)) - return(result) + return result def exists(self, module): '''GLModuleSystem.exists(module) -> bool @@ -107,7 +107,7 @@ class GLModuleSystem(object): ]): # Close all(iterable) function if module not in badnames: result = True - return(result) + return result def find(self, module): '''GLModuleSystem.find(module) -> GLModule @@ -122,7 +122,7 @@ class GLModuleSystem(object): if self.exists(module): path, istemp = self.filesystem.lookup(joinpath('modules', module)) result = GLModule(self.config, path, istemp) - return(result) + return result else: # if not self.exists(module) if self.config['errors']: raise(GLError(3, module)) @@ -184,7 +184,7 @@ class GLModuleSystem(object): os.remove(path) listing = [line for line in result.split('\n') if line.strip()] listing = sorted(set(listing)) - return(listing) + return listing #=============================================================================== @@ -233,7 +233,7 @@ Include:|Link:|License:|Maintainer:)' if type(module) is GLModule: if self.module == module.module: result = True - return(result) + return result def __ne__(self, module): '''x.__ne__(y) <==> x!=y''' @@ -241,7 +241,7 @@ Include:|Link:|License:|Maintainer:)' if type(module) is GLModule: if self.module != module.module: result = True - return(result) + return result def __ge__(self, module): '''x.__ge__(y) <==> x>=y''' @@ -249,7 +249,7 @@ Include:|Link:|License:|Maintainer:)' if type(module) is GLModule: if self.module >= module.module: result = True - return(result) + return result def __gt__(self, module): '''x.__gt__(y) <==> x>y''' @@ -257,14 +257,14 @@ Include:|Link:|License:|Maintainer:)' if type(module) is GLModule: if self.module > module.module: result = True - return(result) + return result def __hash__(self): '''x.__hash__() <==> hash(x)''' module = hash(self.module) patched = hash(self.patched) result = module ^ patched - return(result) + return result def __le__(self, module): '''x.__le__(y) <==> x<=y''' @@ -272,7 +272,7 @@ Include:|Link:|License:|Maintainer:)' if type(module) is GLModule: if self.module <= module.module: result = True - return(result) + return result def __lt__(self, module): '''x.__lt__(y) <==> x<y''' @@ -280,18 +280,18 @@ Include:|Link:|License:|Maintainer:)' if type(module) is GLModule: if self.module < module.module: result = True - return(result) + return result def __str__(self): '''x.__str__() <==> str(x)''' result = self.getName() - return(result) + return result def __repr__(self): '''x.__repr__ <==> repr(x)''' result = '<pygnulib.GLModule %s %s>' % \ (repr(self.getName()), hex(id(self))) - return(result) + return result def getName(self): '''GLModule.getName() -> string @@ -299,39 +299,39 @@ Include:|Link:|License:|Maintainer:)' Return the name of the module.''' pattern = compiler(joinpath('modules', '(.*?)$')) result = pattern.findall(self.module)[0] - return(result) + return result def isPatched(self): '''GLModule.isPatched() -> bool Check whether module was created after applying patch.''' - return(self.patched) + return self.patched def isTests(self): '''GLModule.isTests() -> bool Check whether module is a -tests version of module.''' result = self.getName().endswith('-tests') - return(result) + return result def isNonTests(self): '''GLModule.isTests() -> bool Check whether module is not a -tests version of module.''' result = not(self.isTests()) - return(result) + return result def getTestsName(self): '''Return -tests version of the module name.''' result = self.getName() if not result.endswith('-tests'): result += '-tests' - return(result) + return result def getTestsModule(self): '''Return -tests version of the module as GLModule.''' result = self.modulesystem.find(self.getTestsName()) - return(result) + return result def getShellFunc(self): '''GLModule.getShellFunc() -> string @@ -354,7 +354,7 @@ Include:|Link:|License:|Maintainer:)' result = 'func_%s_gnulib_m4code_%s' % (macro_prefix, module) if type(result) is bytes: result = result.decode(ENCS['default']) - return(result) + return result def getShellVar(self): '''GLModule.getShellVar() -> string @@ -377,7 +377,7 @@ Include:|Link:|License:|Maintainer:)' result = '%s_gnulib_enabled_%s' % (macro_prefix, module) if type(result) is bytes: result = result.decode(ENCS['default']) - return(result) + return result def getConditionalName(self): '''GLModule.getConditionalName() -> string @@ -398,7 +398,7 @@ Include:|Link:|License:|Maintainer:)' result = '%s_GNULIB_ENABLED_%s' % (macro_prefix, name) if type(result) is bytes: result = result.decode(ENCS['default']) - return(result) + return result def getDescription(self): '''GLModule.getDescription() -> string @@ -419,7 +419,7 @@ Include:|Link:|License:|Maintainer:)' result = result[-1] result = result.strip() self.cache['description'] = result - return(self.cache['description']) + return self.cache['description'] def getComment(self): '''GLModule.getComment() -> string @@ -440,7 +440,7 @@ Include:|Link:|License:|Maintainer:)' result = result[-1] result = result.strip() self.cache['comment'] = result - return(self.cache['comment']) + return self.cache['comment'] def getStatus(self): '''GLModule.getStatus() -> string @@ -466,7 +466,7 @@ Include:|Link:|License:|Maintainer:)' parts += [line] result = [part.strip() for part in parts if part.strip()] self.cache['status'] = list(result) - return(list(self.cache['status'])) + return list(self.cache['status']) def getNotice(self): '''GLModule.getNotice() -> string @@ -492,7 +492,7 @@ Include:|Link:|License:|Maintainer:)' parts += [line] result = ''.join(parts) self.cache['notice'] = result - return(self.cache['notice']) + return self.cache['notice'] def getApplicability(self): '''GLModule.getApplicability() -> string @@ -527,7 +527,7 @@ Include:|Link:|License:|Maintainer:)' result = result.decode(ENCS['default']) result = result.strip() self.cache['applicability'] = result - return(self.cache['applicability']) + return self.cache['applicability'] def getFiles(self): '''GLModule.getFiles() -> list @@ -559,7 +559,7 @@ Include:|Link:|License:|Maintainer:)' result += [joinpath('m4', 'zzgnulib.m4')] result += [joinpath('m4', 'gnulib-common.m4')] self.cache['files'] = list(result) - return(list(self.cache['files'])) + return list(self.cache['files']) def getDependencies(self): '''GLModule.getDependencies() -> list @@ -603,7 +603,7 @@ Include:|Link:|License:|Maintainer:)' condition = condition.decode(ENCS['default']) result += [tuple([self.modulesystem.find(module), condition])] self.cache['dependencies'] = result - return(list(self.cache['dependencies'])) + return list(self.cache['dependencies']) def getAutoconfSnippet_Early(self): '''GLModule.getAutoconfSnippet_Early() -> string @@ -629,7 +629,7 @@ Include:|Link:|License:|Maintainer:)' parts += [line] result = ''.join(parts) self.cache['autoconf-early'] = result - return(self.cache['autoconf-early']) + return self.cache['autoconf-early'] def getAutoconfSnippet(self): '''GLModule.getAutoconfSnippet() -> string @@ -655,7 +655,7 @@ Include:|Link:|License:|Maintainer:)' parts += [line] result = ''.join(parts) self.cache['autoconf'] = result - return(self.cache['autoconf']) + return self.cache['autoconf'] def getAutomakeSnippet(self): '''getAutomakeSnippet() -> string @@ -669,7 +669,7 @@ Include:|Link:|License:|Maintainer:)' else: # if not conditional.strip() result += '\n' result += self.getAutomakeSnippet_Unconditional() - return(result) + return result def getAutomakeSnippet_Conditional(self): '''GLModule.getAutomakeSnippet_Conditional() -> string @@ -695,7 +695,7 @@ Include:|Link:|License:|Maintainer:)' parts += [line] result = ''.join(parts) self.cache['makefile-conditional'] = result - return(self.cache['makefile-conditional']) + return self.cache['makefile-conditional'] def getAutomakeSnippet_Unconditional(self): '''GLModule.getAutomakeSnippet_Unconditional() -> string @@ -767,7 +767,7 @@ Include:|Link:|License:|Maintainer:)' result += '\n\n' result = constants.nlconvert(result) self.cache['makefile-unconditional'] = result - return(self.cache['makefile-unconditional']) + return self.cache['makefile-unconditional'] def getInclude(self): '''GLModule.getInclude() -> string @@ -796,7 +796,7 @@ Include:|Link:|License:|Maintainer:)' pattern = compiler('^(["<].*?[>"])', re.S | re.M) result = pattern.sub('#include \\1', result) self.cache['include'] = result - return(self.cache['include']) + return self.cache['include'] def getLink(self): '''GLModule.getLink() -> string @@ -821,7 +821,7 @@ Include:|Link:|License:|Maintainer:)' parts = [part.strip() for part in parts if part.strip()] # result = ' '.join(parts) self.cache['link'] = parts - return(self.cache['link']) + return self.cache['link'] def getLicense(self): '''GLModule.getLicense(self) -> string @@ -837,7 +837,7 @@ Include:|Link:|License:|Maintainer:)' sys.stderr.write('module %s lacks a license\n' % str(self)) if not license: license = 'GPL' - return(license) + return license def getLicense_Raw(self): '''GLModule.getLicense_Raw() -> string @@ -858,7 +858,7 @@ Include:|Link:|License:|Maintainer:)' result = result[-1] result = result.strip() self.cache['license'] = result - return(self.cache['license']) + return self.cache['license'] def getMaintainer(self): '''GLModule.getMaintainer() -> string @@ -885,7 +885,7 @@ Include:|Link:|License:|Maintainer:)' result = ''.join(parts) result = result.strip() self.cache['maintainer'] = result - return(self.cache['maintainer']) + return self.cache['maintainer'] #=============================================================================== @@ -927,21 +927,21 @@ class GLModuleTable(object): def __repr__(self): '''x.__repr__() <==> repr(x)''' result = '<pygnulib.GLModuleTable %s>' % hex(id(self)) - return(result) + return result def __getitem__(self, y): '''x.__getitem__(y) <==> x[y]''' if y in ['base', 'final', 'main', 'tests', 'avoids']: if y == 'base': - return(self.getBaseModules()) + return self.getBaseModules() elif y == 'final': - return(self.getFinalModules()) + return self.getFinalModules() elif y == 'main': - return(self.getMainModules()) + return self.getMainModules() elif y == 'tests': - return(self.getTestsModules()) + return self.getTestsModules() else: # if y == 'avoids' - return(self.getAvoids()) + return self.getAvoids() else: # if y is not in list raise(KeyError('GLModuleTable does not contain key: %s' % repr(y))) @@ -988,7 +988,7 @@ class GLModuleTable(object): raise(TypeError('module must be a GLModule, not %s' % type(module).__name__)) result = str(module) in self.dependers - return(result) + return result def getCondition(self, parent, module): '''GLModuleTable.getCondition(module) -> string or True @@ -1005,7 +1005,7 @@ class GLModuleTable(object): result = None if key in self.conditionals: result = self.conditionals[key] - return(result) + return result def transitive_closure(self, modules): '''GLModuleTable.transitive_closure(modules) -> list @@ -1101,7 +1101,7 @@ class GLModuleTable(object): inmodules = sorted(set(inmodules)) modules = sorted(set(outmodules)) self.modules = modules - return(list(modules)) + return list(modules) def transitive_closure_separately(self, basemodules, finalmodules): '''GLModuleTable.transitive_closure_separately(*args, **kwargs) -> tuple @@ -1143,7 +1143,7 @@ class GLModuleTable(object): set(self.config['testflags'] + [TESTS['tests']])) self.config.setTestFlags(testflags) result = tuple([main_modules, tests_modules]) - return(result) + return result def add_dummy(self, modules): '''GLModuleTable.add_dummy(modules) -> list @@ -1171,7 +1171,7 @@ class GLModuleTable(object): if not have_lib_sources: dummy = self.modulesystem.find('dummy') modules = sorted(set(modules + [dummy])) - return(list(modules)) + return list(modules) def filelist(self, modules): '''GLModuleTable.filelist(modules) -> list @@ -1189,7 +1189,7 @@ class GLModuleTable(object): for file in listing: if file not in filelist: filelist += [file] - return(filelist) + return filelist def filelist_separately(self, main_modules, tests_modules): '''GLModuleTable.filelist_separately(**kwargs) -> list @@ -1208,13 +1208,13 @@ class GLModuleTable(object): for file in tests_filelist ] # Finish to sort filelist result = tuple([main_filelist, tests_filelist]) - return(result) + return result def getAvoids(self): '''GLModuleTable.getAvoids() -> list Return list of avoids.''' - return(list(self.avoids)) + return list(self.avoids) def setAvoids(self, modules): '''GLModuleTable.setAvoids(modules) @@ -1229,7 +1229,7 @@ class GLModuleTable(object): '''GLModuleTable.getBaseModules() -> list Return list of base modules.''' - return(list(self.base_modules)) + return list(self.base_modules) def setBaseModules(self, modules): '''GLModuleTable.setBaseModules(modules) @@ -1244,7 +1244,7 @@ class GLModuleTable(object): '''GLModuleTable.getFinalModules() -> list Return list of final modules.''' - return(list(self.final_modules)) + return list(self.final_modules) def setFinalModules(self, modules): '''GLModuleTable.setFinalModules(modules) @@ -1259,7 +1259,7 @@ class GLModuleTable(object): '''GLModuleTable.getMainModules() -> list Return list of main modules.''' - return(list(self.main_modules)) + return list(self.main_modules) def setMainModules(self, modules): '''GLModuleTable.setMainModules(modules) @@ -1274,7 +1274,7 @@ class GLModuleTable(object): '''GLModuleTable.getTestsModules() -> list Return list of tests modules.''' - return(list(self.tests_modules)) + return list(self.tests_modules) def setTestsModules(self, modules): '''GLModuleTable.setTestsModules(modules) diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py index c0657acc0d..6433a0d78c 100644 --- a/pygnulib/GLTestDir.py +++ b/pygnulib/GLTestDir.py @@ -152,7 +152,7 @@ class GLTestDir(object): path = file result += [os.path.normpath(path)] result = sorted(set(result)) - return(list(result)) + return list(result) def execute(self): '''GLTestDir.execute() diff --git a/pygnulib/constants.py b/pygnulib/constants.py index f36a9e0a7d..235f5d8891 100644 --- a/pygnulib/constants.py +++ b/pygnulib/constants.py @@ -269,7 +269,7 @@ def compiler(pattern, flags=0): pattern = re.compile(pattern, re.UNICODE | flags) else: # if PYTHON3 pattern = re.compile(pattern, flags) - return(pattern) + return pattern def cleaner(sequence): @@ -285,7 +285,7 @@ def cleaner(sequence): sequence = [False if value == 'false' else value for value in sequence] sequence = [True if value == 'true' else value for value in sequence] sequence = [value.strip() for value in sequence] - return(sequence) + return sequence def joinpath(head, *tail): @@ -304,7 +304,7 @@ def joinpath(head, *tail): result = os.path.normpath(os.path.join(head, *tail)) if type(result) is bytes: result = result.decode(ENCS['default']) - return(result) + return result def relativize(dir1, dir2): @@ -338,7 +338,7 @@ def relativize(dir1, dir2): dir0 = joinpath(dir0, first) dir1 = dir1[dir1.find(os.path.sep) + 1:] result = os.path.normpath(dir2) - return(result) + return result def link_relative(src, dest): @@ -405,7 +405,7 @@ def filter_filelist(separator, filelist, (added_prefix, added_suffix), filename) listing += [result] result = separator.join(listing) - return(result) + return result def substart(orig, repl, data): @@ -416,7 +416,7 @@ def substart(orig, repl, data): result = data if data.startswith(orig): result = repl + data[len(orig):] - return(result) + return result def subend(orig, repl, data): @@ -427,7 +427,7 @@ def subend(orig, repl, data): result = data if data.endswith(orig): result = data[:-len(orig)] + repl - return(result) + return result def nlconvert(text): @@ -436,7 +436,7 @@ def nlconvert(text): text = text.replace('\r\n', '\n') if system == 'windows': text = text.replace('\n', '\r\n') - return(text) + return text def nlremove(text): @@ -446,7 +446,7 @@ def nlremove(text): lines = [line for line in text.split('\n') if line != ''] text = '\n'.join(lines) text = nlconvert(text) - return(text) + return text def remove_backslash_newline(text): -- 2.34.1
>From 4bccc91c6bd9d73d3473d909023995e59119152e Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Fri, 29 Jul 2022 22:58:27 +0200 Subject: [PATCH 4/5] gnulib-tool.py: Follow gnulib-tool changes, part 16. Follow gnulib-tool change 2015-09-25 Pavel Raiskup <prais...@redhat.com> gnulib-common.m4: fix gl_PROG_AR_RANLIB/AM_PROG_AR clash * pygnulib/GLImport.py (GLImport.gnulib_comp): Put the gl_USE_SYSTEM_EXTENSIONS right before gl_PROG_AR_RANLIB into gnulib-comp.m4 (if the 'extensions' module is used). --- ChangeLog | 8 ++++++++ gnulib-tool.py.TODO | 28 ---------------------------- pygnulib/GLImport.py | 6 ++++-- 3 files changed, 12 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 01d8df2e13..1ddf2822ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2022-07-29 Bruno Haible <br...@clisp.org> + gnulib-tool.py: Follow gnulib-tool changes, part 16. + Follow gnulib-tool change + 2015-09-25 Pavel Raiskup <prais...@redhat.com> + gnulib-common.m4: fix gl_PROG_AR_RANLIB/AM_PROG_AR clash + * pygnulib/GLImport.py (GLImport.gnulib_comp): Put the + gl_USE_SYSTEM_EXTENSIONS right before gl_PROG_AR_RANLIB into + gnulib-comp.m4 (if the 'extensions' module is used). + gnulib-tool.py: Modernize coding style. * pygnulib/*.py: Remove parentheses around return value expressions. diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO index 7017d15a05..bcb811b5df 100644 --- a/gnulib-tool.py.TODO +++ b/gnulib-tool.py.TODO @@ -1134,34 +1134,6 @@ Date: Tue Oct 6 13:20:05 2015 +0200 (func_import, func_create_testdir): All dumps of gl_PROG_AR_RANLIB replaced with func_emit_pre_early_macros call. -commit f8fe25fab60e3c687a12446984bb475342956bb8 -Author: Pavel Raiskup <prais...@redhat.com> -Date: Fri Sep 25 11:25:03 2015 -0700 - - gnulib-common.m4: fix gl_PROG_AR_RANLIB/AM_PROG_AR clash - - The gl_PROG_AR_RANLIB (it is always called by gl_EARLY) sets AR - and ARFLAGS variables. Doing this unconditionally could break - later Automake's AM_PROG_AR invocation (at least it's - AC_CHECK_TOOLS call to detect correct 'ar' binary). - - Original purpose of the gl_PROG_AR_RANLIB was only to handle the - Amsterdam Compiler Kit, so make the previous code to have effects - only on ACK, and rather automatically call the Automake's - AM_PROG_AR as soon as possible to decide other cases. - - References: - http://lists.gnu.org/archive/html/bug-gnulib/2015-07/msg00001.html - - * m4/gnulib-common.m4 (gl_PROG_AR_RANLIB): AC_BEFORE AM_PROG_AR. - Set the AR/ARFLAGS to ACK defaults OR call AM_PROG_AR. If neither - is possible, keep setting AR/ARFLAGS to reasonable defaults. - * gnulib-tool (func_import): Put the gl_USE_SYSTEM_EXTENSIONS - right before gl_PROG_AR_RANLIB into gnulib-comp.m4 (if the - 'extensions' module is used. - * modules/extensions (configure.ac-early): Remove as this snippet - is added to gnulib-comp.m4 earlier anyway. - commit 9bdf6c8a0cdeb13c12e4b65dee9538c5468dbe1d Author: Bruno Haible <br...@clisp.org> Date: Sun Aug 19 14:06:50 2012 +0200 diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index 10ad069271..c51b5036df 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -598,8 +598,10 @@ AC_DEFUN([%s_EARLY], m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace m4_pattern_allow([^gl_ES$])dnl a valid locale name m4_pattern_allow([^gl_LIBOBJS$])dnl a variable - m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable - AC_REQUIRE([gl_PROG_AR_RANLIB])\n''' % (configure_ac, macro_prefix) + m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable\n''' % (configure_ac, macro_prefix) + if any(str(module) == 'extensions' for module in moduletable['final']): + emit += ' AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])\n' + emit += ' AC_REQUIRE([gl_PROG_AR_RANLIB])\n' uses_subdirs = False for module in moduletable['main']: # Test whether there are some source files in subdirectories. -- 2.34.1
>From 1b4313a18a42c6796b3064e82d45e41c51fcfa7a Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Fri, 29 Jul 2022 23:29:23 +0200 Subject: [PATCH 5/5] gnulib-tool.py: Follow gnulib-tool changes, part 17. Follow gnulib-tool change 2015-10-06 Pavel Raiskup <prais...@redhat.com> gnulib-tool: fix tests of 'extensions' module * pygnulib/GLEmiter.py (GLEmiter.preEarlyMacros): New function. * pygnulib/GLImport.py (GLImport.gnulib_comp): Invoke it. * pygnulib/GLTestDir.py (GLTestDir.execute): Likewise. --- ChangeLog | 8 ++++++++ gnulib-tool.py.TODO | 13 ------------- pygnulib/GLEmiter.py | 25 +++++++++++++++++++++++++ pygnulib/GLImport.py | 4 +--- pygnulib/GLTestDir.py | 6 +++--- 5 files changed, 37 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1ddf2822ad..16119afe29 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2022-07-29 Bruno Haible <br...@clisp.org> + gnulib-tool.py: Follow gnulib-tool changes, part 17. + Follow gnulib-tool change + 2015-10-06 Pavel Raiskup <prais...@redhat.com> + gnulib-tool: fix tests of 'extensions' module + * pygnulib/GLEmiter.py (GLEmiter.preEarlyMacros): New function. + * pygnulib/GLImport.py (GLImport.gnulib_comp): Invoke it. + * pygnulib/GLTestDir.py (GLTestDir.execute): Likewise. + gnulib-tool.py: Follow gnulib-tool changes, part 16. Follow gnulib-tool change 2015-09-25 Pavel Raiskup <prais...@redhat.com> diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO index bcb811b5df..8f535f6897 100644 --- a/gnulib-tool.py.TODO +++ b/gnulib-tool.py.TODO @@ -1121,19 +1121,6 @@ Date: Sat Nov 21 14:09:15 2015 +0100 -------------------------------------------------------------------------------- -commit 63ce1a2103dd4452f7bd5bc873a982e03ed52427 -Author: Pavel Raiskup <prais...@redhat.com> -Date: Tue Oct 6 13:20:05 2015 +0200 - - gnulib-tool: fix tests of 'extensions' module - - This complements f8fe25fab60e3c687a124 commit. - - * gnulib-tool (func_emit_pre_early_macros): New function, it wraps - emitting of initial gl_EARLY macros. - (func_import, func_create_testdir): All dumps of gl_PROG_AR_RANLIB - replaced with func_emit_pre_early_macros call. - commit 9bdf6c8a0cdeb13c12e4b65dee9538c5468dbe1d Author: Bruno Haible <br...@clisp.org> Date: Sun Aug 19 14:06:50 2012 +0200 diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py index 8f20990f16..0d57b6177b 100644 --- a/pygnulib/GLEmiter.py +++ b/pygnulib/GLEmiter.py @@ -373,6 +373,31 @@ add AM_GNU_GETTEXT([external]) or similar to configure.ac.') emit = emit.decode(ENCS['default']) return emit + def preEarlyMacros(self, require, indentation, modules): + '''GLEmiter.preEarlyMacros(require, indentation, modules) -> string + + Collect and emit the pre-early section. + + require parameter can be True (AC_REQUIRE) or False (direct call). + indentation parameter is a string. + modules argument represents list of modules; every module in this list must + be a GLModule instance.''' + emit = string() + emit += '\n' + indentation + '# Pre-early section.\n' + # We need to call gl_USE_SYSTEM_EXTENSIONS before gl_PROG_AR_RANLIB. + # Doing AC_REQUIRE in configure-ac.early is not early enough. + if any(str(module) == 'extensions' for module in modules): + if require: + emit += indentation + 'AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])\n' + else: + emit += indentation + 'gl_USE_SYSTEM_EXTENSIONS\n' + if require: + emit += indentation + 'AC_REQUIRE([gl_PROG_AR_RANLIB])\n' + else: + emit += indentation + 'gl_PROG_AR_RANLIB\n' + emit += '\n' + return emit + def po_Makevars(self): '''GLEmiter.po_Makevars() -> string diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index c51b5036df..06c122e780 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -599,9 +599,7 @@ AC_DEFUN([%s_EARLY], m4_pattern_allow([^gl_ES$])dnl a valid locale name m4_pattern_allow([^gl_LIBOBJS$])dnl a variable m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable\n''' % (configure_ac, macro_prefix) - if any(str(module) == 'extensions' for module in moduletable['final']): - emit += ' AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])\n' - emit += ' AC_REQUIRE([gl_PROG_AR_RANLIB])\n' + emit += self.emiter.preEarlyMacros(True, ' ', moduletable['final']) uses_subdirs = False for module in moduletable['main']: # Test whether there are some source files in subdirectories. diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py index 6433a0d78c..0a403c993f 100644 --- a/pygnulib/GLTestDir.py +++ b/pygnulib/GLTestDir.py @@ -441,7 +441,7 @@ class GLTestDir(object): emit += 'AC_PROG_CC\n' emit += 'AC_PROG_INSTALL\n' emit += 'AC_PROG_MAKE_SET\n' - emit += 'gl_PROG_AR_RANLIB\n\n' + emit += self.emiter.preEarlyMacros(False, '', modules) if uses_subdirs: emit += 'AM_PROG_CC_C_O\n\n' snippets = list() @@ -561,8 +561,8 @@ class GLTestDir(object): emit += 'm4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace\n' emit += 'm4_pattern_allow([^gl_ES$])dnl a valid locale name\n' emit += 'm4_pattern_allow([^gl_LIBOBJS$])dnl a variable\n' - emit += 'm4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable\n\n' - emit += 'gl_PROG_AR_RANLIB\n\n' + emit += 'm4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable\n' + emit += self.emiter.preEarlyMacros(False, '', modules) if any_uses_subdirs: emit += 'AM_PROG_CC_C_O\n' snippets = list() -- 2.34.1