]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Refactor.
authorBruno Haible <bruno@clisp.org>
Mon, 8 Aug 2022 16:42:45 +0000 (18:42 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 9 Aug 2022 21:19:04 +0000 (23:19 +0200)
* pygnulib/GLModuleSystem.py (GLModule.getLicense): Separate the warning
logic from the result logic.

ChangeLog
pygnulib/GLModuleSystem.py

index 5dc57dc4f8d855b430e6db8175d8f0ae4f77b216..596f629316b5b451dd0a4a929fe862c172e39d18 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-08-09  Bruno Haible  <bruno@clisp.org>
+
+       gnulib-tool.py: Refactor.
+       * pygnulib/GLModuleSystem.py (GLModule.getLicense): Separate the warning
+       logic from the result logic.
+
 2022-08-09  Paul Eggert  <eggert@cs.ucla.edu>
 
        largefile, year2038: simplify if Autoconf 2.72
index 19d13d213b22f59df617d4dbe7817cb1791ce13a..13d6a722318f82a496fbdf30619742e6119fcd3f 100644 (file)
@@ -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']