>From d0e094317bbf34413e458f9551543335b6eb8cef Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 8 Aug 2022 18:42:45 +0200 Subject: [PATCH 1/5] gnulib-tool.py: Refactor. * pygnulib/GLModuleSystem.py (GLModule.getLicense): Separate the warning logic from the result logic. --- ChangeLog | 6 ++++++ pygnulib/GLModuleSystem.py | 21 +++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5dc57dc4f8..596f629316 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2022-08-09 Bruno Haible + + gnulib-tool.py: Refactor. + * pygnulib/GLModuleSystem.py (GLModule.getLicense): Separate the warning + logic from the result logic. + 2022-08-09 Paul Eggert largefile, year2038: simplify if Autoconf 2.72 diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py index 19d13d213b..13d6a72231 100644 --- a/pygnulib/GLModuleSystem.py +++ b/pygnulib/GLModuleSystem.py @@ -651,23 +651,24 @@ class GLModule(object): Get license and warn user if module lacks a license.''' if 'license' not in self.cache: - result = None + license = self.getLicense_Raw().strip() + # Warn if the License field is missing. + if not self.isTests(): + if not license: + if self.config['errors']: + raise GLError(18, str(self)) + else: # if not self.config['errors'] + sys.stderr.write('gnulib-tool: warning: module %s lacks a License\n' % str(self)) if str(self) == 'parse-datetime': # This module is under a weaker license only for the purpose of some # users who hand-edit it and don't use gnulib-tool. For the regular # gnulib users they are under a stricter license. result = 'GPL' else: - license = self.getLicense_Raw().strip() - if not self.isTests(): - if not license: - if self.config['errors']: - raise GLError(18, str(self)) - else: # if not self.config['errors'] - sys.stderr.write('gnulib-tool: warning: module %s lacks a license\n' % str(self)) - if not license: - license = 'GPL' result = license + # The default is GPL. + if not result: + result = 'GPL' self.cache['license'] = result return self.cache['license'] -- 2.34.1