]> granicus.if.org Git - python/commitdiff
Use string.replace instead of regsub.[g]sub.
authorGuido van Rossum <guido@python.org>
Wed, 24 Dec 1997 21:18:41 +0000 (21:18 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 24 Dec 1997 21:18:41 +0000 (21:18 +0000)
Lib/CGIHTTPServer.py
Lib/binhex.py
Lib/cgi.py
Lib/mhlib.py
Lib/telnetlib.py

index 85e172172193a169a5d94a0acab72a52f197ba47..b40edbced47e3343e9946cdf6856af3e31f0c3b5 100644 (file)
@@ -148,8 +148,7 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
            if ua:
                env['HTTP_USER_AGENT'] = ua
            # XXX Other HTTP_* headers
-           import regsub
-           decoded_query = regsub.gsub('+', ' ', query)
+           decoded_query = string.replace(query, '+', ' ')
            try:
                os.setuid(nobody)
            except os.error:
index 7c22c4e0c7e1148835aadbf5ee853bcf1b526678..469344330757711089f6e3651fbc0b52cdef1e56 100644 (file)
@@ -76,7 +76,6 @@ else:
        #
        # Glue code for non-macintosh useage
        #
-       import regsub
        
        class FInfo:
                def __init__(self):
@@ -99,7 +98,7 @@ else:
                dsize = fp.tell()
                fp.close()
                dir, file = os.path.split(name)
-               file = regsub.sub(':', '-', file)
+               file = string.replace(file, ':', '-', 1)
                return file, finfo, dsize, 0
 
        class openrsrc:
index fb3076c9aa1f7079f8d84c2d4e570d7142836ae4..e4cb217a05ae10859a83612927b1283c2d79e921 100755 (executable)
@@ -420,7 +420,6 @@ import string
 import sys
 import os
 import urllib
-import regsub
 import mimetools
 import rfc822
 from StringIO import StringIO
@@ -564,8 +563,8 @@ def parse_qs(qs, keep_blank_values=0, strict_parsing=0):
            if strict_parsing:
                raise ValueError, "bad query field: %s" % `name_value`
            continue
-       name = urllib.unquote(regsub.gsub('+', ' ', nv[0]))
-       value = urllib.unquote(regsub.gsub('+', ' ', nv[1]))
+       name = urllib.unquote(string.replace(nv[0], '+', ' '))
+       value = urllib.unquote(string.replace(nv[1], '+', ' '))
         if len(value) or keep_blank_values:
            if dict.has_key (name):
                dict[name].append(value)
@@ -1317,11 +1316,11 @@ environment as well.  Here are some common variable names:
 
 def escape(s, quote=None):
     """Replace special characters '&', '<' and '>' by SGML entities."""
-    s = regsub.gsub("&", "&amp;", s)   # Must be done first!
-    s = regsub.gsub("<", "&lt;", s)
-    s = regsub.gsub(">", "&gt;", s)
+    s = string.replace(s, "&", "&amp;")        # Must be done first!
+    s = string.replace(s, "<", "&lt;")
+    s = string.replace(s, ">", "&gt;",)
     if quote:
-       s = regsub.gsub('"', "&quot;", s)
+       s = string.replace(s, '"', "&quot;")
     return s
 
 
index 69a33ec6797f24d15d8968e497ba92526cf42e67..dc9871234c0ee3ca74891f2c65d7b6fdc1466b06 100644 (file)
@@ -773,7 +773,7 @@ class SubMessage(Message):
 # - the string used to initialize the set (default ''),
 # - the separator between ranges (default ',')
 # - the separator between begin and end of a range (default '-')
-# The separators may be regular expressions and should be different.
+# The separators must be strings (not regexprs) and should be different.
 #
 # The tostring() function yields a string that can be passed to another
 # IntSet constructor; __repr__() is a valid IntSet constructor itself.
@@ -882,11 +882,11 @@ class IntSet:
        self.normalize()
 
     def fromstring(self, data):
-       import string, regsub
+       import string
        new = []
-       for part in regsub.split(data, self.sep):
+       for part in string.splitfields(data, self.sep):
            list = []
-           for subp in regsub.split(part, self.rng):
+           for subp in string.splitfields(part, self.rng):
                s = string.strip(subp)
                list.append(string.atoi(s))
            if len(list) == 1:
index 4595426055fddfc7930bc76f92711e8737eb0f36..0f20fb4cc0d9a277ba3e0ce471e77a3ff48679ca 100644 (file)
@@ -38,7 +38,6 @@ To do:
 import socket
 import select
 import string
-import regsub
 
 # Tunable parameters
 DEBUGLEVEL = 0
@@ -185,7 +184,7 @@ class Telnet:
 
        """
        if IAC in buffer:
-           buffer = regsub.gsub(IAC, IAC+IAC, buffer)
+           buffer = string.replace(buffer, IAC, IAC+IAC)
        self.sock.send(buffer)
 
     def read_until(self, match, timeout=None):