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

Commit1ce889f

Browse files
committed
remove six
1 parent29d3072 commit1ce889f

23 files changed

+46
-100
lines changed

‎debug-info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"maxsize":sys.maxsize
1212
}
1313

14-
search_modules= ["chardet","genshi","html5lib","lxml","six"]
14+
search_modules= ["chardet","genshi","html5lib","lxml"]
1515
found_modules= []
1616

1717
forminsearch_modules:

‎html5lib/_inputstream.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
fromsiximporttext_type
3-
fromsix.movesimporthttp_client,urllib
2+
importhttp.client
3+
importurllib.response
44

55
importcodecs
66
importre
@@ -124,10 +124,10 @@ def _readFromBuffer(self, bytes):
124124
defHTMLInputStream(source,**kwargs):
125125
# Work around Python bug #20007: read(0) closes the connection.
126126
# http://bugs.python.org/issue20007
127-
if (isinstance(source,http_client.HTTPResponse)or
127+
if (isinstance(source,http.client.HTTPResponse)or
128128
# Also check for addinfourl wrapping HTTPResponse
129129
(isinstance(source,urllib.response.addbase)and
130-
isinstance(source.fp,http_client.HTTPResponse))):
130+
isinstance(source.fp,http.client.HTTPResponse))):
131131
isUnicode=False
132132
elifhasattr(source,"read"):
133133
isUnicode=isinstance(source.read(0),text_type)

‎html5lib/_tokenizer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11

2-
fromsiximportunichraschr
3-
42
fromcollectionsimportdeque,OrderedDict
53
fromsysimportversion_info
64

‎html5lib/_trie/py.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
fromsiximporttext_type
2-
31
frombisectimportbisect_left
42

53
from ._baseimportTrieasABCTrie
64

75

86
classTrie(ABCTrie):
97
def__init__(self,data):
10-
ifnotall(isinstance(x,text_type)forxindata.keys()):
8+
ifnotall(isinstance(x,str)forxindata.keys()):
119
raiseTypeError("All keys must be strings")
1210

1311
self._data=data

‎html5lib/_utils.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,7 @@
33

44
fromcollections.abcimportMapping
55

6-
fromsiximporttext_type,PY3
7-
8-
ifPY3:
9-
importxml.etree.ElementTreeasdefault_etree
10-
else:
11-
try:
12-
importxml.etree.ElementTreeasdefault_etree
13-
exceptImportError:
14-
importxml.etree.ElementTreeasdefault_etree
6+
importxml.etree.ElementTreeasdefault_etree
157

168

