summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-03-23 16:53:34 (GMT)
committerFred Drake <fdrake@acm.org>2001-03-23 16:53:34 (GMT)
commit2262a80fb3ad3cb4850a7018146963df94a0b7a1 (patch)
tree88bfa13727ebd504a02103ef184e067d7bbe571d /Doc
parenta9d0450f72044b5a5d60cd02f583ad4524fb9ef7 (diff)
downloadcpython-2262a80fb3ad3cb4850a7018146963df94a0b7a1.zip
cpython-2262a80fb3ad3cb4850a7018146963df94a0b7a1.tar.gz
cpython-2262a80fb3ad3cb4850a7018146963df94a0b7a1.tar.bz2
Pick up the "encode" function from esistools instead of defining our own
(broken) version. Remove Conversion.err_write() -- use dbgmsg() consistently.
Diffstat (limited to 'Doc')
-rwxr-xr-xDoc/tools/sgmlconv/latex2esis.py24
1 files changed, 9 insertions, 15 deletions
diff --git a/Doc/tools/sgmlconv/latex2esis.py b/Doc/tools/sgmlconv/latex2esis.py
index d4bfa3f..74e1dc7 100755
--- a/Doc/tools/sgmlconv/latex2esis.py
+++ b/Doc/tools/sgmlconv/latex2esis.py
@@ -32,6 +32,9 @@ except ImportError:
from xmllib import XMLParser
+from esistools import encode
+
+
DEBUG = 0
@@ -47,10 +50,6 @@ class LaTeXStackError(LaTeXFormatError):
self.stack = stack[:]
LaTeXFormatError.__init__(self, msg)
-def encode(s):
- s = xml.sax.saxutils.escape(s)
- return s.replace("\n", "\\n\n-")
-
_begin_env_rx = re.compile(r"[\\]begin{([^}]*)}")
_end_env_rx = re.compile(r"[\\]end{([^}]*)}")
@@ -85,18 +84,18 @@ class _Stack(UserList.UserList):
if type(entry) is not StringType:
raise LaTeXFormatError("cannot push non-string on stack: "
+ `entry`)
- sys.stderr.write("%s<%s>\n" % (" "*len(self.data), entry))
+ #dbgmsg("%s<%s>" % (" "*len(self.data), entry))
self.data.append(entry)
def pop(self, index=-1):
entry = self.data[index]
del self.data[index]
- sys.stderr.write("%s</%s>\n" % (" "*len(self.data), entry))
+ #dbgmsg("%s</%s>" % (" "*len(self.data), entry))
def __delitem__(self, index):
entry = self.data[index]
del self.data[index]
- sys.stderr.write("%s</%s>\n" % (" "*len(self.data), entry))
+ #dbgmsg("%s</%s>" % (" "*len(self.data), entry))
def new_stack():
@@ -113,10 +112,6 @@ class Conversion:
self.line = string.join(map(string.rstrip, ifp.readlines()), "\n")
self.preamble = 1
- def err_write(self, msg):
- if DEBUG:
- sys.stderr.write(str(msg) + "\n")
-
def convert(self):
self.subconvert()
@@ -271,7 +266,7 @@ class Conversion:
opened = 1
stack.append(entry.name)
self.write("(%s\n" % entry.outputname)
- self.err_write("--- text: %s\n" % `pentry.text`)
+ #dbgmsg("--- text: %s" % `pentry.text`)
self.write("-%s\n" % encode(pentry.text))
elif pentry.type == "entityref":
self.write("&%s\n" % pentry.name)
@@ -290,7 +285,7 @@ class Conversion:
# end of macro or group
macroname = stack[-1]
if macroname:
- conversion = self.table.get(macroname)
+ conversion = self.table[macroname]
if conversion.outputname:
# otherwise, it was just a bare group
self.write(")%s\n" % conversion.outputname)
@@ -373,8 +368,7 @@ class Conversion:
def get_entry(self, name):
entry = self.table.get(name)
if entry is None:
- self.err_write("get_entry(%s) failing; building default entry!"
- % `name`)
+ dbgmsg("get_entry(%s) failing; building default entry!" % `name`)
# not defined; build a default entry:
entry = TableEntry(name)
entry.has_content = 1