On 4/16/24 9:06 AM, Collin Funk wrote:
> Patch 0001 changes GLModuleTable's unconditionals member from a
> dictionary to a set.
Forgot attachments, oops.
Collin
From be8c8ce23d090269f52124630b1b0b4d6034052e Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Tue, 16 Apr 2024 08:21:27 -0700
Subject: [PATCH 1/2] 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.
---
ChangeLog | 9 +++++++++
pygnulib/GLModuleSystem.py | 16 ++++++++--------
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8418f71093..bb91326403 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-04-16 Collin Funk <collin.fu...@gmail.com>
+
+ 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-15 Collin Funk <collin.fu...@gmail.com>
gnulib-tool.py: Optimize directory creation.
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index 82b3c2f6e5..11f8934026 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -727,13 +727,13 @@ def __init__(self, config: GLConfig, inc_all_direct_tests: bool, inc_all_indirec
returns the condition when B should be enabled as a dependency of A,
once the m4 code for A has been executed.
'''
- self.dependers = dict() # Dependencies
- self.conditionals = dict() # Conditional modules
- self.unconditionals = dict() # Unconditional modules
- self.base_modules = [] # Base modules
- self.main_modules = [] # Main modules
- self.tests_modules = [] # Tests modules
- self.final_modules = [] # Final modules
+ self.dependers = dict()
+ self.conditionals = dict()
+ self.unconditionals = set()
+ self.base_modules = []
+ self.main_modules = []
+ self.tests_modules = []
+ self.final_modules = []
if type(config) is not GLConfig:
raise TypeError('config must be a GLConfig, not %s'
% type(config).__name__)
@@ -781,7 +781,7 @@ def addUnconditional(self, module: GLModule) -> None:
if type(module) is not GLModule:
raise TypeError('module must be a GLModule, not %s'
% type(module).__name__)
- self.unconditionals[str(module)] = True
+ self.unconditionals.add(str(module))
if str(module) in self.dependers:
self.dependers.pop(str(module))
--
2.44.0
From 352d793b06942978eb0ce8c713348c55768d3a3b Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Tue, 16 Apr 2024 08:36:55 -0700
Subject: [PATCH 2/2] gnulib-tool.py: Prefer 'not in' over 'not ... in'.
* pygnulib/GLEmiter.py (GLEmiter.autoconfSnippet): Change conditional.
* pygnulib/GLModuleSystem.py (GLModuleTable.addConditional): Likewise.
---
ChangeLog | 6 ++++++
pygnulib/GLEmiter.py | 2 +-
pygnulib/GLModuleSystem.py | 2 +-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index bb91326403..186c8a6b39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-04-16 Collin Funk <collin.fu...@gmail.com>
+
+ 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 Collin Funk <collin.fu...@gmail.com>
gnulib-tool.py: Make data structures more clear.
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index 558f130bbb..ff4e3027d6 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -218,7 +218,7 @@ def autoconfSnippet(self, module: GLModule, toplevel: bool, disable_libtool: boo
if str(module) in ['gnumakefile', 'maintainer-makefile']:
# These modules are meant to be used only in the top-level directory.
flag = toplevel
- else: # if not str(module) in ['gnumakefile', 'maintainer-makefile']
+ else: # if str(module) not in ['gnumakefile', 'maintainer-makefile']
flag = True
if flag:
snippet = module.getAutoconfSnippet()
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index 11f8934026..3148f921e1 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -767,7 +767,7 @@ def addConditional(self, parent: GLModule, module: GLModule, condition: str | bo
if not (type(condition) is str or condition == True):
raise TypeError('condition must be a string or True, not %s'
% type(condition).__name__)
- if not str(module) in self.unconditionals:
+ if str(module) not in self.unconditionals:
# No unconditional dependency to the given module is known at this point.
if str(module) not in self.dependers:
self.dependers[str(module)] = []
--
2.44.0