From 071972e426c9782611bd5b66f036d35d809f7ee4 Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Wed, 16 Oct 2002 15:30:17 +0000 Subject: [PATCH] Use string methods. --- Doc/tools/buildindex.py | 6 +++--- Doc/tools/indfix.py | 5 ++--- Doc/tools/keywords.py | 5 ++--- Doc/tools/refcounts.py | 7 +++---- Doc/tools/rewrite.py | 11 +++++------ Doc/tools/support.py | 3 +-- Doc/tools/toc2bkm.py | 4 ++-- 7 files changed, 18 insertions(+), 23 deletions(-) diff --git a/Doc/tools/buildindex.py b/Doc/tools/buildindex.py index b40bd5231e5..08fdb7b33a8 100755 --- a/Doc/tools/buildindex.py +++ b/Doc/tools/buildindex.py @@ -2,7 +2,7 @@ __version__ = '$Revision$' -import os +import os.path import re import string import sys @@ -49,7 +49,7 @@ class Node: def dump(self): return "%s\1%s###%s\n" \ - % (string.join(self.links, "\1"), + % ("\1".join(self.links), bang_join(self.text), self.seqno) @@ -294,7 +294,7 @@ def format_html_letters(nodes, columns, group_symbol_nodes): for letter, nodes in letter_groups: s = "%s" % (letter, letter) items.append(s) - s = ["
\n%s
\n" % string.join(items, " |\n")] + s = ["
\n%s
\n" % " |\n".join(items)] for letter, nodes in letter_groups: s.append(format_letter(letter)) s.append(format_nodes(nodes, columns)) diff --git a/Doc/tools/indfix.py b/Doc/tools/indfix.py index 6e8e911679d..5bab0fb8c3f 100755 --- a/Doc/tools/indfix.py +++ b/Doc/tools/indfix.py @@ -19,13 +19,12 @@ isn't part of a group of similar items is not modified. __version__ = '$Revision$' import re -import string import StringIO import sys -def cmp_entries(e1, e2, lower=string.lower): - return cmp(lower(e1[1]), lower(e2[1])) or cmp(e1, e2) +def cmp_entries(e1, e2): + return cmp(e1[1].lower(), e2[1].lower()) or cmp(e1, e2) def dump_entries(write, entries): diff --git a/Doc/tools/keywords.py b/Doc/tools/keywords.py index 6da352a3835..876987de7c0 100644 --- a/Doc/tools/keywords.py +++ b/Doc/tools/keywords.py @@ -2,11 +2,10 @@ # This Python program sorts and reformats the table of keywords in ref2.tex -import string l = [] try: while 1: - l = l + string.split(raw_input()) + l = l + raw_input().split() except EOFError: pass l.sort() @@ -16,5 +15,5 @@ ncols = 5 nrows = (len(l)+ncols-1)/ncols for i in range(nrows): for j in range(i, len(l), nrows): - print string.ljust(l[j], 10), + print l[j].ljust(10), print diff --git a/Doc/tools/refcounts.py b/Doc/tools/refcounts.py index d7c761b41e2..d82def7a7d8 100644 --- a/Doc/tools/refcounts.py +++ b/Doc/tools/refcounts.py @@ -2,7 +2,6 @@ __version__ = '$Revision$' import os -import string import sys @@ -10,7 +9,7 @@ import sys try: p = os.path.dirname(__file__) except NameError: - p = sys.path[0] + p = os.path.dirname(sys.argv[0]) p = os.path.normpath(os.path.join(os.getcwd(), p, os.pardir, "api", "refcounts.dat")) DEFAULT_PATH = p @@ -27,11 +26,11 @@ def loadfile(fp): line = fp.readline() if not line: break - line = string.strip(line) + line = line.strip() if line[:1] in ("", "#"): # blank lines and comments continue - parts = string.split(line, ":", 4) + parts = line.split(":", 4) if len(parts) != 5: raise ValueError("Not enough fields in " + `line`) function, type, arg, refcount, comment = parts diff --git a/Doc/tools/rewrite.py b/Doc/tools/rewrite.py index e822bf5bd2d..f2c1b80b17d 100644 --- a/Doc/tools/rewrite.py +++ b/Doc/tools/rewrite.py @@ -3,7 +3,6 @@ Usage: rewrite.py boilerplate.tex [VAR=value] ...