Skip to content

Commit 0f9bfd3

Browse files
committed
Convert most uses of the string module to string methods.
(string.join() lives!)
1 parent bbf7a40 commit 0f9bfd3

3 files changed

Lines changed: 15 additions & 16 deletions

File tree

Doc/tools/sgmlconv/esis2sgml.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def convert(ifp, ofp, xml=0, autoclose=(), verbatims=()):
9797
data = esistools.decode(data)
9898
data = escape(data)
9999
if not inverbatim:
100-
data = string.replace(data, "---", "—")
100+
data = data.replace("---", "—")
101101
ofp.write(data)
102102
if "\n" in data:
103103
lastopened = None
@@ -139,7 +139,7 @@ def convert(ifp, ofp, xml=0, autoclose=(), verbatims=()):
139139
lastempty = 0
140140
inverbatim = 0
141141
elif type == "A":
142-
name, type, value = string.split(data, " ", 2)
142+
name, type, value = data.split(" ", 2)
143143
name = map_gi(name, _attr_map)
144144
attrs[name] = esistools.decode(value)
145145
elif type == "e":
@@ -165,7 +165,7 @@ def dump_empty_element_names(knownempties):
165165
line = fp.readline()
166166
if not line:
167167
break
168-
gi = string.strip(line)
168+
gi = line.strip()
169169
if gi:
170170
d[gi] = gi
171171
fp = open(EMPTIES_FILENAME, "w")
@@ -177,9 +177,9 @@ def dump_empty_element_names(knownempties):
177177

178178

179179
def update_gi_map(map, names, fromsgml=1):
180-
for name in string.split(names, ","):
180+
for name in names.split(","):
181181
if fromsgml:
182-
uncased = string.lower(name)
182+
uncased = name.lower()
183183
else:
184184
uncased = name
185185
map[uncased] = name
@@ -211,7 +211,7 @@ def main():
211211
elif opt in ("-x", "--xml"):
212212
xml = 1
213213
elif opt in ("-a", "--autoclose"):
214-
autoclose = string.split(arg, ",")
214+
autoclose = arg.split(",")
215215
elif opt == "--elements-map":
216216
elem_names = ("%s,%s" % (elem_names, arg))[1:]
217217
elif opt == "--attributes-map":
@@ -241,9 +241,9 @@ def main():
241241
# stream but set up conversion tables to get the case right on output
242242
global _normalize_case
243243
_normalize_case = string.lower
244-
update_gi_map(_elem_map, string.split(elem_names, ","))
245-
update_gi_map(_attr_map, string.split(attr_names, ","))
246-
update_gi_map(_values_map, string.split(value_names, ","))
244+
update_gi_map(_elem_map, elem_names.split(","))
245+
update_gi_map(_attr_map, attr_names.split(","))
246+
update_gi_map(_values_map, value_names.split(","))
247247
else:
248248
global map_gi
249249
map_gi = null_map_gi

Doc/tools/sgmlconv/esistools.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Miscellaneous utility functions useful for dealing with ESIS streams."""
22

33
import re
4-
import string
54

65
import xml.dom.pulldom
76

@@ -182,7 +181,7 @@ def _handle_token(self, token, data):
182181
elif token == '?':
183182
if handler:
184183
if ' ' in data:
185-
target, data = string.split(data, None, 1)
184+
target, data = data.split(None, 1)
186185
else:
187186
target, data = data, ""
188187
handler.processingInstruction(target, decode(data))

Doc/tools/sgmlconv/latex2esis.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def __init__(self, ifp, ofp, table):
109109
self.write = ofp.write
110110
self.ofp = ofp
111111
self.table = table
112-
self.line = string.join(map(string.rstrip, ifp.readlines()), "\n")
112+
self.line = string.join([s.rstrip() for s in ifp.readlines()], "\n")
113113
self.preamble = 1
114114

115115
def convert(self):
@@ -170,7 +170,7 @@ def subconvert(self, endchar=None, depth=0):
170170
entry = self.get_entry(macroname)
171171
if entry.verbatim:
172172
# magic case!
173-
pos = string.find(line, "\\end{%s}" % macroname)
173+
pos = line.find("\\end{%s}" % macroname)
174174
text = line[m.end(1):pos]
175175
stack.append(entry.name)
176176
self.write("(%s\n" % entry.outputname)
@@ -410,7 +410,7 @@ def convert(ifp, ofp, table):
410410

411411
def skip_white(line):
412412
while line and line[0] in " %\n\t\r":
413-
line = string.lstrip(line[1:])
413+
line = line[1:].lstrip()
414414
return line
415415

416416

@@ -461,14 +461,14 @@ def start_environment(self, attrs):
461461
self.__current.verbatim = attrs.get("verbatim") == "yes"
462462
if attrs.has_key("outputname"):
463463
self.__current.outputname = attrs.get("outputname")
464-
self.__current.endcloses = string.split(attrs.get("endcloses", ""))
464+
self.__current.endcloses = attrs.get("endcloses", "").split()
465465
def end_environment(self):
466466
self.end_macro()
467467

468468
def start_macro(self, attrs):
469469
name = attrs["name"]
470470
self.__current = TableEntry(name)
471-
self.__current.closes = string.split(attrs.get("closes", ""))
471+
self.__current.closes = attrs.get("closes", "").split()
472472
if attrs.has_key("outputname"):
473473
self.__current.outputname = attrs.get("outputname")
474474
def end_macro(self):

0 commit comments

Comments
 (0)