]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Make some code more straightforward.
authorBruno Haible <bruno@clisp.org>
Mon, 11 Mar 2024 11:49:24 +0000 (12:49 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 11 Mar 2024 11:49:24 +0000 (12:49 +0100)
* pygnulib/GLImport.py (GLImport.__init__): Reorder assignments and
conditions slightly.

ChangeLog
pygnulib/GLImport.py

index 9135b6b7794473437b5b87b871af4c68e7d72e54..308f75a4adc83f92a459e00107321810632556fe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-03-11  Bruno Haible  <bruno@clisp.org>
+
+       gnulib-tool.py: Make some code more straightforward.
+       * pygnulib/GLImport.py (GLImport.__init__): Reorder assignments and
+       conditions slightly.
+
 2024-03-11  Collin Funk  <collin.funk1@gmail.com>
 
        gnulib-tool.py: Follow gnulib-tool changes, part 52.
index de2961c55ed4fc72d124b6035c31644e004abdc7..1dabccd20198da63d7825211e42f6ab645fd7f04 100644 (file)
@@ -261,31 +261,32 @@ class GLImport(object):
 
         # Determine whether --automake-subdir is supported.
         if self.config['automake_subdir']:
-            automake_options = set()
+            found_subdir_objects = False
             if self.config['destdir']:
-                pattern = re.compile(r'^.*AM_INIT_AUTOMAKE\([\[ ]*([^\]\)]*).*$', re.MULTILINE)
                 with open(self.config['configure_ac'], encoding='utf-8') as file:
                     data = file.read()
+                pattern = re.compile(r'^.*AM_INIT_AUTOMAKE\([\[ ]*([^\]\)]*).*$', re.MULTILINE)
                 configure_ac_automake_options = pattern.findall(data)
                 if configure_ac_automake_options:
                     automake_options = { x
                                          for y in configure_ac_automake_options
                                          for x in y.split() }
-            found_subdir_objects = 'subdir-objects' in automake_options
-            if self.config['destdir']:
-                base = self.config['destdir']
-            else:
-                base = '.'
-            if not found_subdir_objects and isfile(joinpath(base, 'Makefile.am')):
-                pattern = re.compile(r'^AUTOMAKE_OPTIONS[\t ]*=(.*)$', re.MULTILINE)
-                with open(joinpath(base, 'Makefile.am'), encoding='utf-8') as file:
-                    data = file.read()
-                automake_options = pattern.findall(data)
-                if automake_options:
-                    automake_options = { x
-                                         for y in automake_options
-                                         for x in y.split() }
                     found_subdir_objects = 'subdir-objects' in automake_options
+            if not found_subdir_objects:
+                if self.config['destdir']:
+                    base = self.config['destdir']
+                else:
+                    base = '.'
+                if isfile(joinpath(base, 'Makefile.am')):
+                    with open(joinpath(base, 'Makefile.am'), encoding='utf-8') as file:
+                        data = file.read()
+                    pattern = re.compile(r'^AUTOMAKE_OPTIONS[\t ]*=(.*)$', re.MULTILINE)
+                    automake_options = pattern.findall(data)
+                    if automake_options:
+                        automake_options = { x
+                                             for y in automake_options
+                                             for x in y.split() }
+                        found_subdir_objects = 'subdir-objects' in automake_options
             if not found_subdir_objects:
                 raise GLError(21, None)