From: Bruno Haible Date: Mon, 8 Aug 2022 16:42:45 +0000 (+0200) Subject: gnulib-tool.py: Refactor. X-Git-Tag: v1.0~2138 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=d0e094317bbf34413e458f9551543335b6eb8cef;p=gnulib.git gnulib-tool.py: Refactor. * pygnulib/GLModuleSystem.py (GLModule.getLicense): Separate the warning logic from the result logic. --- 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']