diff options
author | Bruno Haible <bruno@clisp.org> | 2022-08-07 22:53:32 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2022-08-07 23:04:30 +0200 |
commit | 81b8c4d5565dbbea10eb3561063d2e8da52148d7 (patch) | |
tree | 2e1054c688f7d41bf10a9ea2527f9438b1979e74 /gnulib-tool.py | |
parent | 586000e597d4ef7cba8de869a15ad5c922a2010c (diff) | |
download | gnulib-81b8c4d5565dbbea10eb3561063d2e8da52148d7.tar.gz |
gnulib-tool.py: Fix section extraction from module descriptions.
The code with self.content.split(section)[-1]
was broken because it recognizes an indented section label.
Similar code with ('\n' + self.content).split('\n' + section)[-1]
would still be broken because it recognizes an indented section label
in the first line of the file.
The code with section_label_regex
was broken because sometimes it returns the second-to-last section with
the given label, not the last one.
Also, whitespace after the colon was not ignored.
* pygnulib/GLModuleSystem.py (GLModule.__init__): Dissect the module
description's contents immediately, once only, in a reliable way.
(GLModule.getDescription, GLModule.getComment): Simplify.
(GLModule.getStatus): Simplify. Return a string.
(GLModule.getStatuses): New function. Return a list.
(GLModule.getNotice, GLModule.getApplicability, GLModule.getFiles,
GLModule.getDependencies, GLModules.getAutoconfSnippet_Early,
GLModules.getAutoconfSnippet, GLModule.getAutomakeSnippet_Conditional,
GLModule.getInclude, GLModule.getLink, GLModule.getLicense_Raw):
Simplify.
(GLModule.getLicense): Remove whitespace after calling getLicense_Raw.
(GLModule.getMaintainer): Simplify.
(GLModuleTable.transitive_closure): Call getStatuses() instead of
getStatus().
* pygnulib/GLEmiter.py: Likewise.
* gnulib-tool.py (main): For --extract-description, --extract-comment,
--extract-status, --extract-notice, --extract-autoconf-snippet,
--extract-automake-snippet, --extract-include-directive,
--extract-link-directive, --extract-maintainer, don't add an extra
newline after the snippet.
Diffstat (limited to 'gnulib-tool.py')
-rwxr-xr-x | gnulib-tool.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/gnulib-tool.py b/gnulib-tool.py index 032deee6e0..0e888e6fd8 100755 --- a/gnulib-tool.py +++ b/gnulib-tool.py @@ -974,29 +974,28 @@ def main(): modules = [ modulesystem.find(module) for module in modules ] for module in modules: - print(module.getDescription()) + sys.stdout.write(module.getDescription()) elif mode == 'extract-comment': modulesystem = classes.GLModuleSystem(config) modules = [ modulesystem.find(module) for module in modules ] for module in modules: - print(module.getComment()) + sys.stdout.write(module.getComment()) elif mode == 'extract-status': modulesystem = classes.GLModuleSystem(config) modules = [ modulesystem.find(module) for module in modules ] for module in modules: - status = module.getStatus() - print('\n'.join(status)) + sys.stdout.write(module.getStatus()) elif mode == 'extract-notice': modulesystem = classes.GLModuleSystem(config) modules = [ modulesystem.find(module) for module in modules ] for module in modules: - print(module.getNotice()) + sys.stdout.write(module.getNotice()) elif mode == 'extract-applicability': modulesystem = classes.GLModuleSystem(config) @@ -1039,28 +1038,28 @@ def main(): modules = [ modulesystem.find(module) for module in modules ] for module in modules: - print(module.getAutoconfSnippet()) + sys.stdout.write(module.getAutoconfSnippet()) elif mode == 'extract-automake-snippet': modulesystem = classes.GLModuleSystem(config) modules = [ modulesystem.find(module) for module in modules ] for module in modules: - print(module.getAutomakeSnippet()) + sys.stdout.write(module.getAutomakeSnippet()) elif mode == 'extract-include-directive': modulesystem = classes.GLModuleSystem(config) modules = [ modulesystem.find(module) for module in modules ] for module in modules: - print(module.getInclude()) + sys.stdout.write(module.getInclude()) elif mode == 'extract-link-directive': modulesystem = classes.GLModuleSystem(config) modules = [ modulesystem.find(module) for module in modules ] for module in modules: - print(module.getLink()) + sys.stdout.write(module.getLink()) elif mode == 'extract-license': modulesystem = classes.GLModuleSystem(config) @@ -1074,7 +1073,7 @@ def main(): modules = [ modulesystem.find(module) for module in modules ] for module in modules: - print(module.getMaintainer()) + sys.stdout.write(module.getMaintainer()) elif mode == 'extract-tests-module': modulesystem = classes.GLModuleSystem(config) |