summaryrefslogtreecommitdiff
path: root/pygnulib
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2022-08-05 04:05:04 +0200
committerBruno Haible <bruno@clisp.org>2022-08-05 15:06:21 +0200
commit276725c4e2c8e06e3cec36472adb0be7d99b709d (patch)
tree8beb56b7d40f12f7c2b0d5226c697fd971dab9c3 /pygnulib
parentc0c72120f0a9e1514d5a46d3588bf40bdbd20be4 (diff)
downloadgnulib-276725c4e2c8e06e3cec36472adb0be7d99b709d.tar.gz
gnulib-tool.py: Simplify.
* pygnulib/constants.py (compiler): Remove function. * gnulib-tool.py: Use re.compile directly instead. * pygnulib/*.py: Likewise.
Diffstat (limited to 'pygnulib')
-rw-r--r--pygnulib/GLEmiter.py25
-rw-r--r--pygnulib/GLImport.py17
-rw-r--r--pygnulib/GLModuleSystem.py39
-rw-r--r--pygnulib/GLTestDir.py25
-rw-r--r--pygnulib/constants.py10
5 files changed, 53 insertions, 63 deletions
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index c95d109423..b56e551f1d 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -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'
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index 9dff29a6b3..3b2b14eb4b 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -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:
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index eb5b544594..6b8f20e54f 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -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(' ')
diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py
index 732a0590df..624a38317e 100644
--- a/pygnulib/GLTestDir.py
+++ b/pygnulib/GLTestDir.py
@@ -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]
diff --git a/pygnulib/constants.py b/pygnulib/constants.py
index 7d59235007..4eff6da8bc 100644
--- a/pygnulib/constants.py
+++ b/pygnulib/constants.py
@@ -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]