Hi Bruno,
On 3/19/24 11:24 PM, Bruno Haible wrote:
> It would be better to define a method getFiles_Raw -> str,
> similarly to how getLicense_Raw is defined, and have
> getFiles -> list
> use that.
Yes, that is a better idea. Here is a patch that does this.
I beleive that this should match gnulib-tool.sh in all cases. If you
add two newlines after modules/warnings:
$ env GNULIB_TOOL_IMPL=sh gnulib-tool --extract-filelist warnings
m4/warnings.m4
m4/00gnulib.m4
m4/zzgnulib.m4
m4/gnulib-common.m4
This patch makes the python version behave the same way as well.
I'm not sure if any files in modules/* have extra newlines like this,
but the more close the gnulib-tool's behave the better.
Collin
From 2b3e2e48ab53b1b4d0f209f835dddbea0312c3ea Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Wed, 20 Mar 2024 17:51:55 -0700
Subject: [PATCH] gnulib-tool.py: Make --extract-filelist match gnulib-tool.sh.
* pygnulib/GLModuleSystem.py (GLModule.getFiles_Raw): New function which
returns the 'Files:' section from a module unchanged.
(GLModule.getFiles): Use it.
* pygnulib/main.py (main): Use it and match the output of gnulib-tool.sh
for --extract-filelist.
---
ChangeLog | 9 +++++++++
pygnulib/GLModuleSystem.py | 6 +++++-
pygnulib/main.py | 7 +++++--
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 16c8ab130b..4f92f28c31 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-03-20 Collin Funk <collin.fu...@gmail.com>
+
+ gnulib-tool.py: Make --extract-filelist match gnulib-tool.sh.
+ * pygnulib/GLModuleSystem.py (GLModule.getFiles_Raw): New function which
+ returns the 'Files:' section from a module unchanged.
+ (GLModule.getFiles): Use it.
+ * pygnulib/main.py (main): Use it and match the output of gnulib-tool.sh
+ for --extract-filelist.
+
2024-03-20 Collin Funk <collin.fu...@gmail.com>
gnulib-tool.py: Fix unconditional Automake snippets for non-tests.
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index 9dfc3dd5bb..4e970efeb9 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -518,13 +518,17 @@ class GLModule(object):
self.cache['applicability'] = result
return self.cache['applicability']
+ def getFiles_Raw(self) -> str:
+ '''Return the unmodified list of files as a string.'''
+ return self.sections.get('Files', '')
+
def getFiles(self):
'''GLModule.getFiles() -> list
Return list of files.
GLConfig: ac_version.'''
if 'files' not in self.cache:
- snippet = self.sections.get('Files', '')
+ snippet = self.getFiles_Raw()
result = [ line.strip()
for line in snippet.split('\n')
if line.strip() ]
diff --git a/pygnulib/main.py b/pygnulib/main.py
index a3e7f86387..b41fe4720e 100644
--- a/pygnulib/main.py
+++ b/pygnulib/main.py
@@ -1148,8 +1148,11 @@ def main():
for name in modules:
module = modulesystem.find(name)
if module:
- files = module.getFiles()
- print(lines_to_multiline(files), end='')
+ files = module.getFiles_Raw()
+ files += 'm4/00gnulib.m4\n'
+ files += 'm4/zzgnulib.m4\n'
+ files += 'm4/gnulib-common.m4'
+ print(files)
elif mode == 'extract-dependencies':
if avoids:
--
2.44.0