179
__all__= ["default_etree","MethodDispatcher","isSurrogatePair",
@@ -27,10 +19,10 @@
2719
# escapes.
2820
try:
2921
_x=eval('"\\uD800"')# pylint:disable=eval-used
30-
ifnotisinstance(_x,text_type):
22+
ifnotisinstance(_x,str):
3123
# We need this with u"" because of http://bugs.jython.org/issue2039
3224
_x=eval('u"\\uD800"')# pylint:disable=eval-used
33-
assertisinstance(_x,text_type)
25+
assertisinstance(_x,str)
3426
exceptException:
3527
supports_lone_surrogates=False
3628
else:

‎html5lib/filters/lint.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11

2-
fromsiximporttext_type
3-
42
from .importbase
53
from ..constantsimportnamespaces,voidElements
64

@@ -32,9 +30,9 @@ def __iter__(self):
3230
iftypein ("StartTag","EmptyTag"):
3331
namespace=token["namespace"]
3432
name=token["name"]
35-
assertnamespaceisNoneorisinstance(namespace,text_type)
33+
assertnamespaceisNoneorisinstance(namespace,str)
3634
assertnamespace!=""
37-
assertisinstance(name,text_type)
35+
assertisinstance(name,str)
3836
assertname!=""
3937
assertisinstance(token["data"],dict)
4038
if (notnamespaceornamespace==namespaces["html"])andnameinvoidElements:
@@ -44,18 +42,18 @@ def __iter__(self):
4442
iftype=="StartTag"andself.require_matching_tags:
4543
open_elements.append((namespace,name))
4644
for (namespace,name),valueintoken["data"].items():
47-
assertnamespaceisNoneorisinstance(namespace,text_type)
45+
assertnamespaceisNoneorisinstance(namespace,str)
4846
assertnamespace!=""
49-
assertisinstance(name,text_type)
47+
assertisinstance(name,str)
5048
assertname!=""
51-
assertisinstance(value,text_type)
49+
assertisinstance(value,str)
5250

5351
eliftype=="EndTag":
5452
namespace=token["namespace"]
5553
name=token["name"]
56-
assertnamespaceisNoneorisinstance(namespace,text_type)
54+
assertnamespaceisNoneorisinstance(namespace,str)
5755
assertnamespace!=""
58-
assertisinstance(name,text_type)
56+
assertisinstance(name,str)
5957
assertname!=""
6058
if (notnamespaceornamespace==namespaces["html"])andnameinvoidElements:
6159
assertFalse,"Void element reported as EndTag token: %(tag)s"% {"tag":name}
@@ -65,26 +63,26 @@ def __iter__(self):
6563

6664
eliftype=="Comment":
6765
data=token["data"]
68-
assertisinstance(data,text_type)
66+
assertisinstance(data,str)
6967

7068
eliftypein ("Characters","SpaceCharacters"):
7169
data=token["data"]
72-
assertisinstance(data,text_type)
70+
assertisinstance(data,str)
7371
assertdata!=""
7472
iftype=="SpaceCharacters":
7573
assertdata.strip(spaceCharacters)==""
7674

7775
eliftype=="Doctype":
7876
name=token["name"]
79-
assertnameisNoneorisinstance(name,text_type)
80-
asserttoken["publicId"]isNoneorisinstance(name,text_type)
81-
asserttoken["systemId"]isNoneorisinstance(name,text_type)
77+
assertnameisNoneorisinstance(name,str)
78+
asserttoken["publicId"]isNoneorisinstance(name,str)
79+
asserttoken["systemId"]isNoneorisinstance(name,str)
8280

8381
eliftype=="Entity":
84-
assertisinstance(token["name"],text_type)
82+
assertisinstance(token["name"],str)
8583

8684
eliftype=="SerializerError":
87-
assertisinstance(token["data"],text_type)
85+
assertisinstance(token["data"],str)
8886

8987
else:
9088
assertFalse,"Unknown token type: %(type)s"% {"type":type}

‎html5lib/filters/sanitizer.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99

1010
importre
1111
importwarnings
12+
fromurllib.parseimporturlparse
1213
fromxml.sax.saxutilsimportescape,unescape
1314

14-
fromsix.movesimporturllib_parseasurlparse
15-
1615
from .importbase
1716
from ..constantsimportnamespaces,prefixes
1817

@@ -845,7 +844,7 @@ def allowed_token(self, token):
845844
# remove replacement characters from unescaped characters
846845
val_unescaped=val_unescaped.replace("\ufffd","")
847846
try:
848-
uri=urlparse.urlparse(val_unescaped)
847+
uri=urlparse(val_unescaped)
849848
exceptValueError:
850849
uri=None
851850
delattrs[attr]

‎html5lib/html5parser.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
fromsiximportviewkeys
2-
31
from .import_inputstream
42
from .import_tokenizer
53

@@ -2773,7 +2771,7 @@ def processEndTag(self, token):
27732771

27742772

27752773
defadjust_attributes(token,replacements):
2776-
needs_adjustment=viewkeys(token['data'])&viewkeys(replacements)
2774+
needs_adjustment=token['data'].keys()&replacements.keys()
27772775
ifneeds_adjustment:
27782776
token['data']=type(token['data'])((replacements.get(k,k),v)
27792777
fork,vintoken['data'].items())

‎html5lib/serializer.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
fromsiximporttext_type
2-
31
importre
42

53
fromcodecsimportregister_error,xmlcharrefreplace_errors
@@ -221,14 +219,14 @@ def __init__(self, **kwargs):
221219
self.strict=False
222220

223221
defencode(self,string):
224-
assertisinstance(string,text_type)
222+
assertisinstance(string,str)
225223
ifself.encoding:
226224
returnstring.encode(self.encoding,"htmlentityreplace")
227225
else:
228226
returnstring
229227

230228
defencodeStrict(self,string):
231-
assertisinstance(string,text_type)
229+
assertisinstance(string,str)
232230
ifself.encoding:
233231
returnstring.encode(self.encoding,"strict")
234232
else:

‎html5lib/tests/test_meta.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
importsix
31
fromunittest.mockimportMock
42

53
from .importsupport
@@ -26,11 +24,7 @@ def test_errorMessage():
2624
r=support.errorMessage(input,expected,actual)
2725

2826
# Assertions!
29-
ifsix.PY2:
30-
assertb"Input:\n1\nExpected:\n2\nReceived\n3\n"==r
31-
else:
32-
assertsix.PY3
33-
assert"Input:\n1\nExpected:\n2\nReceived\n3\n"==r
27+
assert"Input:\n1\nExpected:\n2\nReceived\n3\n"==r
3428

3529
assertinput.__repr__.call_count==1
3630
assertexpected.__repr__.call_count==1

‎html5lib/tests/test_parser2.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
2-
fromsiximportPY2,text_type
3-
41
importio
52

63
from .importsupport# noqa
@@ -73,11 +70,6 @@ def test_debug_log():
7370
('dataState','InBodyPhase','InBodyPhase','processEndTag', {'name':'p','type':'EndTag'}),
7471
('dataState','InBodyPhase','InBodyPhase','processCharacters', {'type':'Characters'})]
7572

