summaryrefslogtreecommitdiffstats
path: root/Doc/tools/sgmlconv
diff options
context:
space:
mode:
authorCollin Winter <collinw@gmail.com>2007-03-21 02:11:39 (GMT)
committerCollin Winter <collinw@gmail.com>2007-03-21 02:11:39 (GMT)
commit65d09d4ee984d569424e11415f30d6af209ef558 (patch)
tree8b94fe73e8dbf38622ef2bff089310197956eb08 /Doc/tools/sgmlconv
parent89df245607619ed532106fbbdbf80745815f9c96 (diff)
downloadcpython-65d09d4ee984d569424e11415f30d6af209ef558.zip
cpython-65d09d4ee984d569424e11415f30d6af209ef558.tar.gz
cpython-65d09d4ee984d569424e11415f30d6af209ef558.tar.bz2
Run 2to3 over Doc/tools/.
Diffstat (limited to 'Doc/tools/sgmlconv')
-rwxr-xr-xDoc/tools/sgmlconv/docfixer.py14
-rwxr-xr-xDoc/tools/sgmlconv/esis2sgml.py8
-rw-r--r--Doc/tools/sgmlconv/esistools.py8
-rwxr-xr-xDoc/tools/sgmlconv/latex2esis.py6
4 files changed, 16 insertions, 20 deletions
diff --git a/Doc/tools/sgmlconv/docfixer.py b/Doc/tools/sgmlconv/docfixer.py
index 961e3b8..9f93966 100755
--- a/Doc/tools/sgmlconv/docfixer.py
+++ b/Doc/tools/sgmlconv/docfixer.py
@@ -210,8 +210,7 @@ def rewrite_descriptor(doc, descriptor):
# 2a.
if descriptor.hasAttribute("var"):
if descname != "opcodedesc":
- raise RuntimeError, \
- "got 'var' attribute on descriptor other than opcodedesc"
+ raise RuntimeError("got 'var' attribute on descriptor other than opcodedesc")
variable = descriptor.getAttribute("var")
if variable:
args = doc.createElement("args")
@@ -241,7 +240,7 @@ def rewrite_descriptor(doc, descriptor):
try:
sig = methodline_to_signature(doc, children[pos])
except KeyError:
- print oldchild.toxml()
+ print(oldchild.toxml())
raise
newchildren.append(sig)
else:
@@ -347,7 +346,7 @@ def fixup_trailing_whitespace(doc, fragment, wsmap):
while queue:
node = queue[0]
del queue[0]
- if wsmap.has_key(node.nodeName):
+ if node.nodeName in wsmap:
fixups.append(node)
for child in node.childNodes:
if child.nodeType == ELEMENT:
@@ -962,8 +961,7 @@ def write_esis(doc, ofp, knownempty):
gi = node.tagName
if knownempty(gi):
if node.hasChildNodes():
- raise ValueError, \
- "declared-empty node <%s> has children" % gi
+ raise ValueError("declared-empty node <%s> has children" % gi)
ofp.write("e\n")
for k, value in node.attributes.items():
if _token_rx.match(value):
@@ -979,7 +977,7 @@ def write_esis(doc, ofp, knownempty):
elif nodeType == ENTITY_REFERENCE:
ofp.write("&%s\n" % node.nodeName)
else:
- raise RuntimeError, "unsupported node type: %s" % nodeType
+ raise RuntimeError("unsupported node type: %s" % nodeType)
def convert(ifp, ofp):
@@ -1033,7 +1031,7 @@ def convert(ifp, ofp):
for gi in events.parser.get_empties():
d[gi] = gi
for key in ("author", "pep", "rfc"):
- if d.has_key(key):
+ if key in d:
del d[key]
knownempty = d.has_key
#
diff --git a/Doc/tools/sgmlconv/esis2sgml.py b/Doc/tools/sgmlconv/esis2sgml.py
index 81294d1..10ec83a 100755
--- a/Doc/tools/sgmlconv/esis2sgml.py
+++ b/Doc/tools/sgmlconv/esis2sgml.py
@@ -44,8 +44,7 @@ def null_map_gi(sgmlgi, map):
def format_attrs(attrs, xml=0):
- attrs = attrs.items()
- attrs.sort()
+ attrs = sorted(attrs.items())
parts = []
append = parts.append
for name, value in attrs:
@@ -149,7 +148,7 @@ def convert(ifp, ofp, xml=0, autoclose=(), verbatims=()):
ofp.write("&%s;" % data)
knownempty = 0
else:
- raise RuntimeError, "unrecognized ESIS event type: '%s'" % type
+ raise RuntimeError("unrecognized ESIS event type: '%s'" % type)
if LIST_EMPTIES:
dump_empty_element_names(knownempties)
@@ -170,8 +169,7 @@ def dump_empty_element_names(knownempties):
if gi:
d[gi] = gi
fp = open(EMPTIES_FILENAME, "w")
- gilist = d.keys()
- gilist.sort()
+ gilist = sorted(d.keys())
fp.write("\n".join(gilist))
fp.write("\n")
fp.close()
diff --git a/Doc/tools/sgmlconv/esistools.py b/Doc/tools/sgmlconv/esistools.py
index 6dc5eaa..11f458e 100644
--- a/Doc/tools/sgmlconv/esistools.py
+++ b/Doc/tools/sgmlconv/esistools.py
@@ -29,7 +29,7 @@ def decode(s):
n, s = s.split(";", 1)
r = r + unichr(int(n))
else:
- raise ValueError, "can't handle %r" % s
+ raise ValueError("can't handle %r" % s)
return r
@@ -80,7 +80,7 @@ class ESISReader(xml.sax.xmlreader.XMLReader):
self.setErrorHandler(errorHandler)
def get_empties(self):
- return self._empties.keys()
+ return list(self._empties.keys())
#
# XMLReader interface
@@ -270,7 +270,7 @@ class Attributes(xml.sax.xmlreader.AttributesImpl):
return self._attrs[name][0]
def get(self, name, default=None):
- if self._attrs.has_key(name):
+ if name in self._attrs:
return self._attrs[name][0]
return default
@@ -282,7 +282,7 @@ class Attributes(xml.sax.xmlreader.AttributesImpl):
def values(self):
L = []
- for value, type in self._attrs.values():
+ for value, type in list(self._attrs.values()):
L.append(value)
return L
diff --git a/Doc/tools/sgmlconv/latex2esis.py b/Doc/tools/sgmlconv/latex2esis.py
index cbc9828..3ee86e3 100755
--- a/Doc/tools/sgmlconv/latex2esis.py
+++ b/Doc/tools/sgmlconv/latex2esis.py
@@ -472,7 +472,7 @@ class TableHandler(xml.sax.handler.ContentHandler):
name = attrs["name"]
self.__current = TableEntry(name, environment=1)
self.__current.verbatim = attrs.get("verbatim") == "yes"
- if attrs.has_key("outputname"):
+ if "outputname" in attrs:
self.__current.outputname = attrs.get("outputname")
self.__current.endcloses = attrs.get("endcloses", "").split()
def end_environment(self):
@@ -482,11 +482,11 @@ class TableHandler(xml.sax.handler.ContentHandler):
name = attrs["name"]
self.__current = TableEntry(name)
self.__current.closes = attrs.get("closes", "").split()
- if attrs.has_key("outputname"):
+ if "outputname" in attrs:
self.__current.outputname = attrs.get("outputname")
def end_macro(self):
name = self.__current.name
- if self.__table.has_key(name):
+ if name in self.__table:
raise ValueError("name %r already in use" % (name,))
self.__table[name] = self.__current
self.__current = None