diff options
author | Fred Drake <fdrake@acm.org> | 2002-10-16 16:00:42 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2002-10-16 16:00:42 (GMT) |
commit | df85f0b09f9dbba5fb033fdc67acf0466334abfe (patch) | |
tree | 09374a5c9a16142199485cfdbe0c3a36b1906a07 /Doc/tools | |
parent | 071972e426c9782611bd5b66f036d35d809f7ee4 (diff) | |
download | cpython-df85f0b09f9dbba5fb033fdc67acf0466334abfe.zip cpython-df85f0b09f9dbba5fb033fdc67acf0466334abfe.tar.gz cpython-df85f0b09f9dbba5fb033fdc67acf0466334abfe.tar.bz2 |
Modernization: Use string methods, use str instead of
types.StringType, inherit from list instead of
UserList.
Diffstat (limited to 'Doc/tools')
-rwxr-xr-x | Doc/tools/sgmlconv/latex2esis.py | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/Doc/tools/sgmlconv/latex2esis.py b/Doc/tools/sgmlconv/latex2esis.py index 3ccd7e7..47739a6 100755 --- a/Doc/tools/sgmlconv/latex2esis.py +++ b/Doc/tools/sgmlconv/latex2esis.py @@ -19,14 +19,10 @@ import errno import getopt import os import re -import string import sys -import UserList import xml.sax import xml.sax.saxutils -from types import ListType, StringType, TupleType - from esistools import encode @@ -74,29 +70,30 @@ def popping(name, point, depth): dbgmsg("popping </%s> at %s" % (name, point)) -class _Stack(UserList.UserList): +class _Stack(list): def append(self, entry): - if type(entry) is not StringType: + if not isinstance(entry, str): raise LaTeXFormatError("cannot push non-string on stack: " + `entry`) #dbgmsg("%s<%s>" % (" "*len(self.data), entry)) - self.data.append(entry) + list.append(self, entry) def pop(self, index=-1): - entry = self.data[index] - del self.data[index] - #dbgmsg("%s</%s>" % (" "*len(self.data), entry)) + entry = self[index] + del self[index] + #dbgmsg("%s</%s>" % (" " * len(self), entry)) def __delitem__(self, index): - entry = self.data[index] - del self.data[index] - #dbgmsg("%s</%s>" % (" "*len(self.data), entry)) + entry = self[index] + list.__delitem__(self, index) + #dbgmsg("%s</%s>" % (" " * len(self), entry)) def new_stack(): if DEBUG: return _Stack() - return [] + else: + return [] class Conversion: @@ -106,7 +103,7 @@ class Conversion: self.table = table L = [s.rstrip() for s in ifp.readlines()] L.append("") - self.line = string.join(L, "\n") + self.line = "\n".join(L) self.preamble = 1 def convert(self): @@ -340,7 +337,7 @@ class Conversion: break if stack: raise LaTeXFormatError("elements remain on stack: " - + string.join(stack, ", ")) + + ", ".join(stack)) # otherwise we just ran out of input here... # This is a really limited table of combinations, but it will have @@ -546,7 +543,7 @@ def main(): opts, args = getopt.getopt(sys.argv[1:], "D", ["debug"]) for opt, arg in opts: if opt in ("-D", "--debug"): - DEBUG = DEBUG + 1 + DEBUG += 1 if len(args) == 0: ifp = sys.stdin ofp = sys.stdout |