]> Savannah Git Hosting - gnulib.git/commitdiff
config/cache: simplify regular expressions
authorDmitry Selyutin <ghostmansd@gmail.com>
Tue, 12 Sep 2017 16:47:11 +0000 (19:47 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Tue, 12 Sep 2017 18:33:32 +0000 (21:33 +0300)
pygnulib/config.py

index d08181db6a79754e63545cb98121ee7689942ae3..13177e44d1fa78f3867a96c5c9b02c8461736e83 100644 (file)
@@ -430,9 +430,9 @@ class Base:
 class Cache(Base):
     """gnulib cached configuration"""
     _AUTOCONF_ = {
-        "autoconf" : _re_.compile(".*AC_PREREQ\\(\\[(.*?)\\]\\)", _re_.S | _re_.M),
-        "auxdir"   : _re_.compile("^AC_CONFIG_AUX_DIR\\(\\[(.*?)\\]\\)$", _re_.S | _re_.M),
-        "libtool"  : _re_.compile("A[CM]_PROG_LIBTOOL", _re_.S | _re_.M)
+        "autoconf" : _re_.compile(r"AC_PREREQ\(\[(.*?)\]\)", _re_.S | _re_.M),
+        "auxdir"   : _re_.compile(r"AC_CONFIG_AUX_DIR\(\[(.*?)\]\)$", _re_.S | _re_.M),
+        "libtool"  : _re_.compile(r"A[CM]_PROG_LIBTOOL", _re_.S | _re_.M)
     }
     _GNULIB_CACHE_ = {
         "local"             : (str, "gl_LOCAL_DIR"),
@@ -470,7 +470,7 @@ class Cache(Base):
             _GNULIB_CACHE_STR_ += [_key_]
         else:
             _GNULIB_CACHE_LIST_ += [_key_]
-    _GNULIB_CACHE_PATTERN_ = _re_.compile("^(gl_.*?)\\(\\[(.*?)\\]\\)$", _re_.S | _re_.M)
+    _GNULIB_CACHE_PATTERN_ = _re_.compile(r"^(gl_.*?)\(\[(.*?)\]\)$", _re_.S | _re_.M)
 
 
     def __init__(self, root, m4_base, autoconf=None, **kwargs):
@@ -526,7 +526,7 @@ class Cache(Base):
             raise FileNotFoundError(path)
         with _codecs_.open(path, "rb", "UTF-8") as stream:
             data = stream.read()
-        regex = "AC_DEFUN\\(\\[%s_FILE_LIST\\], \\[(.*?)\\]\\)" % self["macro-prefix"]
+        regex = r"AC_DEFUN\(\[%s_FILE_LIST\], \[(.*?)\]\)".format(self["macro-prefix"])
         pattern = _re_.compile(regex, _re_.S | _re_.M)
         match = pattern.findall(data)
         if match: