diff options
author | Bruno Haible <bruno@clisp.org> | 2022-08-08 18:42:45 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2022-08-09 23:19:04 +0200 |
commit | d0e094317bbf34413e458f9551543335b6eb8cef (patch) | |
tree | f8066246ee5e42dd74ef2fd5d129c8bbcb776973 /pygnulib | |
parent | b9bf95fd0a6ab666b484b1e224321664f051f7fa (diff) | |
download | gnulib-d0e094317bbf34413e458f9551543335b6eb8cef.tar.gz |
gnulib-tool.py: Refactor.
* pygnulib/GLModuleSystem.py (GLModule.getLicense): Separate the warning
logic from the result logic.
Diffstat (limited to 'pygnulib')
-rw-r--r-- | pygnulib/GLModuleSystem.py | 21 |
1 files changed, 11 insertions, 10 deletions
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'] |