[Python-3000-checkins] r54469 - in python/branches/p3yk/Doc/tools: buildindex.py custlib.py getversioninfo keywords.py listmodules.py mkackshtml mkhowto mkmodindex prechm.py refcounts.py sgmlconv/docfixer.py sgmlconv/esis2sgml.py sgmlconv/esistools.py sgmlconv/latex2esis.py undoc_symbols.py

collin.winter python-3000-checkins at python.org
Wed Mar 21 03:11:51 CET 2007


Author: collin.winter
Date: Wed Mar 21 03:11:39 2007
New Revision: 54469

Modified:
   python/branches/p3yk/Doc/tools/buildindex.py
   python/branches/p3yk/Doc/tools/custlib.py
   python/branches/p3yk/Doc/tools/getversioninfo
   python/branches/p3yk/Doc/tools/keywords.py
   python/branches/p3yk/Doc/tools/listmodules.py
   python/branches/p3yk/Doc/tools/mkackshtml
   python/branches/p3yk/Doc/tools/mkhowto
   python/branches/p3yk/Doc/tools/mkmodindex
   python/branches/p3yk/Doc/tools/prechm.py
   python/branches/p3yk/Doc/tools/refcounts.py
   python/branches/p3yk/Doc/tools/sgmlconv/docfixer.py
   python/branches/p3yk/Doc/tools/sgmlconv/esis2sgml.py
   python/branches/p3yk/Doc/tools/sgmlconv/esistools.py
   python/branches/p3yk/Doc/tools/sgmlconv/latex2esis.py
   python/branches/p3yk/Doc/tools/undoc_symbols.py
Log:
Run 2to3 over Doc/tools/.

Modified: python/branches/p3yk/Doc/tools/buildindex.py
==============================================================================
--- python/branches/p3yk/Doc/tools/buildindex.py	(original)
+++ python/branches/p3yk/Doc/tools/buildindex.py	Wed Mar 21 03:11:39 2007
@@ -37,6 +37,15 @@
         # 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 @@
         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__":

Modified: python/branches/p3yk/Doc/tools/custlib.py
==============================================================================
--- python/branches/p3yk/Doc/tools/custlib.py	(original)
+++ python/branches/p3yk/Doc/tools/custlib.py	Wed Mar 21 03:11:39 2007
@@ -31,7 +31,7 @@
         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 @@
     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 @@
 
 # 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 @@
 \\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}""")

Modified: python/branches/p3yk/Doc/tools/getversioninfo
==============================================================================
--- python/branches/p3yk/Doc/tools/getversioninfo	(original)
+++ python/branches/p3yk/Doc/tools/getversioninfo	Wed Mar 21 03:11:39 2007
@@ -68,4 +68,4 @@
            "\\setshortversion{%s}\n"
            % (release, releaseinfo, shortversion))
 
-print release + releaseinfo
+print(release + releaseinfo)

Modified: python/branches/p3yk/Doc/tools/keywords.py
==============================================================================
--- python/branches/p3yk/Doc/tools/keywords.py	(original)
+++ python/branches/p3yk/Doc/tools/keywords.py	Wed Mar 21 03:11:39 2007
@@ -21,5 +21,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()

Modified: python/branches/p3yk/Doc/tools/listmodules.py
==============================================================================
--- python/branches/p3yk/Doc/tools/listmodules.py	(original)
+++ python/branches/p3yk/Doc/tools/listmodules.py	Wed Mar 21 03:11:39 2007
@@ -40,8 +40,7 @@
     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 @@
 
     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

Modified: python/branches/p3yk/Doc/tools/mkackshtml
==============================================================================
--- python/branches/p3yk/Doc/tools/mkackshtml	(original)
+++ python/branches/p3yk/Doc/tools/mkackshtml	Wed Mar 21 03:11:39 2007
@@ -26,7 +26,7 @@
     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)

Modified: python/branches/p3yk/Doc/tools/mkhowto
==============================================================================
--- python/branches/p3yk/Doc/tools/mkhowto	(original)
+++ python/branches/p3yk/Doc/tools/mkhowto	Wed Mar 21 03:11:39 2007
@@ -65,11 +65,11 @@
 
 
 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 @@
         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 @@
                 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 @@
     def message(self, msg):
         msg = "+++ " + msg
         if not self.options.quiet:
-            print msg
+            print(msg)
         self.log(msg + "\n")
 
     def warning(self, msg):

Modified: python/branches/p3yk/Doc/tools/mkmodindex
==============================================================================
--- python/branches/p3yk/Doc/tools/mkmodindex	(original)
+++ python/branches/p3yk/Doc/tools/mkmodindex	Wed Mar 21 03:11:39 2007
@@ -49,7 +49,7 @@
 
     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 @@
     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 = """

Modified: python/branches/p3yk/Doc/tools/prechm.py
==============================================================================
--- python/branches/p3yk/Doc/tools/prechm.py	(original)
+++ python/branches/p3yk/Doc/tools/prechm.py	Wed Mar 21 03:11:39 2007
@@ -413,7 +413,7 @@
 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_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 @@
     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 @@
     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 @@
     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 @@
 
     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()
 

Modified: python/branches/p3yk/Doc/tools/refcounts.py
==============================================================================
--- python/branches/p3yk/Doc/tools/refcounts.py	(original)
+++ python/branches/p3yk/Doc/tools/refcounts.py	Wed Mar 21 03:11:39 2007
@@ -69,24 +69,23 @@
 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():

Modified: python/branches/p3yk/Doc/tools/sgmlconv/docfixer.py
==============================================================================
--- python/branches/p3yk/Doc/tools/sgmlconv/docfixer.py	(original)
+++ python/branches/p3yk/Doc/tools/sgmlconv/docfixer.py	Wed Mar 21 03:11:39 2007
@@ -210,8 +210,7 @@
     # 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 @@
             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 @@
     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 @@
             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 @@
         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 @@
     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
     #

Modified: python/branches/p3yk/Doc/tools/sgmlconv/esis2sgml.py
==============================================================================
--- python/branches/p3yk/Doc/tools/sgmlconv/esis2sgml.py	(original)
+++ python/branches/p3yk/Doc/tools/sgmlconv/esis2sgml.py	Wed Mar 21 03:11:39 2007
@@ -44,8 +44,7 @@
 
 
 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 @@
             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 @@
             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()

Modified: python/branches/p3yk/Doc/tools/sgmlconv/esistools.py
==============================================================================
--- python/branches/p3yk/Doc/tools/sgmlconv/esistools.py	(original)
+++ python/branches/p3yk/Doc/tools/sgmlconv/esistools.py	Wed Mar 21 03:11:39 2007
@@ -29,7 +29,7 @@
             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 @@
             self.setErrorHandler(errorHandler)
 
     def get_empties(self):
-        return self._empties.keys()
+        return list(self._empties.keys())
 
     #
     #  XMLReader interface
@@ -270,7 +270,7 @@
         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 @@
 
     def values(self):
         L = []
-        for value, type in self._attrs.values():
+        for value, type in list(self._attrs.values()):
             L.append(value)
         return L
 

Modified: python/branches/p3yk/Doc/tools/sgmlconv/latex2esis.py
==============================================================================
--- python/branches/p3yk/Doc/tools/sgmlconv/latex2esis.py	(original)
+++ python/branches/p3yk/Doc/tools/sgmlconv/latex2esis.py	Wed Mar 21 03:11:39 2007
@@ -472,7 +472,7 @@
         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 @@
         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

Modified: python/branches/p3yk/Doc/tools/undoc_symbols.py
==============================================================================
--- python/branches/p3yk/Doc/tools/undoc_symbols.py	(original)
+++ python/branches/p3yk/Doc/tools/undoc_symbols.py	Wed Mar 21 03:11:39 2007
@@ -80,11 +80,10 @@
     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])


More information about the Python-3000-checkins mailing list