Skip to content

Commit c4dd677

Browse files
committed
Move a whole bunch of private modules to be underscore prefixed
This moves: html5lib.ihatexml -> html5lib._ihatexml html5lib.inputstream -> html5lib._inputstream html5lib.tokenizer -> html5lib._tokenizer html5lib.trie -> html5lib._trie html5lib.utils -> html5lib._utils
1 parent 8db5828 commit c4dd677

21 files changed

+82
-82
lines changed
File renamed without changes.

html5lib/inputstream.py renamed to html5lib/_inputstream.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from .constants import EOF, spaceCharacters, asciiLetters, asciiUppercase
1212
from .constants import ReparseException
13-
from . import utils
13+
from . import _utils
1414

1515
from io import StringIO
1616

@@ -28,7 +28,7 @@
2828

2929
invalid_unicode_no_surrogate = "[\u0001-\u0008\u000B\u000E-\u001F\u007F-\u009F\uFDD0-\uFDEF\uFFFE\uFFFF\U0001FFFE\U0001FFFF\U0002FFFE\U0002FFFF\U0003FFFE\U0003FFFF\U0004FFFE\U0004FFFF\U0005FFFE\U0005FFFF\U0006FFFE\U0006FFFF\U0007FFFE\U0007FFFF\U0008FFFE\U0008FFFF\U0009FFFE\U0009FFFF\U000AFFFE\U000AFFFF\U000BFFFE\U000BFFFF\U000CFFFE\U000CFFFF\U000DFFFE\U000DFFFF\U000EFFFE\U000EFFFF\U000FFFFE\U000FFFFF\U0010FFFE\U0010FFFF]" # noqa
3030

31-
if utils.supports_lone_surrogates:
31+
if _utils.supports_lone_surrogates:
3232
# Use one extra step of indirection and create surrogates with
3333
# eval. Not using this indirection would introduce an illegal
3434
# unicode literal on platforms not supporting such lone
@@ -176,7 +176,7 @@ def __init__(self, source):
176176
177177
"""
178178

179-
if not utils.supports_lone_surrogates:
179+
if not _utils.supports_lone_surrogates:
180180
# Such platforms will have already checked for such
181181
# surrogate errors, so no need to do this checking.
182182
self.reportCharacterErrors = None
@@ -304,9 +304,9 @@ def characterErrorsUCS2(self, data):
304304
codepoint = ord(match.group())
305305
pos = match.start()
306306
# Pretty sure there should be endianness issues here
307-
if utils.isSurrogatePair(data[pos:pos + 2]):
307+
if _utils.isSurrogatePair(data[pos:pos + 2]):
308308
# We have a surrogate pair!
309-
char_val = utils.surrogatePairToCodepoint(data[pos:pos + 2])
309+
char_val = _utils.surrogatePairToCodepoint(data[pos:pos + 2])
310310
if char_val in non_bmp_invalid_codepoints:
311311
self.errors.append("invalid-codepoint")
312312
skip = True

html5lib/tokenizer.py renamed to html5lib/_tokenizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
from .constants import tokenTypes, tagTokenTypes
1212
from .constants import replacementCharacters
1313

14-
from .inputstream import HTMLInputStream
14+
from ._inputstream import HTMLInputStream
1515

16-
from .trie import Trie
16+
from ._trie import Trie
1717

1818
entitiesTrie = Trie(entities)
1919

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

html5lib/html5parser.py

Lines changed: 45 additions & 45 deletions
Large diffs are not rendered by default.

html5lib/serializer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from .constants import voidElements, booleanAttributes, spaceCharacters
99
from .constants import rcdataElements, entities, xmlEntities
10-
from . import treewalkers, utils
10+
from . import treewalkers, _utils
1111
from xml.sax.saxutils import escape
1212

1313
spaceCharacters = "".join(spaceCharacters)
@@ -33,7 +33,7 @@
3333
continue
3434
if v != "&":
3535
if len(v) == 2:
36-
v = utils.surrogatePairToCodepoint(v)
36+
v = _utils.surrogatePairToCodepoint(v)
3737
else:
3838
v = ord(v)
3939
if v not in encode_entity_map or k.islower():
@@ -51,8 +51,8 @@ def htmlentityreplace_errors(exc):
5151
skip = False
5252
continue
5353
index = i + exc.start
54-
if utils.isSurrogatePair(exc.object[index:min([exc.end, index + 2])]):
55-
codepoint = utils.surrogatePairToCodepoint(exc.object[index:index + 2])
54+
if _utils.isSurrogatePair(exc.object[index:min([exc.end, index + 2])]):
55+
codepoint = _utils.surrogatePairToCodepoint(exc.object[index:index + 2])
5656
skip = True
5757
else:
5858
codepoint = ord(c)

0 commit comments

Comments
 (0)