]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Simplify.
authorBruno Haible <bruno@clisp.org>
Fri, 5 Aug 2022 02:05:04 +0000 (04:05 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 5 Aug 2022 13:06:21 +0000 (15:06 +0200)
* pygnulib/constants.py (compiler): Remove function.
* gnulib-tool.py: Use re.compile directly instead.
* pygnulib/*.py: Likewise.

ChangeLog
gnulib-tool.py
pygnulib/GLEmiter.py
pygnulib/GLImport.py
pygnulib/GLModuleSystem.py
pygnulib/GLTestDir.py
pygnulib/constants.py

index 1abeb15271023abc00ac787c6e4039008cce1fba..e504d85215125fd6a98a6919e69a599567894804 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-08-05  Bruno Haible  <bruno@clisp.org>
+
+       gnulib-tool.py: Simplify.
+       * pygnulib/constants.py (compiler): Remove function.
+       * gnulib-tool.py: Use re.compile directly instead.
+       * pygnulib/*.py: Likewise.
+
 2022-08-04  Bruno Haible  <bruno@clisp.org>
 
        gnulib-tool.py: Fix typo.
index 21c6789ba93d74b416c0e725243794794296c8d9..1a6bd9e948886d96e805c86d9a768f011e1982ec 100755 (executable)
@@ -55,7 +55,6 @@ ENCS = constants.ENCS
 UTILS = constants.UTILS
 MODES = constants.MODES
 TESTS = constants.TESTS
-compiler = constants.compiler
 joinpath = constants.joinpath
 copyfile = constants.copyfile
 isabs = os.path.isabs
@@ -745,7 +744,7 @@ def main():
                 else:  # if not isfile(filepath)
                     filepath = joinpath(destdir, 'aclocal.m4')
                     if isfile(filepath):
-                        pattern = constants.compiler(r'm4_include\(\[(.*?)\]\)')
+                        pattern = re.compile(r'm4_include\(\[(.*?)\]\)')
                         with codecs.open(filepath, 'rb', 'UTF-8') as file:
                             m4dirs = pattern.findall(file.read())
                         m4dirs = [ os.path.dirname(m4dir)
index c95d10942329b4989f5f622a294e073520992982..b56e551f1dfd7a1c84ee5e9d1237b7f7c7ee10e5 100644 (file)
@@ -45,7 +45,6 @@ __copyright__ = constants.__copyright__
 # Define global constants
 #===============================================================================
 TESTS = constants.TESTS
-compiler = constants.compiler
 joinpath = constants.joinpath
 isfile = os.path.isfile
 normpath = os.path.normpath
@@ -158,7 +157,7 @@ class GLEmiter(object):
                       if line.strip() ]
             snippet = '%s\n' % '\n'.join(lines)
             transformer = fileassistant.transformers.get('aux', '')
-            pattern = compiler('(^.*?$)', re.S | re.M)
+            pattern = re.compile('(^.*?$)', re.S | re.M)
             snippet = pattern.sub('%s\\1' % indentation, snippet)
             if transformer:
                 args = ['sed', '-e', transformer]
@@ -179,7 +178,7 @@ class GLEmiter(object):
             else:
                 # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses
                 # autopoint through at least GNU gettext version 0.18.2.
-                snippet = compiler('^ *AM_GNU_GETTEXT_VERSION').sub('AM_GNU_GETTEXT_VERSION', snippet)
+                snippet = re.compile('^ *AM_GNU_GETTEXT_VERSION').sub('AM_GNU_GETTEXT_VERSION', snippet)
             emit += snippet
             if str(module) == 'alloca' and libtool and not disable_libtool:
                 emit += 'changequote(,)dnl\n'
@@ -189,7 +188,7 @@ class GLEmiter(object):
         if replace_auxdir:
             regex = 'AC_CONFIG_FILES\\(\\[(.*?)\\:build-aux/(.*?)\\]\\)'
             repl = 'AC_CONFIG_FILES([\\1:%s/\\2])' % auxdir
-            pattern = compiler(regex, re.S | re.M)
+            pattern = re.compile(regex, re.S | re.M)
             emit = pattern.sub(repl, emit)
         lines = [ line
                   for line in emit.split('\n')
@@ -694,9 +693,9 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                 amsnippet1 = amsnippet1.replace('lib_LIBRARIES', 'lib%_LIBRARIES')
                 amsnippet1 = amsnippet1.replace('lib_LTLIBRARIES', 'lib%_LTLIBRARIES')
                 if LD_flags:
-                    pattern = compiler('lib_LDFLAGS[\t ]*\\+=(.*?)$', re.S | re.M)
+                    pattern = re.compile('lib_LDFLAGS[\t ]*\\+=(.*?)$', re.S | re.M)
                     amsnippet1 = pattern.sub('', amsnippet1)
-                pattern = compiler('lib_([A-Z][A-Z](?:.*?))', re.S | re.M)
+                pattern = re.compile('lib_([A-Z][A-Z](?:.*?))', re.S | re.M)
                 amsnippet1 = pattern.sub('%s_%s_\\1' % (libname, libext),
                                          amsnippet1)
                 amsnippet1 = amsnippet1.replace('$(GNULIB_', '$(' + module_indicator_prefix + '_GNULIB_')
@@ -709,12 +708,12 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                 if str(module) == 'alloca':
                     amsnippet1 += '%s_%s_LIBADD += @%sALLOCA@\n' % (libname, libext, perhapsLT)
                     amsnippet1 += '%s_%s_DEPENDENCIES += @%sALLOCA@\n' % (libname, libext, perhapsLT)
-                amsnippet1 = constants.combine_lines_matching(compiler('%s_%s_SOURCES' % (libname, libext)),
+                amsnippet1 = constants.combine_lines_matching(re.compile('%s_%s_SOURCES' % (libname, libext)),
                                                               amsnippet1)
 
                 # Get unconditional snippet, edit it and save to amsnippet2.
                 amsnippet2 = module.getAutomakeSnippet_Unconditional()
-                pattern = compiler('lib_([A-Z][A-Z](?:.*?))', re.S | re.M)
+                pattern = re.compile('lib_([A-Z][A-Z](?:.*?))', re.S | re.M)
                 amsnippet2 = pattern.sub('%s_%s_\\1' % (libname, libext),
                                          amsnippet2)
                 amsnippet2 = amsnippet2.replace('$(GNULIB_',
@@ -756,7 +755,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
             #  * https://debbugs.gnu.org/10997
             #  * https://debbugs.gnu.org/11030
             # So we need this workaround.
-            pattern = compiler('^pkgdata_DATA *\\+=', re.S | re.M)
+            pattern = re.compile('^pkgdata_DATA *\\+=', re.S | re.M)
             if pattern.findall(allsnippets):
                 emit += 'pkgdata_DATA =\n'
             emit += 'EXTRA_DIST =\n'
@@ -808,7 +807,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         insnippets = False
         inmakefile = False
         regex = '^[a-zA-Z0-9_]*_%sLIBRARIES *\\+{0,1}= *%s.%s' % (perhapsLT, libname, libext)
-        pattern = compiler(regex, re.S | re.M)
+        pattern = re.compile(regex, re.S | re.M)
         insnippets = bool(pattern.findall(allsnippets))
         # Then test if $sourcebase/Makefile.am (if it exists) specifies it.
         path = joinpath(sourcebase, 'Makefile.am')
@@ -961,9 +960,9 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                 snippet = snippet.replace('lib_LIBRARIES', 'lib%_LIBRARIES')
                 snippet = snippet.replace('lib_LTLIBRARIES', 'lib%_LTLIBRARIES')
                 if LD_flags:
-                    pattern = compiler('lib_LDFLAGS[\t ]*\\+=(.*?)$', re.S | re.M)
+                    pattern = re.compile('lib_LDFLAGS[\t ]*\\+=(.*?)$', re.S | re.M)
                     snippet = pattern.sub('', snippet)
-                pattern = compiler('lib_([A-Z][A-Z](?:.*?))', re.S | re.M)
+                pattern = re.compile('lib_([A-Z][A-Z](?:.*?))', re.S | re.M)
                 snippet = pattern.sub('libtests_a_\\1', snippet)
                 snippet = snippet.replace('$(GNULIB_', '$(' + module_indicator_prefix + '_GNULIB_')
                 snippet = snippet.replace('lib%_LIBRARIES', 'lib_LIBRARIES')
@@ -1038,7 +1037,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         #  * https://debbugs.gnu.org/10997
         #  * https://debbugs.gnu.org/11030
         # So we need this workaround.
-        pattern = compiler('^pkgdata_DATA *\\+=', re.S | re.M)
+        pattern = re.compile('^pkgdata_DATA *\\+=', re.S | re.M)
         if bool(pattern.findall(main_snippets)) or bool(pattern.findall(longrun_snippets)):
             emit += 'pkgdata_DATA =\n'
 
index 9dff29a6b3d635e4eddec3aa6a8b421554fc0120..3b2b14eb4be3d4cecd34033b7be7aa0718295829 100644 (file)
@@ -49,7 +49,6 @@ __copyright__ = constants.__copyright__
 #===============================================================================
 MODES = constants.MODES
 TESTS = constants.TESTS
-compiler = constants.compiler
 joinpath = constants.joinpath
 cleaner = constants.cleaner
 copyfile2 = constants.copyfile2
@@ -99,18 +98,18 @@ class GLImport(object):
         self.config.setAutoconfFile(path)
         with codecs.open(path, 'rb', 'UTF-8') as file:
             data = file.read()
-        pattern = compiler(r'^AC_CONFIG_AUX_DIR\((.*?)\)$', re.S | re.M)
+        pattern = re.compile(r'^AC_CONFIG_AUX_DIR\((.*?)\)$', re.S | re.M)
         match = pattern.findall(data)
         if match:
             result = cleaner(match)[0]
             self.cache.setAuxDir(joinpath(self.config['destdir'], result))
-        pattern = compiler(r'A[CM]_PROG_LIBTOOL', re.S | re.M)
+        pattern = re.compile(r'A[CM]_PROG_LIBTOOL', re.S | re.M)
         guessed_libtool = bool(pattern.findall(data))
         if self.config['auxdir'] == None:
             self.config.setAuxDir(self.cache['auxdir'])
 
         # Guess autoconf version.
-        pattern = compiler(r'.*AC_PREREQ\((.*?)\)', re.S | re.M)
+        pattern = re.compile(r'.*AC_PREREQ\((.*?)\)', re.S | re.M)
         versions = cleaner(pattern.findall(data))
         if versions:
             version = sorted(set([ float(version)
@@ -126,7 +125,7 @@ class GLImport(object):
                 data = file.read()
 
             # Create regex object and keys.
-            pattern = compiler('^(gl_.*?)\\((.*?)\\)$', re.S | re.M)
+            pattern = re.compile('^(gl_.*?)\\((.*?)\\)$', re.S | re.M)
             keys = \
                 [
                     'gl_LOCAL_DIR', 'gl_MODULES', 'gl_AVOID', 'gl_SOURCE_BASE',
@@ -214,7 +213,7 @@ class GLImport(object):
                 with codecs.open(path, 'rb', 'UTF-8') as file:
                     data = file.read()
                 regex = 'AC_DEFUN\\(\\[%s_FILE_LIST\\], \\[(.*?)\\]\\)' % self.cache['macro_prefix']
-                pattern = compiler(regex, re.S | re.M)
+                pattern = re.compile(regex, re.S | re.M)
                 self.cache.setFiles(pattern.findall(data)[-1].strip().split())
 
         # The self.config['localpath'] defaults to the cached one. Recall that
@@ -870,7 +869,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
             notice = notice.strip()
             if notice:
                 print('Notice from module %s:' % str(module))
-                pattern = compiler('^(.*?)$', re.S | re.M)
+                pattern = re.compile('^(.*?)$', re.S | re.M)
                 notice = pattern.sub('  \\1', notice)
                 print(notice)
 
@@ -1442,9 +1441,9 @@ in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library.''')
         with codecs.open(configure_ac, 'rb', 'UTF-8') as file:
             data = file.read()
         match_result1 = \
-            bool(compiler('^ *AC_PROG_CC_STDC', re.S | re.M).findall(data))
+            bool(re.compile('^ *AC_PROG_CC_STDC', re.S | re.M).findall(data))
         match_result2 = \
-            bool(compiler('^ *AC_PROG_CC_C99', re.S | re.M).findall(data))
+            bool(re.compile('^ *AC_PROG_CC_C99', re.S | re.M).findall(data))
         if match_result1:
             position_early_after = 'AC_PROG_CC_STDC'
         elif match_result2:
index eb5b5445942f3f5d74f546dbfac2a99189a09e20..6b8f20e54f230bc2c0271ca5a9af0043874d3a5c 100644 (file)
@@ -42,7 +42,6 @@ __copyright__ = constants.__copyright__
 DIRS = constants.DIRS
 ENCS = constants.ENCS
 TESTS = constants.TESTS
-compiler = constants.compiler
 joinpath = constants.joinpath
 isdir = os.path.isdir
 isfile = os.path.isfile
@@ -281,7 +280,7 @@ Include:|Link:|License:|Maintainer:)'
         '''GLModule.getName() -> str
 
         Return the name of the module.'''
-        pattern = compiler(joinpath('modules', '(.*?)$'))
+        pattern = re.compile(joinpath('modules', '(.*?)$'))
         result = pattern.findall(self.module)[0]
         return result
 
@@ -386,7 +385,7 @@ Include:|Link:|License:|Maintainer:)'
                 result = ''
             else:  # if section in self.content
                 pattern = '^%s[\t ]*(.*?)%s' % (section, self.regex)
-                pattern = compiler(pattern, re.S | re.M)
+                pattern = re.compile(pattern, re.S | re.M)
                 result = pattern.findall(self.content)
                 if type(result) is list:
                     if not result:
@@ -407,7 +406,7 @@ Include:|Link:|License:|Maintainer:)'
                 result = ''
             else:  # if section in self.content
                 pattern = '^%s[\t ]*(.*?)%s' % (section, self.regex)
-                pattern = compiler(pattern, re.S | re.M)
+                pattern = re.compile(pattern, re.S | re.M)
                 result = pattern.findall(self.content)
                 if type(result) is list:
                     if not result:
@@ -436,7 +435,7 @@ Include:|Link:|License:|Maintainer:)'
                     regex = '^(Description|Comment|Status|Notice|Applicability|'
                     regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
                     regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
-                    pattern = compiler(regex)
+                    pattern = re.compile(regex)
                     findflag = pattern.findall(line)
                     if findflag:
                         break
@@ -465,7 +464,7 @@ Include:|Link:|License:|Maintainer:)'
                     regex = '^(Description|Comment|Status|Notice|Applicability|'
                     regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
                     regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
-                    pattern = compiler(regex)
+                    pattern = re.compile(regex)
                     findflag = pattern.findall(line)
                     if findflag:
                         break
@@ -492,7 +491,7 @@ Include:|Link:|License:|Maintainer:)'
                     regex = '^(Description|Comment|Status|Notice|Applicability|'
                     regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
                     regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
-                    pattern = compiler(regex)
+                    pattern = re.compile(regex)
                     findflag = pattern.findall(line)
                     if findflag:
                         break
@@ -530,7 +529,7 @@ Include:|Link:|License:|Maintainer:)'
                     regex = '^(Description|Comment|Status|Notice|Applicability|'
                     regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
                     regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
-                    pattern = compiler(regex)
+                    pattern = re.compile(regex)
                     findflag = pattern.findall(line)
                     if findflag:
                         break
@@ -564,7 +563,7 @@ Include:|Link:|License:|Maintainer:)'
                     regex = '^(Description|Comment|Status|Notice|Applicability|'
                     regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
                     regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
-                    pattern = compiler(regex)
+                    pattern = re.compile(regex)
                     findflag = pattern.findall(line)
                     if findflag:
                         break
@@ -608,7 +607,7 @@ Include:|Link:|License:|Maintainer:)'
                     regex = '^(Description|Comment|Status|Notice|Applicability|'
                     regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
                     regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
-                    pattern = compiler(regex)
+                    pattern = re.compile(regex)
                     findflag = pattern.findall(line)
                     if findflag:
                         break
@@ -635,7 +634,7 @@ Include:|Link:|License:|Maintainer:)'
                     regex = '^(Description|Comment|Status|Notice|Applicability|'
                     regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
                     regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
-                    pattern = compiler(regex)
+                    pattern = re.compile(regex)
                     findflag = pattern.findall(line)
                     if findflag:
                         break
@@ -676,7 +675,7 @@ Include:|Link:|License:|Maintainer:)'
                     regex = '^(Description|Comment|Status|Notice|Applicability|'
                     regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
                     regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
-                    pattern = compiler(regex)
+                    pattern = re.compile(regex)
                     findflag = pattern.findall(line)
                     if findflag:
                         break
@@ -706,7 +705,7 @@ Include:|Link:|License:|Maintainer:)'
                 # TODO: unconditional automake snippet for nontests modules
                 snippet = self.getAutomakeSnippet_Conditional()
                 snippet = constants.combine_lines(snippet)
-                pattern = compiler('^lib_SOURCES[\t ]*\\+=[\t ]*(.*?)$', re.S | re.M)
+                pattern = re.compile('^lib_SOURCES[\t ]*\\+=[\t ]*(.*?)$', re.S | re.M)
                 mentioned_files = pattern.findall(snippet)
                 if mentioned_files != list():
                     mentioned_files = mentioned_files[-1].split(' ')
@@ -774,14 +773,14 @@ Include:|Link:|License:|Maintainer:)'
                     regex = '^(Description|Comment|Status|Notice|Applicability|'
                     regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
                     regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
-                    pattern = compiler(regex)
+                    pattern = re.compile(regex)
                     findflag = pattern.findall(line)
                     if findflag:
                         break
                     parts += [line]
                 result = ''.join(parts)
             result = result.strip()
-            pattern = compiler('^(["<].*?[>"])', re.S | re.M)
+            pattern = re.compile('^(["<].*?[>"])', re.S | re.M)
             result = pattern.sub('#include \\1', result)
             self.cache['include'] = result
         return self.cache['include']
@@ -802,7 +801,7 @@ Include:|Link:|License:|Maintainer:)'
                     regex = '^(Description|Comment|Status|Notice|Applicability|'
                     regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
                     regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
-                    pattern = compiler(regex)
+                    pattern = re.compile(regex)
                     findflag = pattern.findall(line)
                     if findflag:
                         break
@@ -845,7 +844,7 @@ Include:|Link:|License:|Maintainer:)'
                 result = ''
             else:  # if section in self.content
                 pattern = '^%s[\t ]*(.*?)%s' % (section, self.regex)
-                pattern = compiler(pattern, re.S | re.M)
+                pattern = re.compile(pattern, re.S | re.M)
                 result = pattern.findall(self.content)
                 if type(result) is list:
                     if not result:
@@ -874,7 +873,7 @@ Include:|Link:|License:|Maintainer:)'
                     regex = '^(Description|Comment|Status|Notice|Applicability|'
                     regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
                     regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
-                    pattern = compiler(regex)
+                    pattern = re.compile(regex)
                     findflag = pattern.findall(line)
                     if findflag:
                         break
@@ -1042,7 +1041,7 @@ class GLModuleTable(object):
                     if self.config['conddeps']:
                         automake_snippet = \
                             module.getAutomakeSnippet_Conditional()
-                        pattern = compiler('^if')
+                        pattern = re.compile('^if')
                         if not pattern.findall(automake_snippet):
                             self.addUnconditional(module)
                         conditional = self.isConditional(module)
@@ -1165,7 +1164,7 @@ class GLModuleTable(object):
                 raise TypeError('each module must be a GLModule instance')
             snippet = module.getAutomakeSnippet()
             snippet = constants.remove_backslash_newline(snippet)
-            pattern = compiler('^lib_SOURCES[\t ]*\\+=[\t ]*(.*?)$', re.S | re.M)
+            pattern = re.compile('^lib_SOURCES[\t ]*\\+=[\t ]*(.*?)$', re.S | re.M)
             files = pattern.findall(snippet)
             if files:  # if source files were found
                 files = files[-1].split(' ')
index 732a0590dfb93cb0f779194cdb93b825d26ac9d3..624a38317eacd2ed054a313d3f24b2d2f1829317 100644 (file)
@@ -51,7 +51,6 @@ __copyright__ = constants.__copyright__
 DIRS = constants.DIRS
 UTILS = constants.UTILS
 TESTS = constants.TESTS
-compiler = constants.compiler
 joinpath = constants.joinpath
 copyfile = constants.copyfile
 movefile = constants.movefile
@@ -304,7 +303,7 @@ class GLTestDir(object):
                 notice = module.getNotice()
                 if notice:
                     print('Notice from module %s:' % str(module))
-                    pattern = compiler('^(.*?)$', re.S | re.M)
+                    pattern = re.compile('^(.*?)$', re.S | re.M)
                     notice = pattern.sub('  \\1', notice)
                     print(notice)
         else:  # if not single_configure
@@ -312,7 +311,7 @@ class GLTestDir(object):
                 notice = module.getNotice()
                 if notice:
                     print('Notice from module %s:' % str(module))
-                    pattern = compiler('^(.*?)$', re.S | re.M)
+                    pattern = re.compile('^(.*?)$', re.S | re.M)
                     notice = pattern.sub('  \\1', notice)
                     print(notice)
 
@@ -466,7 +465,7 @@ class GLTestDir(object):
                                   for line in snippet.split('\n')
                                   if line.strip() ]
                         snippet = '\n'.join(lines)
-                        pattern = compiler('AC_REQUIRE\\(\\[([^()].*?)\\]\\)', re.S | re.M)
+                        pattern = re.compile('AC_REQUIRE\\(\\[([^()].*?)\\]\\)', re.S | re.M)
                         snippet = pattern.sub('\\1', snippet)
                         snippet = snippet.strip()
                         snippets += [snippet]
@@ -583,7 +582,7 @@ class GLTestDir(object):
                           for line in snippet.split('\n')
                           if line.strip() ]
                 snippet = '\n'.join(lines)
-                pattern = compiler('AC_REQUIRE\\(\\[([^()].*?)\\]\\)', re.S | re.M)
+                pattern = re.compile('AC_REQUIRE\\(\\[([^()].*?)\\]\\)', re.S | re.M)
                 snippet = pattern.sub('\\1', snippet)
                 snippet = snippet.strip()
                 snippets += [snippet]
@@ -754,9 +753,9 @@ class GLTestDir(object):
 
         # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
         regex_find = list()
-        pattern = compiler('^CLEANFILES[\t ]*\\+=(.*?)$', re.S | re.M)
+        pattern = re.compile('^CLEANFILES[\t ]*\\+=(.*?)$', re.S | re.M)
         regex_find += pattern.findall(snippet)
-        pattern = compiler('^MOSTLYCLEANFILES[\t ]*\\+=(.*?)$', re.S | re.M)
+        pattern = re.compile('^MOSTLYCLEANFILES[\t ]*\\+=(.*?)$', re.S | re.M)
         regex_find += pattern.findall(snippet)
         regex_find = [ line.strip()
                        for line in regex_find
@@ -770,7 +769,7 @@ class GLTestDir(object):
         # Extract the value of "BUILT_SOURCES += ...". Remove variable references
         # such $(FOO_H) because they don't refer to distributed files.
         regex_find = list()
-        pattern = compiler('^BUILT_SOURCES[\t ]*\\+=(.*?)$', re.S | re.M)
+        pattern = re.compile('^BUILT_SOURCES[\t ]*\\+=(.*?)$', re.S | re.M)
         regex_find += pattern.findall(snippet)
         regex_find = [ line.strip()
                        for line in regex_find
@@ -782,7 +781,7 @@ class GLTestDir(object):
                   if line.strip()]
         built_sources = [ line
                           for line in built_sources
-                          if not bool(compiler('[$]\\([A-Za-z0-9_]*\\)$').findall(line)) ]
+                          if not bool(re.compile('[$]\\([A-Za-z0-9_]*\\)$').findall(line)) ]
         distributed_built_sources = [ file
                                       for file in built_sources
                                       if file not in cleaned_files ]
@@ -796,9 +795,9 @@ class GLTestDir(object):
 
             # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
             regex_find = list()
-            pattern = compiler('^CLEANFILES[\t ]*\\+=(.*?)$', re.S | re.M)
+            pattern = re.compile('^CLEANFILES[\t ]*\\+=(.*?)$', re.S | re.M)
             regex_find += pattern.findall(snippet)
-            pattern = compiler('^MOSTLYCLEANFILES[\t ]*\\+=(.*?)$', re.S | re.M)
+            pattern = re.compile('^MOSTLYCLEANFILES[\t ]*\\+=(.*?)$', re.S | re.M)
             regex_find += pattern.findall(snippet)
             regex_find = [ line.strip()
                            for line in regex_find
@@ -813,7 +812,7 @@ class GLTestDir(object):
             # such $(FOO_H) because they don't refer to distributed files.
             regex_find = list()
             tests_built_sources = list()
-            pattern = compiler('^BUILT_SOURCES[\t ]*\\+=(.*?)$', re.S | re.M)
+            pattern = re.compile('^BUILT_SOURCES[\t ]*\\+=(.*?)$', re.S | re.M)
             regex_find += pattern.findall(snippet)
             regex_find = [ line.strip()
                            for line in regex_find
@@ -825,7 +824,7 @@ class GLTestDir(object):
                       if line.strip() ]
             tests_built_sources = [ line
                                     for line in tests_built_sources
-                                    if not bool(compiler('[$]\\([A-Za-z0-9_]*\\)$').findall(line)) ]
+                                    if not bool(re.compile('[$]\\([A-Za-z0-9_]*\\)$').findall(line)) ]
             tests_distributed_built_sources = [ file
                                                 for file in tests_built_sources
                                                 if file not in cleaned_files]
index 7d59235007977bba571d90e241097a7a10de6f36..4eff6da8bca2a0427492f1fd6f6758d2a9b49b93 100644 (file)
@@ -237,12 +237,6 @@ def execute(args, verbose):
             sys.exit(retcode)
 
 
-def compiler(pattern, flags=0):
-    '''Compile regex pattern depending on version of Python.'''
-    pattern = re.compile(pattern, flags)
-    return pattern
-
-
 def cleaner(sequence):
     '''Clean string or list of strings after using regex.'''
     if type(sequence) is str:
@@ -405,8 +399,8 @@ def filter_filelist(separator, filelist,
     listing = list()
     for filename in filelist:
         if filename.startswith(prefix) and filename.endswith(suffix):
-            pattern = compiler('^%s(.*?)%s$'
-                               % (removed_prefix, removed_suffix))
+            pattern = re.compile('^%s(.*?)%s$'
+                                 % (removed_prefix, removed_suffix))
             result = pattern.sub('%s\\1%s'
                                  % (added_prefix, added_suffix), filename)
             listing += [result]