>From 2045ee7288c2a4d0dbea090ae5b829557f96dc1a Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 11 Mar 2024 12:49:24 +0100 Subject: [PATCH] gnulib-tool.py: Make some code more straightforward. * pygnulib/GLImport.py (GLImport.__init__): Reorder assignments and conditions slightly. --- ChangeLog | 6 ++++++ pygnulib/GLImport.py | 33 +++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9135b6b779..308f75a4ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-03-11 Bruno Haible + + gnulib-tool.py: Make some code more straightforward. + * pygnulib/GLImport.py (GLImport.__init__): Reorder assignments and + conditions slightly. + 2024-03-11 Collin Funk gnulib-tool.py: Follow gnulib-tool changes, part 52. diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index de2961c55e..1dabccd201 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -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) -- 2.34.1