1
0
mirror of https://git.savannah.gnu.org/git/gnulib.git synced 2026-10-24 00:48:56 +03:00
Commit Graph

126 Commits

Author SHA1 Message Date
Collin Funk
a8482ceecf maint: run 'make update-copyright' 2026-01-01 10:37:05 -08:00
Pádraig Brady
7b08932179 maint: run 'make update-copyright' 2025-01-01 09:25:10 +00:00
Bruno Haible
ab4cc5f2b5 gnulib-tool.py: Fix invalid use of cache.
* pygnulib/GLModuleSystem.py (GLModule._getDependents): Make the modules
argument mandatory. Don't store the result in self.cache.
2024-12-05 09:43:14 +01:00
Bruno Haible
5efa7c4298 gnulib-tool.py: Refactor.
* pygnulib/GLModuleSystem.py (GLModuleSystem.getAllModules): Moved here
from GLModule._getAllModules. No need to eliminate empty module names.
(GLModule._getDependents, GLModule.getDependentsRecursively): Update.
2024-12-05 09:41:23 +01:00
Bruno Haible
d72b2930e6 gnulib-tool.py: Remove dead code.
* pygnulib/GLModuleSystem.py (GLModule.getDependents): Remove top_level
parameter. Use the cached value if present.
* pygnulib/main.py: Update accordingly.
2024-12-05 09:40:53 +01:00
Collin Funk
ac562bbfa2 gnulib-tool.py: Make --extract-dependents quick again.
Suggested by Bruno Haible in:
<https://lists.gnu.org/archive/html/bug-gnulib/2024-12/msg00012.html>.

* pygnulib/GLModuleSystem.py (GLModule.getDependents): Add an optional
argument to use the implementation before yesterdays change.
* pygnulib/main.py (mode == 'extract-dependents'): Add the optional
argument to call of GLModule.getDependents.
2024-12-04 18:49:45 -08:00
Collin Funk
1e0fff5e55 gnulib-tool.py: Optimize --extract-recursive-dependencies.
* pygnulib/GLModuleSystem.py (GLModuleSystem.list): Add optional
argument to include test modules.
(GLModule._getDependents) New function.
(GLModule.getDependents): Use it.
(GLModule.getDependentsRecursively): Likewise.
(GLModule._getAllModules): New function.
2024-12-03 19:17:52 -08:00
Bruno Haible
7b6f844bf2 gnulib-tool.py: Allow verifying license compatibility with GPLv2+.
* pygnulib/GLInfo.py (GLInfo.usage): Document the --gpl option.
* pygnulib/main.py (main): Accept a --gpl option. Pass it to the
GLConfig.
* pygnulib/GLConfig.py (GLConfig): Add 'gpl' field and constructor
argument. Add getGPL, setGPL, resetGPL methods.
* m4/gnulib-tool.m4 (gl_GPL): New macro.
* doc/gnulib-tool.texi (Modified imports): Document the gl_GPL macro.
* pygnulib/GLImport.py (GLImport.__init__): Look for gl_GPL invocations
in gnulib-cache.m4.
(GLImport.actioncmd): Output --gpl option when option --gpl was given.
(GLImport.gnulib_cache): Emit a gl_GPL invocation when option --gpl was
given.
(GLImport.prepare): Do license compatibility checking when option --gpl
was given.
* pygnulib/GLModuleSystem.py: Update a comment.
2024-08-29 18:32:35 +02:00
Bruno Haible
5c73543760 gnulib-tool.py: Correct the result of --extract-dependents.
* pygnulib/GLModuleSystem.py (GLModule.getDependents): Add the current
module's test module, if that exists.
2024-08-16 18:24:54 +02:00
Bruno Haible
b254680d6d gnulib-tool.py: Don't treat 'valgrind-tests' as a tests module.
Reported by Marc Nieper-Wißkirchen <marc.nieper+gnu@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-08/msg00093.html>.

* pygnulib/GLModuleSystem.py (_isTestsModuleName): New function.
(GLModuleSystem.list, GLModule.isNonTests, GLModule.getApplicability,
GLModule.getDependencies, GLModule.getAutomakeSnippet_Unconditional,
GLModule.getLicense): Use it.
2024-08-16 17:57:02 +02:00
Bruno Haible
da8e6e1317 gnulib-tool.py: Small refactoring.
Suggested by Collin Funk.