76-
ifPY2:
77-
fori,loginenumerate(expected):
78-
log= [x.encode("ascii")ifisinstance(x,text_type)elsexforxinlog]
79-
expected[i]=tuple(log)
80-
8173
assertparser.log==expected
8274

8375

‎html5lib/tests/test_stream.py

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

88
importpytest
99

10-
importsix
11-
fromsix.movesimporthttp_client,urllib
10+
importhttp.client
11+
importurllib.response
1212

1313
fromhtml5lib._inputstreamimport (BufferedStream,HTMLInputStream,
1414
HTMLUnicodeInputStream,HTMLBinaryInputStream)
@@ -190,7 +190,7 @@ def makefile(self, _mode, _bufsize=None):
190190
# pylint:disable=unused-argument
191191
returnBytesIO(b"HTTP/1.1 200 Ok\r\n\r\nText")
192192

193-
source=http_client.HTTPResponse(FakeSocket())
193+
source=http.client.HTTPResponse(FakeSocket())
194194
source.begin()
195195
stream=HTMLInputStream(source)
196196
assertstream.charsUntil(" ")=="Text"
@@ -201,15 +201,12 @@ def test_python_issue_20007_b():
201201
Make sure we have a work-around for Python bug #20007
202202
http://bugs.python.org/issue20007
203203
"""
204-
ifsix.PY2:
205-
return
206-
207204
classFakeSocket:
208205
defmakefile(self,_mode,_bufsize=None):
209206
# pylint:disable=unused-argument
210207
returnBytesIO(b"HTTP/1.1 200 Ok\r\n\r\nText")
211208

212-
source=http_client.HTTPResponse(FakeSocket())
209+
source=http.client.HTTPResponse(FakeSocket())
213210
source.begin()
214211
wrapped=urllib.response.addinfourl(source,source.msg,"http://example.com")
215212
stream=HTMLInputStream(wrapped)

‎html5lib/tests/test_tokenizer2.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11

22
importio
33

4-
fromsiximportunichr,text_type
5-
64
fromhtml5lib._tokenizerimportHTMLTokenizer
75
fromhtml5lib.constantsimporttokenTypes
86

@@ -15,7 +13,7 @@ def ignore_parse_errors(toks):
1513

1614
deftest_maintain_attribute_order():
1715
# generate loads to maximize the chance a hash-based mutation will occur
18-
attrs= [(unichr(x),text_type(i))fori,xinenumerate(range(ord('a'),ord('z')))]
16+
attrs= [(chr(x),str(i))fori,xinenumerate(range(ord('a'),ord('z')))]
1917
stream=io.StringIO("<span "+" ".join("%s='%s'"% (x,i)forx,iinattrs)+">")
2018

2119
toks=HTMLTokenizer(stream)
@@ -48,7 +46,7 @@ def test_duplicate_attribute():
4846

4947
deftest_maintain_duplicate_attribute_order():
5048
# generate loads to maximize the chance a hash-based mutation will occur
51-
attrs= [(unichr(x),text_type(i))fori,xinenumerate(range(ord('a'),ord('z')))]
49+
attrs= [(chr(x),str(i))fori,xinenumerate(range(ord('a'),ord('z')))]
5250
stream=io.StringIO("<span "+" ".join("%s='%s'"% (x,i)forx,iinattrs)+" a=100>")
5351

5452
toks=HTMLTokenizer(stream)

‎html5lib/tests/test_treewalkers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
importitertools
33
importsys
44

5-
fromsiximportunichr,text_type
65
importpytest
76

87
try:
@@ -150,7 +149,7 @@ def test_maintain_attribute_order(treeName):
150149
pytest.skip("Treebuilder not loaded")
151150

152151
# generate loads to maximize the chance a hash-based mutation will occur
153-
attrs= [(unichr(x),text_type(i))fori,xinenumerate(range(ord('a'),ord('z')))]
152+
attrs= [(chr(x),str(i))fori,xinenumerate(range(ord('a'),ord('z')))]
154153
data="<span "+" ".join("%s='%s'"% (x,i)forx,iinattrs)+">"
155154

156155
parser=html5parser.HTMLParser(tree=treeAPIs["builder"])

‎html5lib/tests/tokenizer.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
importre
66

77
importpytest
8-
fromsiximportunichr
98

109
fromhtml5lib._tokenizerimportHTMLTokenizer
1110
fromhtml5libimportconstants,_utils
@@ -145,15 +144,15 @@ def repl(m):
145144
low=int(m.group(2),16)
146145
if0xD800<=high<=0xDBFFand0xDC00<=low<=0xDFFF:
147146
cp= ((high-0xD800)<<10)+ (low-0xDC00)+0x10000
148-
returnunichr(cp)
147+
returnchr(cp)
149148
else:
150-
returnunichr(high)+unichr(low)
149+
returnchr(high)+chr(low)
151150
else:
152-
returnunichr(int(m.group(1),16))
151+
returnchr(int(m.group(1),16))
153152
try:
154153
return_surrogateRe.sub(repl,inp)
155154
exceptValueError:
156-
# This occurs whenunichr throws ValueError, which should
155+
# This occurs whenchr throws ValueError, which should
157156
# only be for a lone-surrogate.
158157
if_utils.supports_lone_surrogates:
159158
raise

‎html5lib/treebuilders/base.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
fromsiximporttext_type
2-
31
from ..constantsimportscopingElements,tableInsertModeElements,namespaces
42

53
# The scope markers are inserted when entering object elements,
@@ -199,7 +197,7 @@ def elementInScope(self, target, variant=None):
199197
# match any node with that name
200198
exactNode=hasattr(target,"nameTuple")
201199
ifnotexactNode:
202-
ifisinstance(target,text_type):
200+
ifisinstance(target,str):
203201
target= (namespaces["html"],target)
204202
assertisinstance(target,tuple)
205203

@@ -322,7 +320,7 @@ def _setInsertFromTable(self, value):
322320

323321
definsertElementNormal(self,token):
324322
name=token["name"]
325-
assertisinstance(name,text_type),"Element %s not unicode"%name
323+
assertisinstance(name,str),"Element %s not unicode"%name
326324
namespace=token.get("namespace",self.defaultNamespace)
327325
element=self.elementClass(name,namespace)
328326
element.attributes=token["data"]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp