]> granicus.if.org Git - python/commitdiff
String method conversion.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 9 Feb 2001 09:39:08 +0000 (09:39 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 9 Feb 2001 09:39:08 +0000 (09:39 +0000)
Lib/MimeWriter.py
Lib/pre.py
Lib/pyclbr.py
Lib/traceback.py

index 6aab1cd5f1864d373b9c9ffb4e858c31e994f9e8..bb878c1c9d015193d52982b109c09728bfa82ef1 100644 (file)
@@ -7,7 +7,6 @@ MimeWriter - the only thing here.
 """
 
 
-import string
 import mimetools
 
 __all__ = ["MimeWriter"]
@@ -87,12 +86,12 @@ class MimeWriter:
         self._headers = []
 
     def addheader(self, key, value, prefix=0):
-        lines = string.splitfields(value, "\n")
+        lines = value.split("\n")
         while lines and not lines[-1]: del lines[-1]
         while lines and not lines[0]: del lines[0]
         for i in range(1, len(lines)):
-            lines[i] = "    " + string.strip(lines[i])
-        value = string.joinfields(lines, "\n") + "\n"
+            lines[i] = "    " + lines[i].strip()
+        value = "\n".join(lines) + "\n"
         line = key + ": " + value
         if prefix:
             self._headers.insert(0, line)
index adc1ddf3db237ba08e0c186b41905e7b37343c1d..c385824f43fe840e73fab03de01631d1c2ca0dc3 100644 (file)
@@ -229,7 +229,7 @@ def escape(pattern):
         if char not in alphanum:
             if char=='\000': result[i] = '\\000'
             else: result[i] = '\\'+char
-    return string.join(result, '')
+    return ''.join(result)
 
 def compile(pattern, flags=0):
     """compile(pattern[, flags]) -> RegexObject
@@ -398,7 +398,7 @@ class RegexObject:
                 append(source[lastmatch:pos])
             n = n + 1
         append(source[pos:])
-        return (string.join(results, ''), n)
+        return (''.join(results), n)
 
     def split(self, source, maxsplit=0):
         """split(source[, maxsplit=0]) -> list of strings
index 43bd32c64b85409c03c825aaa2df5e334e40f062..305cabb0858a9d70cc33f180fa2bdafdc35b2003 100644 (file)
@@ -160,11 +160,11 @@ def readmodule_ex(module, path=[], inpackage=0):
 
     dict = {}
 
-    i = string.rfind(module, '.')
+    i = module.rfind('.')
     if i >= 0:
         # Dotted module name
-        package = string.strip(module[:i])
-        submodule = string.strip(module[i+1:])
+        package = module[:i].strip()
+        submodule = module[i+1:].strip()
         parent = readmodule(package, path, inpackage)
         child = readmodule(submodule, parent['__path__'], 1)
         return child
@@ -260,15 +260,15 @@ def readmodule_ex(module, path=[], inpackage=0):
             inherit = m.group("ClassSupers")
             if inherit:
                 # the class inherits from other classes
-                inherit = string.strip(inherit[1:-1])
+                inherit = inherit[1:-1].strip()
                 names = []
-                for n in string.splitfields(inherit, ','):
-                    n = string.strip(n)
+                for n in inherit.split(','):
+                    n = n.strip()
                     if dict.has_key(n):
                         # we know this super class
                         n = dict[n]
                     else:
-                        c = string.splitfields(n, '.')
+                        c = n.split('.')
                         if len(c) > 1:
                             # super class
                             # is of the
@@ -291,8 +291,8 @@ def readmodule_ex(module, path=[], inpackage=0):
 
         elif m.start("Import") >= 0:
             # import module
-            for n in string.split(m.group("ImportList"), ','):
-                n = string.strip(n)
+            for n in m.group("ImportList").split(','):
+                n = n.strip()
                 try:
                     # recursively read the imported module
                     d = readmodule(n, path, inpackage)
@@ -303,7 +303,7 @@ def readmodule_ex(module, path=[], inpackage=0):
         elif m.start("ImportFrom") >= 0:
             # from module import stuff
             mod = m.group("ImportFromPath")
-            names = string.split(m.group("ImportFromList"), ',')
+            names = m.group("ImportFromList").split(',')
             try:
                 # recursively read the imported module
                 d = readmodule(mod, path, inpackage)
@@ -314,7 +314,7 @@ def readmodule_ex(module, path=[], inpackage=0):
             # imported module to our name space if they
             # were mentioned in the list
             for n in names:
-                n = string.strip(n)
+                n = n.strip()
                 if d.has_key(n):
                     dict[n] = d[n]
                 elif n == '*':
@@ -334,3 +334,4 @@ def readmodule_ex(module, path=[], inpackage=0):
 
 def _indent(ws, _expandtabs=string.expandtabs):
     return len(_expandtabs(ws, TABWIDTH))
+
index 7097b8f949701999aa1e07f01d0d13d861c2807f..834c568dbdcee5c07918bf11e4f841f761542dd0 100644 (file)
@@ -18,7 +18,7 @@ def print_list(extracted_list, file=None):
         _print(file,
                '  File "%s", line %d, in %s' % (filename,lineno,name))
         if line:
-            _print(file, '    %s' % string.strip(line))
+            _print(file, '    %s' % line.strip())
 
 def format_list(extracted_list):
     """Given a list of tuples as returned by extract_tb() or
@@ -31,7 +31,7 @@ def format_list(extracted_list):
     for filename, lineno, name, line in extracted_list:
         item = '  File "%s", line %d, in %s\n' % (filename,lineno,name)
         if line:
-            item = item + '    %s\n' % string.strip(line)
+            item = item + '    %s\n' % line.strip()
         list.append(item)
     return list
 
@@ -56,7 +56,7 @@ def print_tb(tb, limit=None, file=None):
         _print(file,
                '  File "%s", line %d, in %s' % (filename,lineno,name))
         line = linecache.getline(filename, lineno)
-        if line: _print(file, '    ' + string.strip(line))
+        if line: _print(file, '    ' + line.strip())
         tb = tb.tb_next
         n = n+1
 
@@ -85,7 +85,7 @@ def extract_tb(tb, limit = None):
         filename = co.co_filename
         name = co.co_name
         line = linecache.getline(filename, lineno)
-        if line: line = string.strip(line)
+        if line: line = line.strip()
         else: line = None
         list.append((filename, lineno, name, line))
         tb = tb.tb_next
@@ -157,7 +157,7 @@ def format_exception_only(etype, value):
                 while i < len(line) and \
                       line[i] in string.whitespace:
                     i = i+1
-                list.append('    %s\n' % string.strip(line))
+                list.append('    %s\n' % line.strip())
                 s = '    '
                 for c in line[i:offset-1]:
                     if c in string.whitespace:
@@ -246,7 +246,7 @@ def extract_stack(f=None, limit = None):
         filename = co.co_filename
         name = co.co_name
         line = linecache.getline(filename, lineno)
-        if line: line = string.strip(line)
+        if line: line = line.strip()
         else: line = None
         list.append((filename, lineno, name, line))
         f = f.f_back