Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc4dd677

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 parent8db5828 commitc4dd677

21 files changed

+82
-82
lines changed
File renamed without changes.

‎html5lib/inputstream.pyrenamed 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 .constantsimportEOF,spaceCharacters,asciiLetters,asciiUppercase
1212
from .constantsimportReparseException
13-
from .importutils
13+
from .import_utils
1414

1515
fromioimportStringIO
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-
ifutils.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-
ifnotutils.supports_lone_surrogates:
179+
ifnot_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-
ifutils.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
ifchar_valinnon_bmp_invalid_codepoints:
311311
self.errors.append("invalid-codepoint")
312312
skip=True

‎html5lib/tokenizer.pyrenamed to‎html5lib/_tokenizer.py

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

14-
from .inputstreamimportHTMLInputStream
14+
from ._inputstreamimportHTMLInputStream
1515

16-
from .trieimportTrie
16+
from ._trieimportTrie
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 .constantsimportvoidElements,booleanAttributes,spaceCharacters
99
from .constantsimportrcdataElements,entities,xmlEntities
10-
from .importtreewalkers,utils
10+
from .importtreewalkers,_utils
1111
fromxml.sax.saxutilsimportescape
1212

1313
spaceCharacters="".join(spaceCharacters)
@@ -33,7 +33,7 @@
3333
continue
3434
ifv!="&":
3535
iflen(v)==2:
36-
v=utils.surrogatePairToCodepoint(v)
36+
v=_utils.surrogatePairToCodepoint(v)
3737
else:
3838
v=ord(v)
3939
ifvnotinencode_entity_mapork.islower():
@@ -51,8 +51,8 @@ def htmlentityreplace_errors(exc):
5151
skip=False
5252
continue
5353
index=i+exc.start
54-
ifutils.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)

‎html5lib/tests/test_encoding.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
importpytest
66

77
from .supportimportget_data_files,test_dir,errorMessage,TestDataas_TestData
8-
fromhtml5libimportHTMLParser,inputstream
8+
fromhtml5libimportHTMLParser,_inputstream
99

1010

1111
deftest_basic_prescan_length():
1212
data="<title>Caf\u00E9</title><!--a--><meta charset='utf-8'>".encode('utf-8')
1313
pad=1024-len(data)+1
1414
data=data.replace(b"-a-",b"-"+ (b"a"*pad)+b"-")
1515
assertlen(data)==1024# Sanity
16-
stream=inputstream.HTMLBinaryInputStream(data,useChardet=False)
16+
stream=_inputstream.HTMLBinaryInputStream(data,useChardet=False)
1717
assert'utf-8'==stream.charEncoding[0].name
1818

1919

@@ -22,7 +22,7 @@ def test_parser_reparse():
2222
pad=10240-len(data)+1
2323
data=data.replace(b"-a-",b"-"+ (b"a"*pad)+b"-")
2424
assertlen(data)==10240# Sanity
25-
stream=inputstream.HTMLBinaryInputStream(data,useChardet=False)
25+
stream=_inputstream.HTMLBinaryInputStream(data,useChardet=False)
2626
assert'windows-1252'==stream.charEncoding[0].name
2727
p=HTMLParser(namespaceHTMLElements=False)
2828
doc=p.parse(data,useChardet=False)
@@ -47,7 +47,7 @@ def test_parser_reparse():
4747
("windows-1252",b"", {}),
4848
])
4949
deftest_parser_args(expected,data,kwargs):
50-
stream=inputstream.HTMLBinaryInputStream(data,useChardet=False,**kwargs)
50+
stream=_inputstream.HTMLBinaryInputStream(data,useChardet=False,**kwargs)
5151
assertexpected==stream.charEncoding[0].name
5252
p=HTMLParser()
5353
p.parse(data,useChardet=False,**kwargs)
@@ -85,7 +85,7 @@ def runParserEncodingTest(data, encoding):
8585

8686

8787
defrunPreScanEncodingTest(data,encoding):
88-
stream=inputstream.HTMLBinaryInputStream(data,useChardet=False)
88+
stream=_inputstream.HTMLBinaryInputStream(data,useChardet=False)
8989
encoding=encoding.lower().decode("ascii")
9090

9191
# Very crude way to ignore irrelevant tests
@@ -111,6 +111,6 @@ def test_encoding():
111111
else:
112112
deftest_chardet():
113113
withopen(os.path.join(test_dir,"encoding","chardet","test_big5.txt"),"rb")asfp:
114-
encoding=inputstream.HTMLInputStream(fp.read()).charEncoding
114+
encoding=_inputstream.HTMLInputStream(fp.read()).charEncoding
115115
assertencoding[0].name=="big5"
116116
# pylint:enable=wrong-import-position

‎html5lib/tests/test_stream.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
importsix
1212
fromsix.movesimporthttp_client,urllib
1313

14-
fromhtml5lib.inputstreamimport (BufferedStream,HTMLInputStream,
15-
HTMLUnicodeInputStream,HTMLBinaryInputStream)
16-
fromhtml5lib.utilsimportsupports_lone_surrogates
14+
fromhtml5lib._inputstreamimport (BufferedStream,HTMLInputStream,
15+
HTMLUnicodeInputStream,HTMLBinaryInputStream)
16+
fromhtml5lib._utilsimportsupports_lone_surrogates
1717

1818

1919
deftest_basic():

‎html5lib/tests/tokenizer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
importpytest
99
fromsiximportunichr
1010

11-
fromhtml5lib.tokenizerimportHTMLTokenizer
12-
fromhtml5libimportconstants,utils
11+
fromhtml5lib._tokenizerimportHTMLTokenizer
12+
fromhtml5libimportconstants,_utils
1313

1414

1515
classTokenizerTestParser(object):
@@ -156,7 +156,7 @@ def repl(m):
156156
exceptValueError:
157157
# This occurs when unichr throws ValueError, which should
158158
# only be for a lone-surrogate.
159-
ifutils.supports_lone_surrogates:
159+
if_utils.supports_lone_surrogates:
160160
raise
161161
returnNone
162162

‎html5lib/treebuilders/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
from __future__importabsolute_import,division,unicode_literals
3030

31-
from ..utilsimportdefault_etree
31+
from .._utilsimportdefault_etree
3232

3333
treeBuilderCache= {}
3434

‎html5lib/treebuilders/dom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .importbase
99
from ..importconstants
1010
from ..constantsimportnamespaces
11-
from ..utilsimportmoduleFactoryFactory
11+
from .._utilsimportmoduleFactoryFactory
1212

1313

1414
defgetDomBuilder(DomImplementation):

‎html5lib/treebuilders/etree.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
importre
77

88
from .importbase
9-
from ..importihatexml
9+
from ..import_ihatexml
1010
from ..importconstants
1111
from ..constantsimportnamespaces
12-
from ..utilsimportmoduleFactoryFactory
12+
from .._utilsimportmoduleFactoryFactory
1313

1414
tag_regexp=re.compile("{([^}]*)}(.*)")
1515

@@ -259,7 +259,7 @@ def serializeElement(element, indent=0):
259259
deftostring(element):# pylint:disable=unused-variable
260260
"""Serialize an element and its child nodes to a string"""
261261
rv= []
262-
filter=ihatexml.InfosetFilter()
262+
filter=_ihatexml.InfosetFilter()
263263

264264
defserializeElement(element):
265265
ifisinstance(element,ElementTree.ElementTree):

‎html5lib/treebuilders/etree_lxml.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from ..constantsimportDataLossWarning
2121
from ..importconstants
2222
from .importetreeasetree_builders
23-
from ..importihatexml
23+
from ..import_ihatexml
2424

2525
importlxml.etreeasetree
2626

@@ -54,7 +54,7 @@ def _getChildNodes(self):
5454

5555
deftestSerializer(element):
5656
rv= []
57-
infosetFilter=ihatexml.InfosetFilter(preventDoubleDashComments=True)
57+
infosetFilter=_ihatexml.InfosetFilter(preventDoubleDashComments=True)
5858

5959
defserializeElement(element,indent=0):
6060
ifnothasattr(element,"tag"):
@@ -182,7 +182,7 @@ class TreeBuilder(base.TreeBuilder):
182182

183183
def__init__(self,namespaceHTMLElements,fullTree=False):
184184
builder=etree_builders.getETreeModule(etree,fullTree=fullTree)
185-
infosetFilter=self.infosetFilter=ihatexml.InfosetFilter(preventDoubleDashComments=True)
185+
infosetFilter=self.infosetFilter=_ihatexml.InfosetFilter(preventDoubleDashComments=True)
186186
self.namespaceHTMLElements=namespaceHTMLElements
187187

188188
classAttributes(dict):

‎html5lib/treewalkers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from __future__importabsolute_import,division,unicode_literals
1212

1313
from ..importconstants
14-
from ..utilsimportdefault_etree
14+
from .._utilsimportdefault_etree
1515

1616
__all__= ["getTreeWalker","pprint","dom","etree","genshi","etree_lxml"]
1717

‎html5lib/treewalkers/etree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
fromsiximportstring_types
1414

1515
from .importbase
16-
from ..utilsimportmoduleFactoryFactory
16+
from .._utilsimportmoduleFactoryFactory
1717

1818
tag_regexp=re.compile("{([^}]*)}(.*)")
1919

‎html5lib/treewalkers/etree_lxml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from .importbase
88

9-
from ..importihatexml
9+
from ..import_ihatexml
1010

1111

1212
defensure_str(s):
@@ -132,7 +132,7 @@ def __init__(self, tree):
132132
self.fragmentChildren=set()
133133
tree=Root(tree)
134134
base.NonRecursiveTreeWalker.__init__(self,tree)
135-
self.filter=ihatexml.InfosetFilter()
135+
self.filter=_ihatexml.InfosetFilter()
136136

137137
defgetNodeDetails(self,node):
138138
ifisinstance(node,tuple):# Text node

‎parse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
fromhtml5libimporthtml5parser
1212
fromhtml5libimporttreebuilders,serializer,treewalkers
1313
fromhtml5libimportconstants
14-
fromhtml5libimportutils
14+
fromhtml5libimport_utils
1515

1616

1717
defparse():
@@ -116,7 +116,7 @@ def printOutput(parser, document, opts):
116116
importlxml.etree
117117
sys.stdout.write(lxml.etree.tostring(document,encoding="unicode"))
118118
eliftb=="etree":
119-
sys.stdout.write(utils.default_etree.tostring(document,encoding="unicode"))
119+
sys.stdout.write(_utils.default_etree.tostring(document,encoding="unicode"))
120120
elifopts.tree:
121121
ifnothasattr(document,'__getitem__'):
122122
document= [document]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp