diff options
author | Fred Drake <fdrake@acm.org> | 2008-05-17 22:02:32 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2008-05-17 22:02:32 (GMT) |
commit | 3c50ea4303ad58785e7f5058cdd353c6d0140ee4 (patch) | |
tree | 127214cdbbaac0fad36eb75b08e7868a666283c8 /Lib | |
parent | 9b020c784c3a1ec3d412bca1ffed2d24232b0a54 (diff) | |
download | cpython-3c50ea4303ad58785e7f5058cdd353c6d0140ee4.zip cpython-3c50ea4303ad58785e7f5058cdd353c6d0140ee4.tar.gz cpython-3c50ea4303ad58785e7f5058cdd353c6d0140ee4.tar.bz2 |
rename HTMLParser to html.parser and htmlentitydefs to html.entities;
includes merge of trunk revision 63432
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/html/__init__.py | 1 | ||||
-rw-r--r-- | Lib/html/entities.py (renamed from Lib/htmlentitydefs.py) | 0 | ||||
-rw-r--r-- | Lib/html/parser.py (renamed from Lib/HTMLParser.py) | 13 | ||||
-rw-r--r-- | Lib/htmllib.py | 2 | ||||
-rw-r--r-- | Lib/test/test_codeccallbacks.py | 4 | ||||
-rw-r--r-- | Lib/test/test_multibytecodec_support.py | 2 | ||||
-rw-r--r-- | Lib/test/test_sundry.py | 2 |
7 files changed, 13 insertions, 11 deletions
diff --git a/Lib/html/__init__.py b/Lib/html/__init__.py new file mode 100644 index 0000000..196d378 --- /dev/null +++ b/Lib/html/__init__.py @@ -0,0 +1 @@ +# This directory is a Python package. diff --git a/Lib/htmlentitydefs.py b/Lib/html/entities.py index e2b7bf1..e2b7bf1 100644 --- a/Lib/htmlentitydefs.py +++ b/Lib/html/entities.py diff --git a/Lib/HTMLParser.py b/Lib/html/parser.py index 9979195..352a788 100644 --- a/Lib/HTMLParser.py +++ b/Lib/html/parser.py @@ -372,16 +372,17 @@ class HTMLParser(_markupbase.ParserBase): c = int(s) return chr(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':"'"} - for k, v in htmlentitydefs.name2codepoint.items(): - entitydefs[k] = chr(v) + for k, v in html.entities.name2codepoint.items(): + 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) diff --git a/Lib/htmllib.py b/Lib/htmllib.py index 88e1df5..a580006 100644 --- a/Lib/htmllib.py +++ b/Lib/htmllib.py @@ -24,7 +24,7 @@ class HTMLParser(sgmllib.SGMLParser): """ - from htmlentitydefs import entitydefs + from html.entities import entitydefs def __init__(self, formatter, verbose=0): """Creates an instance of the HTMLParser class. diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py index 12eb068..64d1645 100644 --- a/Lib/test/test_codeccallbacks.py +++ b/Lib/test/test_codeccallbacks.py @@ -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 @@ class CodecCallbackTest(unittest.TestCase): l = [] for c in exc.object[exc.start:exc.end]: try: - l.append("&%s;" % htmlentitydefs.codepoint2name[ord(c)]) + l.append("&%s;" % html.entities.codepoint2name[ord(c)]) except KeyError: l.append("&#%d;" % ord(c)) return ("".join(l), exc.end) diff --git a/Lib/test/test_multibytecodec_support.py b/Lib/test/test_multibytecodec_support.py index 48e9089..5508c9d 100644 --- a/Lib/test/test_multibytecodec_support.py +++ b/Lib/test/test_multibytecodec_support.py @@ -74,7 +74,7 @@ class TestBase: if self.has_iso10646: return - from htmlentitydefs import codepoint2name + from html.entities import codepoint2name def xmlcharnamereplace(exc): if not isinstance(exc, UnicodeEncodeError): diff --git a/Lib/test/test_sundry.py b/Lib/test/test_sundry.py index dd81e5b..1b6069d 100644 --- a/Lib/test/test_sundry.py +++ b/Lib/test/test_sundry.py @@ -48,7 +48,7 @@ class TestUntestedModules(unittest.TestCase): import encodings import formatter import getpass - import htmlentitydefs + import html.entities import imghdr import keyword import linecache |