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

Commita897f19

Browse files
committed
Welcome to Python 3.
We now fail the same three tests on both Py2 and Py3. I'm fairly certain themeta-preparser among other things is broken on Py3, but we have no tests forit. (We should fix that.)
1 parenteb7f702 commita897f19

File tree

52 files changed

+3469
-3446
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3469
-3446
lines changed

‎html5lib/__init__.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
tree = html5lib.parse(f)
1212
"""
1313
__version__="0.95-dev"
14-
fromhtml5parserimportHTMLParser,parse,parseFragment
15-
fromtreebuildersimportgetTreeBuilder
16-
fromtreewalkersimportgetTreeWalker
17-
fromserializerimportserialize
14+
from.html5parserimportHTMLParser,parse,parseFragment
15+
from.treebuildersimportgetTreeBuilder
16+
from.treewalkersimportgetTreeWalker
17+
from.serializerimportserialize

‎html5lib/constants.py‎

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

‎html5lib/filters/inject_meta_charset.py‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import_base
1+
from .import_base
22

33
classFilter(_base.Filter):
44
def__init__(self,source,encoding):
@@ -13,44 +13,44 @@ def __iter__(self):
1313
fortokenin_base.Filter.__iter__(self):
1414
type=token["type"]
1515
iftype=="StartTag":
16-
iftoken["name"].lower()==u"head":
16+
iftoken["name"].lower()=="head":
1717
state="in_head"
1818

1919
eliftype=="EmptyTag":
20-
iftoken["name"].lower()==u"meta":
20+
iftoken["name"].lower()=="meta":
2121
# replace charset with actual encoding
2222
has_http_equiv_content_type=False
23-
for (namespace,name),valueintoken["data"].iteritems():
23+
for (namespace,name),valueintoken["data"].items():
2424
ifnamespace!=None:
2525
continue
26-
elifname.lower()==u'charset':
26+
elifname.lower()=='charset':
2727
token["data"][(namespace,name)]=self.encoding
2828
meta_found=True
2929
break
30-
elifname==u'http-equiv'andvalue.lower()==u'content-type':
30+
elifname=='http-equiv'andvalue.lower()=='content-type':
3131
has_http_equiv_content_type=True
3232
else:
33-
ifhas_http_equiv_content_typeand (None,u"content")intoken["data"]:
34-
token["data"][(None,u"content")]=u'text/html; charset=%s'%self.encoding
33+
ifhas_http_equiv_content_typeand (None,"content")intoken["data"]:
34+
token["data"][(None,"content")]='text/html; charset=%s'%self.encoding
3535
meta_found=True
3636

37-
eliftoken["name"].lower()==u"head"andnotmeta_found:
37+
eliftoken["name"].lower()=="head"andnotmeta_found:
3838
# insert meta into empty head
39-
yield {"type":"StartTag","name":u"head",
39+
yield {"type":"StartTag","name":"head",
4040
"data":token["data"]}
41-
yield {"type":"EmptyTag","name":u"meta",
42-
"data": {(None,u"charset"):self.encoding}}
43-
yield {"type":"EndTag","name":u"head"}
41+
yield {"type":"EmptyTag","name":"meta",
42+
"data": {(None,"charset"):self.encoding}}
43+
yield {"type":"EndTag","name":"head"}
4444
meta_found=True
4545
continue
4646

4747
eliftype=="EndTag":
48-
iftoken["name"].lower()==u"head"andpending:
48+
iftoken["name"].lower()=="head"andpending:
4949
# insert meta into head (if necessary) and flush pending queue
5050
yieldpending.pop(0)
5151
ifnotmeta_found:
52-
yield {"type":"EmptyTag","name":u"meta",
53-
"data": {(None,u"charset"):self.encoding}}
52+
yield {"type":"EmptyTag","name":"meta",
53+
"data": {(None,"charset"):self.encoding}}
5454
whilepending:
5555
yieldpending.pop(0)
5656
meta_found=True

‎html5lib/filters/lint.py‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
fromgettextimportgettext
22
_=gettext
33

4-
import_base
4+
from .import_base
55
fromhtml5lib.constantsimportcdataElements,rcdataElements,voidElements
66

77
fromhtml5lib.constantsimportspaceCharacters
8-
spaceCharacters=u"".join(spaceCharacters)
8+
spaceCharacters="".join(spaceCharacters)
99

1010
classLintError(Exception):pass
1111

@@ -19,22 +19,22 @@ def __iter__(self):
1919
name=token["name"]
2020
ifcontentModelFlag!="PCDATA":
2121
raiseLintError(_("StartTag not in PCDATA content model flag: %s")%name)
22-
ifnotisinstance(name,unicode):
23-
raiseLintError(_(u"Tag name is not a string: %r")%name)
22+
ifnotisinstance(name,str):
23+
raiseLintError(_("Tag name is not a string: %r")%name)
2424
ifnotname:
25-
raiseLintError(_(u"Empty tag name"))
25+
raiseLintError(_("Empty tag name"))
2626
iftype=="StartTag"andnameinvoidElements:
27-
raiseLintError(_(u"Void element reported as StartTag token: %s")%name)
27+
raiseLintError(_("Void element reported as StartTag token: %s")%name)
2828
eliftype=="EmptyTag"andnamenotinvoidElements:
29-
raiseLintError(_(u"Non-void element reported as EmptyTag token: %s")%token["name"])
29+
raiseLintError(_("Non-void element reported as EmptyTag token: %s")%token["name"])
3030
iftype=="StartTag":
3131
open_elements.append(name)
3232
forname,valueintoken["data"]:
33-
ifnotisinstance(name,unicode):
33+
ifnotisinstance(name,str):
3434
raiseLintError(_("Attribute name is not a string: %r")%name)
3535
ifnotname:
36-
raiseLintError(_(u"Empty attribute name"))
37-
ifnotisinstance(value,unicode):
36+
raiseLintError(_("Empty attribute name"))
37+
ifnotisinstance(value,str):
3838
raiseLintError(_("Attribute value is not a string: %r")%value)
3939
ifnameincdataElements:
4040
contentModelFlag="CDATA"
@@ -45,15 +45,15 @@ def __iter__(self):
4545

4646
eliftype=="EndTag":
4747
name=token["name"]
48-
ifnotisinstance(name,unicode):
49-
raiseLintError(_(u"Tag name is not a string: %r")%name)
48+
ifnotisinstance(name,str):
49+
raiseLintError(_("Tag name is not a string: %r")%name)
5050
ifnotname:
51-
raiseLintError(_(u"Empty tag name"))
51+
raiseLintError(_("Empty tag name"))
5252
ifnameinvoidElements:
53-
raiseLintError(_(u"Void element reported as EndTag token: %s")%name)
53+
raiseLintError(_("Void element reported as EndTag token: %s")%name)
5454
start_name=open_elements.pop()
5555
ifstart_name!=name:
56-
raiseLintError(_(u"EndTag (%s) does not match StartTag (%s)")% (name,start_name))
56+
raiseLintError(_("EndTag (%s) does not match StartTag (%s)")% (name,start_name))
5757
contentModelFlag="PCDATA"
5858

5959
eliftype=="Comment":
@@ -62,27 +62,27 @@ def __iter__(self):
6262

6363
eliftypein ("Characters","SpaceCharacters"):
6464
data=token["data"]
65-
ifnotisinstance(data,unicode):
65+
ifnotisinstance(data,str):
6666
raiseLintError(_("Attribute name is not a string: %r")%data)
6767
ifnotdata:
68-
raiseLintError(_(u"%s token with empty data")%type)
68+
raiseLintError(_("%s token with empty data")%type)
6969
iftype=="SpaceCharacters":
7070
data=data.strip(spaceCharacters)
7171
ifdata:
72-
raiseLintError(_(u"Non-space character(s) found in SpaceCharacters token: ")%data)
72+
raiseLintError(_("Non-space character(s) found in SpaceCharacters token: ")%data)
7373

7474
eliftype=="Doctype":
7575
name=token["name"]
7676
ifcontentModelFlag!="PCDATA":
7777
raiseLintError(_("Doctype not in PCDATA content model flag: %s")%name)
78-
ifnotisinstance(name,unicode):
79-
raiseLintError(_(u"Tag name is not a string: %r")%name)
78+
ifnotisinstance(name,str):
79+
raiseLintError(_("Tag name is not a string: %r")%name)
8080
# XXX: what to do with token["data"] ?
8181

8282
eliftypein ("ParseError","SerializeError"):
8383
pass
8484

8585
else:
86-
raiseLintError(_(u"Unknown token type: %s")%type)
86+
raiseLintError(_("Unknown token type: %s")%type)
8787

8888
yieldtoken

‎html5lib/filters/optionaltags.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import_base
1+
from .import_base
22

33
classFilter(_base.Filter):
44
defslider(self):

‎html5lib/filters/sanitizer.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import_base
1+
from .import_base
22
fromhtml5lib.sanitizerimportHTMLSanitizerMixin
33

44
classFilter(_base.Filter,HTMLSanitizerMixin):

‎html5lib/filters/whitespace.py‎

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

77
importre
88

9-
import_base
9+
from .import_base
1010
fromhtml5lib.constantsimportrcdataElements,spaceCharacters
11-
spaceCharacters=u"".join(spaceCharacters)
11+
spaceCharacters="".join(spaceCharacters)
1212

13-
SPACES_REGEX=re.compile(u"[%s]+"%spaceCharacters)
13+
SPACES_REGEX=re.compile("[%s]+"%spaceCharacters)
1414

1515
classFilter(_base.Filter):
1616

@@ -29,7 +29,7 @@ def __iter__(self):
2929

3030
elifnotpreserveandtype=="SpaceCharacters"andtoken["data"]:
3131
# Test on token["data"] above to not introduce spaces where there were not
32-
token["data"]=u" "
32+
token["data"]=" "
3333

3434
elifnotpreserveandtype=="Characters":
3535
token["data"]=collapse_spaces(token["data"])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp