diff options
Diffstat (limited to 'Doc/tools')
-rwxr-xr-x | Doc/tools/buildindex.py | 13 | ||||
-rw-r--r-- | Doc/tools/custlib.py | 16 | ||||
-rwxr-xr-x | Doc/tools/getversioninfo | 2 | ||||
-rw-r--r-- | Doc/tools/keywords.py | 4 | ||||
-rw-r--r-- | Doc/tools/listmodules.py | 5 | ||||
-rwxr-xr-x | Doc/tools/mkackshtml | 2 | ||||
-rwxr-xr-x | Doc/tools/mkhowto | 12 | ||||
-rwxr-xr-x | Doc/tools/mkmodindex | 6 | ||||
-rw-r--r-- | Doc/tools/prechm.py | 20 | ||||
-rw-r--r-- | Doc/tools/refcounts.py | 9 | ||||
-rwxr-xr-x | Doc/tools/sgmlconv/docfixer.py | 14 | ||||
-rwxr-xr-x | Doc/tools/sgmlconv/esis2sgml.py | 8 | ||||
-rw-r--r-- | Doc/tools/sgmlconv/esistools.py | 8 | ||||
-rwxr-xr-x | Doc/tools/sgmlconv/latex2esis.py | 6 | ||||
-rw-r--r-- | Doc/tools/undoc_symbols.py | 5 |
15 files changed, 66 insertions, 64 deletions
diff --git a/Doc/tools/buildindex.py b/Doc/tools/buildindex.py index 5870462..8b24cc5 100755 --- a/Doc/tools/buildindex.py +++ b/Doc/tools/buildindex.py @@ -37,6 +37,15 @@ class Node: # build up the text self.text = split_entry_text(str) self.key = split_entry_key(str) + + def __eq__(self, other): + return cmp(self, other) == 0 + + def __lt__(self, other): + return cmp(self, other) == -1 + + def __gt__(self, other): + return cmp(self, other) == 1 def __cmp__(self, other): """Comparison operator includes sequence number, for use with @@ -380,8 +389,8 @@ def main(): sys.stderr.write("\n%s: %d index nodes" % (program, num_nodes)) else: open(ofn, "w").write(html) - print - print "%s: %d index nodes" % (program, num_nodes) + print() + print("%s: %d index nodes" % (program, num_nodes)) if __name__ == "__main__": diff --git a/Doc/tools/custlib.py b/Doc/tools/custlib.py index 15f07ba..8224b2c 100644 --- a/Doc/tools/custlib.py +++ b/Doc/tools/custlib.py @@ -31,7 +31,7 @@ for dir in sys.path: modules[base.lower()] = base # Minor oddity: the types module is documented in libtypes2.tex -if modules.has_key('types'): +if 'types' in modules: del modules['types'] modules['types2'] = None @@ -44,8 +44,8 @@ for file in filelist: modname = file[3:-4] docs[modname] = modname -mlist = modules.keys() -mlist = filter(lambda x, docs=docs: docs.has_key(x), mlist) +mlist = list(modules.keys()) +mlist = filter(lambda x, docs=docs: x in docs, mlist) mlist.sort() mlist = map(lambda x, docs=docs: docs[x], mlist) @@ -55,7 +55,7 @@ modules = mlist # Write the boilerplate # XXX should be fancied up. -print """\documentstyle[twoside,11pt,myformat]{report} +print("""\documentstyle[twoside,11pt,myformat]{report} \\title{Python Library Reference} \\input{boilerplate} \\makeindex % tell \\index to actually write the .idx file @@ -68,11 +68,11 @@ print """\documentstyle[twoside,11pt,myformat]{report} \\end{abstract} \\pagebreak {\\parskip = 0mm \\tableofcontents} -\\pagebreak\\pagenumbering{arabic}""" +\\pagebreak\\pagenumbering{arabic}""") for modname in mlist: - print "\\input{lib%s}" % (modname,) + print("\\input{lib%s}" % (modname,)) # Write the end -print """\\input{custlib.ind} % Index -\\end{document}""" +print("""\\input{custlib.ind} % Index +\\end{document}""") diff --git a/Doc/tools/getversioninfo b/Doc/tools/getversioninfo index d22c16d..c1998d5 100755 --- a/Doc/tools/getversioninfo +++ b/Doc/tools/getversioninfo @@ -68,4 +68,4 @@ write_file(patchlevel_tex, "\\setshortversion{%s}\n" % (release, releaseinfo, shortversion)) -print release + releaseinfo +print(release + releaseinfo) diff --git a/Doc/tools/keywords.py b/Doc/tools/keywords.py index 3344021..f9e4b03 100644 --- a/Doc/tools/keywords.py +++ b/Doc/tools/keywords.py @@ -21,5 +21,5 @@ ncols = 5 nrows = (len(l)+ncols-1)/ncols for i in range(nrows): for j in range(i, len(l), nrows): - print l[j].ljust(10), - print + print(l[j].ljust(10), end=' ') + print() diff --git a/Doc/tools/listmodules.py b/Doc/tools/listmodules.py index 5f3ea02..8acdf43 100644 --- a/Doc/tools/listmodules.py +++ b/Doc/tools/listmodules.py @@ -40,8 +40,7 @@ def main(): for p in path: modules.update(getmodules(p)) - keys = modules.keys() - keys.sort() + keys = sorted(modules.keys()) # filter out known test packages def cb(m): @@ -79,7 +78,7 @@ def main(): if out is not sys.stdout: out.close() - print out.name, "ok (%d modules)" % len(modules) + print(out.name, "ok (%d modules)" % len(modules)) def getmodules(p): # get modules in a given directory diff --git a/Doc/tools/mkackshtml b/Doc/tools/mkackshtml index 2c79f5e..b5fe7ba 100755 --- a/Doc/tools/mkackshtml +++ b/Doc/tools/mkackshtml @@ -26,7 +26,7 @@ def main(): options.variables["title"] = "Acknowledgements" options.parse(sys.argv[1:]) names = collect(sys.stdin) - percol = (len(names) + options.columns - 1) / options.columns + percol = (len(names) + options.columns - 1) // options.columns colnums = [] for i in range(options.columns): colnums.append(percol*i) diff --git a/Doc/tools/mkhowto b/Doc/tools/mkhowto index 02a215d..fa259e0 100755 --- a/Doc/tools/mkhowto +++ b/Doc/tools/mkhowto @@ -65,11 +65,11 @@ PYTHON_BINARY = "python" def usage(options, file): - print >>file, __doc__ % options + print(__doc__ % options, file=file) def error(options, message, err=2): - print >>sys.stderr, message - print >>sys.stderr + print(message, file=sys.stderr) + print(file=sys.stderr) usage(options, sys.stderr) sys.exit(2) @@ -132,7 +132,7 @@ class Options: try: return getattr(self, key) except AttributeError: - raise KeyError, key + raise KeyError(key) def parse(self, args): opts, args = getopt.getopt(args, "Hi:a:s:lDkqr:", @@ -289,7 +289,7 @@ class Job: if not imgs: self.warning( "Could not locate support images of type %s." - % `self.options.image_type`) + % repr(self.options.image_type)) for fn in imgs: new_fn = os.path.join(self.builddir, os.path.basename(fn)) shutil.copyfile(fn, new_fn) @@ -534,7 +534,7 @@ class Job: def message(self, msg): msg = "+++ " + msg if not self.options.quiet: - print msg + print(msg) self.log(msg + "\n") def warning(self, msg): diff --git a/Doc/tools/mkmodindex b/Doc/tools/mkmodindex index 8e869f9..cdc9d42 100755 --- a/Doc/tools/mkmodindex +++ b/Doc/tools/mkmodindex @@ -49,7 +49,7 @@ class IndexOptions(support.Options): def usage(self): program = os.path.basename(sys.argv[0]) - print __doc__ % {"program": program} + print(__doc__ % {"program": program}) links = [ ('author', 'acks.html', 'Acknowledgements'), @@ -143,8 +143,8 @@ def main(): if options.outputfile == "-": sys.stderr.write("%s: %d index nodes\n" % (program, num_nodes)) else: - print - print "%s: %d index nodes" % (program, num_nodes) + print() + print("%s: %d index nodes" % (program, num_nodes)) PLAT_DISCUSS = """ diff --git a/Doc/tools/prechm.py b/Doc/tools/prechm.py index db1f965..b24eea0 100644 --- a/Doc/tools/prechm.py +++ b/Doc/tools/prechm.py @@ -413,7 +413,7 @@ def content(path, contentpage, output): def do_index(library, output): output.write('<UL>\n') for book in library: - print '\t', book.title, '-', book.indexpage + print('\t', book.title, '-', book.indexpage) if book.indexpage: index(book.directory, book.indexpage, output) output.write('</UL>\n') @@ -421,7 +421,7 @@ def do_index(library, output): def do_content(library, version, output): output.write(contents_header) for book in library: - print '\t', book.title, '-', book.firstpage + print('\t', book.title, '-', book.firstpage) path = book.directory + "/" + book.firstpage output.write('<LI>') output.write(object_sitemap % (book.title, path)) @@ -449,12 +449,12 @@ def openfile(file): try: p = open(file, "w") except IOError as msg: - print file, ":", msg + print(file, ":", msg) sys.exit(1) return p def usage(): - print usage_mode + print(usage_mode) sys.exit(0) def do_it(args = None): @@ -467,7 +467,7 @@ def do_it(args = None): try: optlist, args = getopt.getopt(args, 'ckpv:') except getopt.error as msg: - print msg + print(msg) usage() if not args or len(args) > 1: @@ -487,15 +487,15 @@ def do_it(args = None): if not (('-p','') in optlist): fname = arch + '.stp' f = openfile(fname) - print "Building stoplist", fname, "..." + print("Building stoplist", fname, "...") words = stop_list.split() words.sort() for word in words: - print >> f, word + print(word, file=f) f.close() f = openfile(arch + '.hhp') - print "Building Project..." + print("Building Project...") do_project(library, f, arch, version) if version == '2.0.0': for image in os.listdir('icons'): @@ -505,13 +505,13 @@ def do_it(args = None): if not (('-c','') in optlist): f = openfile(arch + '.hhc') - print "Building Table of Content..." + print("Building Table of Content...") do_content(library, version, f) f.close() if not (('-k','') in optlist): f = openfile(arch + '.hhk') - print "Building Index..." + print("Building Index...") do_index(library, f) f.close() diff --git a/Doc/tools/refcounts.py b/Doc/tools/refcounts.py index ccfc8c6..9efb073 100644 --- a/Doc/tools/refcounts.py +++ b/Doc/tools/refcounts.py @@ -69,24 +69,23 @@ class Entry: def dump(d): """Dump the data in the 'canonical' format, with functions in sorted order.""" - items = d.items() - items.sort() + items = sorted(d.items()) first = 1 for k, entry in items: if first: first = 0 else: - print + print() s = entry.name + ":%s:%s:%s:" if entry.result_refs is None: r = "" else: r = entry.result_refs - print s % (entry.result_type, "", r) + print(s % (entry.result_type, "", r)) for t, n, r in entry.args: if r is None: r = "" - print s % (t, n, r) + print(s % (t, n, r)) def main(): 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 diff --git a/Doc/tools/undoc_symbols.py b/Doc/tools/undoc_symbols.py index 782ab6c..14cb941 100644 --- a/Doc/tools/undoc_symbols.py +++ b/Doc/tools/undoc_symbols.py @@ -80,11 +80,10 @@ def print_undoc_symbols(prefix, docdir, incdir): fp = os.popen("ctags -IPyAPI_FUNC -IPy_GCC_ATTRIBUTE --c-types=%s -f - %s" % (TAG_KINDS, incfiles)) dict = findnames(fp, prefix) - names = dict.keys() - names.sort() + names = sorted(dict.keys()) for name in names: if not re.search("%s\\W" % name, docs): - print dict[name], name + print(dict[name], name) if __name__ == '__main__': srcdir = os.path.dirname(sys.argv[0]) |