[Python-checkins] r63432 - in python/trunk: Doc/library/htmllib.rst Doc/library/htmlparser.rst Lib/html/parser.py Lib/htmllib.py Lib/test/test_codeccallbacks.py Lib/test/test_multibytecodec_support.py Lib/test/test_sundry.py

fred.drake python-checkins at python.org
Sat May 17 23:14:05 CEST 2008


Author: fred.drake
Date: Sat May 17 23:14:05 2008
New Revision: 63432

Log:
update references and documentation for modules in the new html package
(http://bugs.python.org/issue2882)


Modified:
   python/trunk/Doc/library/htmllib.rst
   python/trunk/Doc/library/htmlparser.rst
   python/trunk/Lib/html/parser.py
   python/trunk/Lib/htmllib.py
   python/trunk/Lib/test/test_codeccallbacks.py
   python/trunk/Lib/test/test_multibytecodec_support.py
   python/trunk/Lib/test/test_sundry.py

Modified: python/trunk/Doc/library/htmllib.rst
==============================================================================
--- python/trunk/Doc/library/htmllib.rst	(original)
+++ python/trunk/Doc/library/htmllib.rst	Sat May 17 23:14:05 2008
@@ -77,12 +77,12 @@
       Interface definition for transforming an abstract flow of formatting events into
       specific output events on writer objects.
 
-   Module :mod:`HTMLParser`
+   Module :mod:`html.parser`
       Alternate HTML parser that offers a slightly lower-level view of the input, but
       is designed to work with XHTML, and does not implement some of the SGML syntax
       not used in "HTML as deployed" and which isn't legal for XHTML.
 
-   Module :mod:`htmlentitydefs`
+   Module :mod:`html.entities`
       Definition of replacement text for XHTML 1.0  entities.
 
    Module :mod:`sgmllib`
@@ -149,10 +149,10 @@
    :meth:`save_bgn` will raise a :exc:`TypeError` exception.
 
 
-:mod:`htmlentitydefs` --- Definitions of HTML general entities
-==============================================================
+:mod:`html.entities` --- Definitions of HTML general entities
+=============================================================
 
-.. module:: htmlentitydefs
+.. module:: html.entities
    :synopsis: Definitions of HTML general entities.
 .. sectionauthor:: Fred L. Drake, Jr. <fdrake at acm.org>
 

Modified: python/trunk/Doc/library/htmlparser.rst
==============================================================================
--- python/trunk/Doc/library/htmlparser.rst	(original)
+++ python/trunk/Doc/library/htmlparser.rst	Sat May 17 23:14:05 2008
@@ -1,8 +1,8 @@
 
-:mod:`HTMLParser` --- Simple HTML and XHTML parser
-==================================================
+:mod:`html.parser` --- Simple HTML and XHTML parser
+===================================================
 
-.. module:: HTMLParser
+.. module:: html.parser
    :synopsis: A simple parser that can handle HTML and XHTML.
 
 
@@ -22,7 +22,7 @@
 
    The :class:`HTMLParser` class is instantiated without arguments.
 
-   An HTMLParser instance is fed HTML data and calls handler functions when tags
+   An :class:`HTMLParser` instance is fed HTML data and calls handler functions when tags
    begin and end.  The :class:`HTMLParser` class is meant to be overridden by the
    user to provide a desired behavior.
 
@@ -92,8 +92,8 @@
    ``handle_starttag('a', [('href', 'http://www.cwi.nl/')])``.
 
    .. versionchanged:: 2.6
-      All entity references from htmlentitydefs are now replaced in the attribute
-      values.
+      All entity references from :mod:`html.entities` are now replaced in the
+      attribute values.
 
 
 .. method:: HTMLParser.handle_startendtag(tag, attrs)
@@ -171,7 +171,7 @@
 As a basic example, below is a very basic HTML parser that uses the
 :class:`HTMLParser` class to print out tags as they are encountered::
 
-   from HTMLParser import HTMLParser
+   from html.parser import HTMLParser
 
    class MyHTMLParser(HTMLParser):
 

Modified: python/trunk/Lib/html/parser.py
==============================================================================
--- python/trunk/Lib/html/parser.py	(original)
+++ python/trunk/Lib/html/parser.py	Sat May 17 23:14:05 2008
@@ -372,16 +372,17 @@
                     c = int(s)
                 return unichr(c)
             else:
-                # Cannot use name2codepoint directly, because HTMLParser supports apos,
-                # which is not part of HTML 4
-                import htmlentitydefs
+                # Cannot use name2codepoint directly, because HTMLParser
+                # supports apos, which is not part of HTML 4
+                import html.entities
                 if HTMLParser.entitydefs is None:
                     entitydefs = HTMLParser.entitydefs = {'apos':u"'"}
-                    for k, v in htmlentitydefs.name2codepoint.iteritems():
+                    for k, v in html.entities.name2codepoint.iteritems():
                         entitydefs[k] = unichr(v)
                 try:
                     return self.entitydefs[s]
                 except KeyError:
                     return '&'+s+';'
 
-        return re.sub(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));", replaceEntities, s)
+        return re.sub(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));",
+                      replaceEntities, s)

Modified: python/trunk/Lib/htmllib.py
==============================================================================
--- python/trunk/Lib/htmllib.py	(original)
+++ python/trunk/Lib/htmllib.py	Sat May 17 23:14:05 2008
@@ -24,7 +24,7 @@
 
     """
 
-    from htmlentitydefs import entitydefs
+    from html.entities import entitydefs
 
     def __init__(self, formatter, verbose=0):
         """Creates an instance of the HTMLParser class.

Modified: python/trunk/Lib/test/test_codeccallbacks.py
==============================================================================
--- python/trunk/Lib/test/test_codeccallbacks.py	(original)
+++ python/trunk/Lib/test/test_codeccallbacks.py	Sat May 17 23:14:05 2008
@@ -1,5 +1,5 @@
 import test.test_support, unittest
-import sys, codecs, htmlentitydefs, unicodedata
+import sys, codecs, html.entities, unicodedata
 
 class PosReturn:
     # this can be used for configurable callbacks
@@ -86,7 +86,7 @@
             l = []
             for c in exc.object[exc.start:exc.end]:
                 try:
-                    l.append(u"&%s;" % htmlentitydefs.codepoint2name[ord(c)])
+                    l.append(u"&%s;" % html.entities.codepoint2name[ord(c)])
                 except KeyError:
                     l.append(u"&#%d;" % ord(c))
             return (u"".join(l), exc.end)

Modified: python/trunk/Lib/test/test_multibytecodec_support.py
==============================================================================
--- python/trunk/Lib/test/test_multibytecodec_support.py	(original)
+++ python/trunk/Lib/test/test_multibytecodec_support.py	Sat May 17 23:14:05 2008
@@ -64,7 +64,7 @@
         if self.has_iso10646:
             return
 
-        from htmlentitydefs import codepoint2name
+        from html.entities import codepoint2name
 
         def xmlcharnamereplace(exc):
             if not isinstance(exc, UnicodeEncodeError):

Modified: python/trunk/Lib/test/test_sundry.py
==============================================================================
--- python/trunk/Lib/test/test_sundry.py	(original)
+++ python/trunk/Lib/test/test_sundry.py	Sat May 17 23:14:05 2008
@@ -50,7 +50,7 @@
             import encodings
             import formatter
             import getpass
-            import htmlentitydefs
+            import html.entities
             import ihooks
             import imghdr
             import imputil


More information about the Python-checkins mailing list