1919import getopt
2020import os
2121import re
22- import string
2322import sys
24- import UserList
2523import xml .sax
2624import xml .sax .saxutils
2725
28- from types import ListType , StringType , TupleType
29-
3026from esistools import encode
3127
3228
@@ -74,29 +70,30 @@ def popping(name, point, depth):
7470 dbgmsg ("popping </%s> at %s" % (name , point ))
7571
7672
77- class _Stack (UserList . UserList ):
73+ class _Stack (list ):
7874 def append (self , entry ):
79- if type (entry ) is not StringType :
75+ if not isinstance (entry , str ) :
8076 raise LaTeXFormatError ("cannot push non-string on stack: "
8177 + `entry` )
8278 #dbgmsg("%s<%s>" % (" "*len(self.data), entry))
83- self . data . append (entry )
79+ list . append (self , entry )
8480
8581 def pop (self , index = - 1 ):
86- entry = self . data [index ]
87- del self . data [index ]
88- #dbgmsg("%s</%s>" % (" "* len(self.data ), entry))
82+ entry = self [index ]
83+ del self [index ]
84+ #dbgmsg("%s</%s>" % (" " * len(self), entry))
8985
9086 def __delitem__ (self , index ):
91- entry = self . data [index ]
92- del self . data [ index ]
93- #dbgmsg("%s</%s>" % (" "* len(self.data ), entry))
87+ entry = self [index ]
88+ list . __delitem__ ( self , index )
89+ #dbgmsg("%s</%s>" % (" " * len(self), entry))
9490
9591
9692def new_stack ():
9793 if DEBUG :
9894 return _Stack ()
99- return []
95+ else :
96+ return []
10097
10198
10299class Conversion :
@@ -106,7 +103,7 @@ def __init__(self, ifp, ofp, table):
106103 self .table = table
107104 L = [s .rstrip () for s in ifp .readlines ()]
108105 L .append ("" )
109- self .line = string . join ( L , "\n " )
106+ self .line = "\n " . join ( L )
110107 self .preamble = 1
111108
112109 def convert (self ):
@@ -340,7 +337,7 @@ def subconvert(self, endchar=None, depth=0):
340337 break
341338 if stack :
342339 raise LaTeXFormatError ("elements remain on stack: "
343- + string . join ( stack , ", " ))
340+ + ", " . join ( stack ))
344341 # otherwise we just ran out of input here...
345342
346343 # This is a really limited table of combinations, but it will have
@@ -546,7 +543,7 @@ def main():
546543 opts , args = getopt .getopt (sys .argv [1 :], "D" , ["debug" ])
547544 for opt , arg in opts :
548545 if opt in ("-D" , "--debug" ):
549- DEBUG = DEBUG + 1
546+ DEBUG += 1
550547 if len (args ) == 0 :
551548 ifp = sys .stdin
552549 ofp = sys .stdout
0 commit comments