]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Teach Tools/freeze/makeconfig.py and Tools/freeze/parsesetup.py to use
authorEric S. Raymond <esr@thyrsus.com>
Sun, 18 Mar 2001 11:27:58 +0000 (11:27 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 18 Mar 2001 11:27:58 +0000 (11:27 +0000)
the re package rather than the obsolete regex.

Tools/freeze/makeconfig.py
Tools/freeze/parsesetup.py

index 5d1ba2c333ca0fe918faafd0df32187822cd4875..11c97d8bd0527aac80d2df82f29b574df3f1d397 100644 (file)
@@ -1,4 +1,4 @@
-import regex
+import re
 
 
 # Write the config.c file
@@ -6,8 +6,8 @@ import regex
 never = ['marshal', '__main__', '__builtin__', 'sys', 'exceptions']
 
 def makeconfig(infp, outfp, modules, with_ifdef=0):
-       m1 = regex.compile('-- ADDMODULE MARKER 1 --')
-       m2 = regex.compile('-- ADDMODULE MARKER 2 --')
+       m1 = re.compile('-- ADDMODULE MARKER 1 --')
+       m2 = re.compile('-- ADDMODULE MARKER 2 --')
        while 1:
                line = infp.readline()
                if not line: break
index 1795671e946d9d6c86eeb7a82e5a05c52a8cb257..7f90075e8b42a43e904eef0c370c2aa51ad172bf 100644 (file)
@@ -1,6 +1,6 @@
 # Parse Makefiles and Python Setup(.in) files.
 
-import regex
+import re
 import string
 
 
@@ -8,7 +8,7 @@ import string
 # Return a dictionary mapping names to values.
 # May raise IOError.
 
-makevardef = regex.compile('^\([a-zA-Z0-9_]+\)[ \t]*=\(.*\)')
+makevardef = re.compile('^([a-zA-Z0-9_]+)[ \t]*=(.*)')
 
 def getmakevars(filename):
        variables = {}
@@ -18,9 +18,10 @@ def getmakevars(filename):
                        line = fp.readline()
                        if not line:
                                break
-                       if makevardef.match(line) < 0:
+                       matchobj = makevardef.match(line)
+                       if not matchobj:
                                continue
-                       name, value = makevardef.group(1, 2)
+                       (name, value) = matchobj.group(1, 2)
                        # Strip trailing comment
                        i = string.find(value, '#')
                        if i >= 0:
@@ -37,7 +38,7 @@ def getmakevars(filename):
 # definitions, the second mapping variable names to their values.
 # May raise IOError.
 
-setupvardef = regex.compile('^\([a-zA-Z0-9_]+\)=\(.*\)')
+setupvardef = re.compile('^([a-zA-Z0-9_]+)=(.*)')
 
 def getsetupinfo(filename):
        modules = {}
@@ -52,8 +53,9 @@ def getsetupinfo(filename):
                        i = string.find(line, '#')
                        if i >= 0:
                                line = line[:i]
-                       if setupvardef.match(line) >= 0:
-                               name, value = setupvardef.group(1, 2)
+                       matchobj = setupvardef.match(line)
+                       if matchobj:
+                               (name, value) = matchobj.group(1, 2)
                                variables[name] = string.strip(value)
                        else:
                                words = string.split(line)