* pygnulib/GLModuleSystem.py (GLModule.getDependenciesRecursively):
Return a set of GLModule.
* pygnulib/main.py (main): Convert the result to a string here.
2024-08-03 17:06:02 +02:00
Collin Funk
2f400ffc40 gnulib-tool.py: Correct type hint and doc string.
* pygnulib/GLModuleSystem.py (GLModule.getDependentsRecursively): Adjust
type hint and doc string to correctly state a set of GLModule's is
returned.
2024-08-02 20:52:28 -07:00
Bruno Haible
e0de8e473c gnulib-tool.py: New options --extract-[recursive-]dependents.
* pygnulib/GLInfo.py (GLInfo.usage): Document --extract-dependents and
--extract-recursive-dependents options.
* pygnulib/GLModuleSystem.py (GLModule.getDependenciesRecursively): Move
method.
(getDependents, getDependentsRecursively): New methods.
* pygnulib/main.py (main): Add support for --extract-dependents and
--extract-recursive-dependents.
2024-07-29 01:26:51 +02:00
Bruno Haible
8f2cda7dff gnulib-tool.py: Avoid adding specific modules to a testdir.
Reported by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-07/msg00292.html>.

* pygnulib/GLInfo.py (GLInfo.usage): Document
--extract-usability-in-testdir option.
* pygnulib/GLModuleSystem.py (GLModule.section_label_pattern): Recognize
Usable-in-testdir section.
(GLModule.getUsabilityInTestdir): New function.
* pygnulib/GLTestDir.py (GLTestDir.execute): Invoke it to filter out
modules to avoid. Warn if such a module was specified.
* pygnulib/main.py (main): Add support for
--extract-usability-in-testdir. Provide an error message for error 24.
* pygnulib/GLError.py: Likewise.
* modules/config-h (Usable-in-testdir): New section.
* modules/lib-ignore (Usable-in-testdir): New section.
* modules/mountlist (Usable-in-testdir): New section.
* modules/non-recursive-gnulib-prefix-hack (Usable-in-testdir): New
section.
* modules/timevar (Usable-in-testdir): New section.
(Files): Remove lib/timevar.def.
2024-07-28 23:52:04 +02:00
Bruno Haible
94046e1cdc gnulib-tool.py: Fix an exception message.
* pygnulib/GLModuleSystem.py (GLModuleSystem.find): Raise error 23,
not 3.
* pygnulib/GLError.py: Provide an error message for error 23.
* pygnulib/main.py: Likewise.
2024-07-28 23:38:45 +02:00
Collin Funk
7a99ec181a gnulib-tool.py: Revert previous change.
* pygnulib/constants.py (joinpath): Restore function and remove unused
local variable.
(relativize, symlink_relative, as_link_value_at_dest, hardlink): Use it.
* pygnulib/GLConfig.py (resetAutoconfFile): Likewise.
* pygnulib/GLEmiter.py (lib_Makefile_am, tests_Makefile_am): Likewise.
* pygnulib/GLFileSystem.py (lookup, shouldLink, tmpfilename, add)
(update, add_or_update, super_update): Likewise.
* pygnulib/GLImport.py (__init__, relative_to_currdir)
(_done_dir_, _update_ignorelist_, prepare, execute): Likewise.
* pygnulib/GLInfo.py (version): Likewise.
* pygnulib/GLMakefileTable.py (parent): Likewise.
* pygnulib/GLModuleSystem.py (exists, find, getFiles)
(getAutomakeSnippet_Unconditional): Likewise.
* pygnulib/GLTestDir.py (_patch_test_driver, execute): Likewise.
* pygnulib/main.py (main): Likewise.
2024-06-15 05:42:18 -07:00
Collin Funk
790206bfe7 gnulib-tool.py: Simplify joining paths.
* pygnulib/constants.py (joinpath): Remove function. It is equivalent to
os.path.normpath(os.path.join(...)) where the os.path.normpath is
typically not needed.
(relativize, symlink_relative, as_link_value_at_dest, hardlink): Use
os.path.join instead of joinpath.
* pygnulib/GLConfig.py (resetAutoconfFile): Likewise.
* pygnulib/GLEmiter.py (lib_Makefile_am, tests_Makefile_am): Likewise.
* pygnulib/GLFileSystem.py (lookup, shouldLink, tmpfilename, add)
(update, add_or_update, super_update): Likewise.
* pygnulib/GLInfo.py (version): Likewise.
* pygnulib/GLMakefileTable.py (parent): Likewise.
* pygnulib/GLTestDir.py (_patch_test_driver, execute): Likewise.
* pygnulib/main.py (main): Likewise.
* pygnulib/GLModuleSystem.py (exists, find, getFiles): Likewise.
* pygnulib/GLImport.py (__init__, relative_to_currdir)
(_done_dir_, _update_ignorelist_, prepare, execute): Likewise.
(getAutomakeSnippet_Unconditional): Likewise. Add a comment about not
using os.path.normpath() to protect a Make variable.
2024-06-14 21:55:48 -07:00
Collin Funk
c1cdc5ef8e gnulib-tool.py: Use a set to optimize.
* pygnulib/GLModuleSystem.py
(GLModule.getAutomakeSnippet_Unconditional): Call set() on the result of
_extract_lib_SOURCES() to ensure computing the difference between
another set is O(n).
2024-06-03 04:57:14 -07:00
Collin Funk
26d7603143 gnulib-tool.py: Refactor duplicated regular expressions.
* pygnulib/GLModuleSystem.py (_LIB_SOURCES_PATTERN): New variable.
(_extract_lib_SOURCES): New function.
(GLModule.getAutomakeSnippet_Unconditional): Use the new function.
(GLModuleTable.add_dummy): Likewise. Add a second break statement to
stop unnecessary looping.
2024-06-02 22:32:39 -07:00
Collin Funk
1b74469a3a gnulib-tool.py: Don't emit non-ASCII shell output.
Reported by Bruno Haible in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-05/msg00441.html>.

* pygnulib/GLModuleSystem.py (GLModule.shell_id_chars): Use the re.ASCII
flag for the regular expression.
2024-05-29 02:35:02 -07:00
Collin Funk
001302d065 gnulib-tool.py: Add missing docstring.
* pygnulib/GLModuleSystem.py (GLModule.getShellId): Add docstring
forgotten in the previous commit.
2024-05-28 23:26:19 -07:00
Collin Funk
eacd615374 gnulib-tool.py: Simplify creation of module shell ids.
* pygnulib/GLModuleSystem.py (GLModule.shell_id_chars): Remove class
variable.
(GLModule.shell_id_pattern): New class variable.
(GLModule.getShellId): New function.
(GLModule.getShellFunc, GLModule.getShellVar)
(GLModule.getConditionalName): Use it.
2024-05-28 21:55:12 -07:00
Collin Funk
6c3614c1f3 gnulib-tool.py: Filter out dependencies that cannot be found.
Reported by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-05/msg00136.html>.

* pygnulib/GLModuleSystem.py (GLModule.getDependenciesWithConditions):
Reorder conditionals to avoid duplicate checks. Filter out None from the
gathered dependencies when gathering module dependencies. Let
GLModuleSystem.find() warn instead of crashing.
2024-05-11 21:45:12 -07:00
Collin Funk
e91650b1de gnulib-tool.py: Handle module dependencies that cannot be found.
* pygnulib/GLModuleSystem.py
(GLModule.getDependenciesWithoutConditions): Filter out None from the
module dependencies. An appropriate warning will already be printed by
GLModuleSystem.find().
2024-05-07 17:10:23 -07:00
Collin Funk
ecdab13fca gnulib-tool.py: Fix mistake in previous commit.
* pygnulib/GLModuleSystem.py (GLModuleSystem.exists)
(GLModuleSystem.find): Rename 'module' argument to 'module_name' so it
is clear they are not a GLModule object. Treat them as such.
2024-05-01 02:21:43 -07:00
Collin Funk
ffde99059e gnulib-tool.py: Use the GLModule's name variable directly.
* pygnulib/GLModuleSystem.py (GLModule.getName): Remove function.
(GLModule.__str__, GLModule.__repr__, GLModule.isNonTests)
(GLModule.repeatModuleInTests, GLModule.getDependenciesRecursively)
(GLModule.getShellFunc, GLModule.getShellVar)
(GLModule.getConditionalName, GLModule.getApplicability)
(GLModule.getDependencies, GLModule.getAutomakeSnippet_Unconditional)
(GLModule.getLicense, GLModuleSystem.find)
(GLModuleTable.transitive_closure): Use the GLModule's name instance
variable instead of using str() or removed getName() function.
* pygnulib/GLEmiter.py (GLEmiter.autoconfSnippet)
(GLEmiter.preEarlyMacros, GLEmiter.lib_Makefile_am)
(GLEmiter.tests_Makefile_am): Likewise.
* pygnulib/GLImport.py (GLImport.gnulib_comp, GLImport.prepare):
Likewise.
* pygnulib/GLTestDir.py (GLTestDir.execute, GLMegaTestDir.execute):
Likewise.
2024-05-01 01:12:18 -07:00
Collin Funk
134f6b8a18 gnulib-tool.py: Remove remaining unused instance variables.
* pygnulib/GLModuleSystem.py (GLModule.__init__)
(GLModuleTable.__init__): Remove the unused GLFileSystem variable. These
classes perform lookups with a GLModuleSystem.
* pygnulib/GLTestDir.py (GLTestDir.__init__): Remove the unused
GLFileAssistant variable. The transformations it performs are not needed
in testdirs.
2024-04-30 01:09:55 -07:00
Collin Funk
20061b4960 gnulib-tool.py: Add type hints to classes.
* pygnulib/*.py: Add type hints for all instance and class variables.
* pygnulib/GLMakefileTable.py (GLMakefileTable.__getitem__): Fix return
type hint since the dictionary has str values.
2024-04-29 22:20:31 -07:00
Collin Funk
379b3a0271 gnulib-tool.py: Make better use of imports.
* pygnulib/*.py: Import functions from constants.py directly instead of
assigning them to module-specific variable. Keep the module prefix for
standard library functions.
2024-04-23 11:28:19 -07:00
Collin Funk
5b1dcad0b1 gnulib-tool.py: Don't fail when given a bad module name.
* pygnulib/GLTestDir.py (GLTestDir.execute): Don't include None in the
list of GLModule objects.
* pygnulib/GLModuleSystem.py (GLModuleSystem.find): Document the meaning
of the None return.
2024-04-21 13:27:05 +02:00
Collin Funk
544b6f6e1b gnulib-tool.py: Remove duplicate per-module definitions.
* pygnulib/constants.py: Remove duplicate __authors__, __license__, and
__copyright__ definitions.
* pygnulib/GLInfo.py: Use the value of __authors__ and __copyright__
from __init__.py for output.
* pygnulib/*.py: Remove unused references to the constant.py
definitions.
2024-04-20 23:59:29 +02:00
Collin Funk
b9fa78e2a0 gnulib-tool.py: Make use of GLModule's __hash__ method.
* pygnulib/GLModuleSystem.py (GLModuleTable.addUnconditional)
(GLModuleTable.isConditional): Use the GLModule object instead of the
module name directly.
(GLModuleTable.addConditional, GLModuleTable.getCondition): Likewise.
Use a tuple of two GLModule objects as a key for the conditionals
dictionary.
2024-04-19 23:15:57 +02:00
Collin Funk
efc1cb630b gnulib-tool.py: Simplify data structures for dependencies.
* pygnulib/GLModuleSystem.py (GLModuleTable.__init__): Use a defaultdict
for dependers to remove the base initialization case.
(GLModuleTable.addConditional): Use a set to disallow duplicates instead
of performing list lookups.
2024-04-19 23:14:32 +02:00
Bruno Haible
344f86830c gnulib-tool.py: Simplify running some commands in a given directory.
* pygnulib/GLImport.py (GLImport.execute): Use sp.call with a cwd
argument, instead of calling chdir twice.
* pygnulib/GLModuleSystem.py (GLModuleSystem.list): Likewise.
* pygnulib/main.py (mode=='find'): Likewise.
2024-04-19 18:21:26 +02:00
Collin Funk
3353082482 gnulib-tool.py: Remove some unused instance variables.
* pygnulib/GLModuleSystem.py (GLModuleSystem.__init__)
(GLModule.__init__): Remove unused 'args' instance variable.
2024-04-19 13:49:19 +02:00
Collin Funk
5ee994319b gnulib-tool.py: Fix a pylint 'attribute-defined-outside-init' warning.
* pygnulib/GLModuleSystem.py (GLModuleTable.transitive_closure): Don't
define a 'modules' attribute since it is never used.
2024-04-17 20:00:59 +02:00
Collin Funk
daa21fd28d gnulib-tool.py: Make GLModule's __eq__ and __hash__ method agree.
* pygnulib/GLModuleSystem.py (GLModuleTable.__hash__): Only use the
module name in hash computations.
2024-04-17 00:53:18 +02:00
Collin Funk
886f847680 gnulib-tool.py: Prefer 'not in' over 'not ... in'.
* pygnulib/GLEmiter.py (GLEmiter.autoconfSnippet): Change conditional.
* pygnulib/GLModuleSystem.py (GLModuleTable.addConditional): Likewise.
2024-04-16 20:17:58 +02:00
Collin Funk
5097cf4b4e gnulib-tool.py: Make data structures more clear.
* pygnulib/GLModuleSystem.py (GLModuleTable.__init__): Use a set to
represent the unconditional modules instead of a dictionary. Remove
redundant comments.
(GLModuleTable.addUnconditional): Add the module to a set instead of
using it as a key to the dictionary.
2024-04-16 20:17:13 +02:00
Collin Funk
cb7e1bb25d gnulib-tool.py: Write newlines consistently.
* pygnulib/constants.py (NL): Remove variable.
* pygnulib/GLImport.py (GLImport.gnulib_comp): Use '\n' instead of
constants.NL.
* pygnulib/GLModuleSystem.py
(GLModule.getAutomakeSnippet_Unconditional): Likewise.
* pygnulib/main.py (main_with_exception_handling): Likewise.
2024-04-15 00:02:51 +02:00
Collin Funk
aaabd2ebad gnulib-tool.py: Don't perform newline conversions.
* pygnulib/constants.py (nlconvert): Remove function. Remove unused
platform import.
* pygnulib/GLImport.py (GLImport.gnulib_cache): Remove calls to
nlconvert().
* pygnulib/GLModuleSystem.py
(GLModule.getAutomakeSnippet_Unconditional): Likewise.
* pygnulib/GLTestDir.py (GLTestDir.execute, GLMegaTestDir.execute):
Likewise.
2024-04-15 00:00:57 +02:00
Collin Funk
3897b2b1ad gnulib-tool.py: Remove some unused variable assignments.
* pygnulib/GLEmiter.py (GLEmiter.autoconfSnippets): Remove unused
variable.
* pygnulib/GLInfo.py (GLInfo.date, GLInfo.version): Remove assignments
to variables unconditionally set in try, except blocks.
* pygnulib/GLModuleSystem.py (GLModule.getConditionalName)
(GLModule.getShellFunc, GLModule.getShellVar): Likewise.
2024-04-14 19:50:14 +02:00
Bruno Haible
3258dcae2d gnulib-tool.py: Stop using codecs.open.
* pygnulib/*.py: To open a file, consistently use
open(..., mode='[rwa]', newline='\n', encoding='utf-8').
2024-04-13 12:55:44 +02:00
Bruno Haible
40970e22c3 gnulib-tool.py: Fix handling of --with-obsolete.
* pygnulib/constants.py (TESTS): Remove 'obsolete' category.
* pygnulib/GLConfig.py (GLConfig.__init__): Add optional incobsolete
parameter.
(GLConfig.default): Handle 'incobsolete'.
(GLConfig.checkIncObsolete, GLConfig.setIncObsolete,
GLConfig.resetIncObsolete): New methods.
* pygnulib/GLModuleSystem.py (GLModuleSystem.transitive_closure): For
incobsolete, use new GLConfig methods.
* pygnulib/GLImport.py (GLImport.__init__, GLImport.actioncmd,
GLImport.gnulib_cache): Likewise.
* pygnulib/main.py (main): Pass the incobsolete value to the GLConfig
constructor.
2024-04-12 18:21:37 +02:00
Bruno Haible
f948d1813a gnulib-tool.py: Optimize module set lookups.
* gnulib-tool.py (profiler_args): New variable.
* pygnulib/GLModuleSystem.py (GLModuleTable.transitive_closure): Turn
handledmodules into a set.
(GLModuleTable.transitive_closure_separately): For the 'in' test, use
a set variable main_modules_set.
2024-04-11 21:49:45 +02:00
Bruno Haible
ab3425fae3 gnulib-tool.py: Skip nonexistent modules instead of failing.
* pygnulib/GLModuleSystem.py (GLModuleSystem.find): Use the same warning
wording as gnulib-tool.sh.
* pygnulib/GLImport.py (GLImport.gnulib_cache): Print the specified
modules, not the base modules.
(GLImport.prepare): Don't put None elements into base_modules.
2024-04-11 01:55:05 +02:00
Collin Funk
760841f16b gnulib-tool.py: Change the avoid list to a set for lookups.
* pygnulib/GLModuleSystem.py (GLModuleSystem.__init__): Store the
avoided modules in a set instead of a list. This is used only for
membership checks when computing the transitive closure of the given
modules, therefore prefer the O(1) average case over O(n).
2024-04-09 18:30:52 +02:00
Collin Funk
8bf54d5b5d gnulib-tool.py: Remove unused setter and getter functions.
* pygnulib/GLModuleSystem.py (GLModuleTable.getAvoids)
(GLModuleTable.setAvoids): Remove these unused functions.
2024-04-09 18:29:09 +02:00
Collin Funk
7166faa45f gnulib-tool.py: Simplify use of GLModuleTable accessors.
* pygnulib/GLModuleSystem.py (GLModuleTable.__getitem__): Remove
function.
* pygnulib/GLImport.py (GLImport.gnulib_cache, GLImport.gnulib_comp)
(GLImport.execute): Use function calls on the GLModuleTable to access
module lists instead of using keys to emulate a dictionary.
2024-04-09 14:40:05 +02:00
Collin Funk
965b5c72cb 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-09 03:21:20 +02:00